I am trying to understand the usage of Requirements.lock file . For using a dependent chart , we can make use of Requirements.yaml . Based on documentation
Requirements.lock : rebuild the charts/ directory based on the requirements.lock file
Requirements.yaml : update charts/ based on the contents of requirements.yaml
Can someone explain the difference and usage of lock file and do we need to checking requirements.lock file in the repo too ?
Helm consists of two main components: Helm Client – allows developers to create new charts, manage chart repositories, and interact with the tiller server. Tiller Server – runs inside the Kubernetes cluster. Interacts with Helm client, and translates chart definitions and configuration to Kubernetes API commands.
It will pull down the latest charts that satisfy the dependencies, and clean up old dependencies. On successful update, this will generate a lock file that can be used to rebuild the dependencies to an exact version.
Helm Dependency Build: Build is used to reconstruct a chart's dependencies to the state specified in the lock file. This will not re-negotiate dependencies, as 'helm dependency update' does. If no lock file is found, 'helm dependency build' will mirror the behavior of 'helm dependency update'.
The Helm chart directory contains: Directory charts – Used for adding dependent charts. Empty by default. Directory templates – Configuration files that deploy in the cluster. YAML file – Outline of the Helm chart structure. YAML file – Formatting information for configuring the chart.
If no lock file is found, ‘helm dependency build’ will mirror the behavior of the ‘helm dependency update’ command. This means it will update the on-disk dependencies to mirror the requirements.yaml file and generate a lock file.
They are installed before the rest of the chart, and are subject to some limitations. CRD YAML files should be placed in the crds/ directory inside of a chart. Multiple CRDs (separated by YAML start and end markers) may be placed in the same file. Helm will attempt to load all of the files in the CRD directory into Kubernetes.
All of this is also true if you're using the older, Helm v2-compatible layout that lists dependencies in a separate requirements.yaml file. In this case the lock file is requirements.lock, but version: is still a semantic version constraint and the same helm dependency commands update the lock file.
This article says it well:
Much like a runtime language dependency file (such as Python’s requirements.txt), the requirements.yaml file allows you to manage your chart’s dependencies and their versions. When updating dependencies, a lockfile is generated so that subsequent fetching of dependencies use a known, working version.
The requirements.yaml file lists only the immediate dependencies that your chart needs. This makes it easier for you to focus on your chart.
The requirements.lock file lists the exact versions of immediate dependencies and their dependencies and their dependencies and so forth. This allows helm
to precisely track the entire dependency tree and recreate it exactly as it last worked--even if some of the dependencies (or their dependencies) are updated later.
Here's roughly how it works:
helm install
and helm creates the requirements.lock file as it builds the dependency tree.helm install
, helm will ensure that it uses the same versions identified in the requirements.lock file.helm install
(or helm upgrade
) and helm will notice your changes and update the requirements.lock file to reflect them.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With