Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use of Requirements.lock file in Helm charts

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 ?

like image 317
Balakumar Ezhilmaran Avatar asked Dec 10 '18 09:12

Balakumar Ezhilmaran


People also ask

What are the main component files of helm?

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.

What does helm dependency update do?

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.

What does helm dependency build do?

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'.

What is the directory structure for Helm charts?

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.

What happens if no lock file is found in helm dependencies?

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.

What are the limitations of the crd files installed with Helm?

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.

What is the difference between Helm version and version Lock?

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.


1 Answers

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:

  1. You create the initial requirements.yaml file. You run helm install and helm creates the requirements.lock file as it builds the dependency tree.
  2. On the next helm install, helm will ensure that it uses the same versions identified in the requirements.lock file.
  3. At some later date, you update the requirements.yaml file. You run helm install (or helm upgrade) and helm will notice your changes and update the requirements.lock file to reflect them.
like image 69
John Anderson Avatar answered Oct 10 '22 16:10

John Anderson