- 1 External
- 2 Internal
- 3 Overview
- 4 How Helm Dependencies Work
- 5 Manual Dependencies
- 6 Subcharts and Global Values
- 7 Operational Considerations
- 8 Retrieve Individual Chart Archives
- 9 Dependency Operations
- 10 Aliases
- 11 Dependency TODO
How Helm Dependencies Work
This was written for Helm 2.14.3.
All applications, maybe with the exception of the most trivial, usually depend on other runtime components, such as web servers, caches, databases, etc. Helm provides a mechanisms to formally specify, manage and deploy these dependencies as part of a release. A Helm chart may declared dependencies, which are other Helm charts published in external repositories, conveniently packaged by people who presumably know the respective components well, thus they know how to best deploy them on Kubernetes.
During the installation or upgrade process, the Helm client looks into the ./charts sub-directory of the chart being installed, and installs/upgrades the charts whose chart archives are found in that subdirectory. The content of the charts/ subdirectory is the one and only source of truth on dependencies to be installed or upgraded. If a dependency chart is not present in the charts/ subdirectory at the time of installation/upgrade, it is not installed/upgraded. All charts present in the charts/ subdirectory at the time of installation/upgraded are installed/upgraded.
However, Helm provides additional convenience functionality to manage the content of the charts/ subdirectory based on a list of dependency "coordinates" (name, version and repository URL) specified in the chart's requirements.yaml. The helm dependency commands operate on requirements.yaml, with the goal of keeping the content of the charts/ subdirectory in sync with the content of requirements.yaml.
This charts/ content management functionality (helm dependency) must be explicitly invoked and it is NOT automatically triggered during the installation or update process. However, some sanity checks are performed by helm install, which fails if dependencies are declared in requirements.yaml but not present in charts/.
If a dependency is present in the charts/ subdirectory but not in requirements.yaml, it will be considered a manually-managed dependency and it will be installed.
Helm documentation recommends requirements.yaml as the preferred method to manage dependencies. Some documents will refer to dependencies specified in requirement.yaml as dynamic dependencies.
A dependency is a transitive dependency of a chart, if it is a dependency of one of the chart's dependencies. The transitive dependency must exist in the dependency chart's charts/ sub-directory. Simply declaring it in the dependency chart's requirements.yaml file does not make it a transitive dependency, in that the helm dependency update executed on the current chart will identify the direct dependency, but not the "transitive" dependency.
As an example, if the chart
a declares in its requirements.yaml that it depends on chart
b, and chart
b declares in its requirements.yaml that it depends on chart
c, but helm dependency update is not executed on
b, so no chart archives are downloaded in b/charts/, executing helm dependency update on chart
b as a dependency, but no
c. In other words, helm dependency update does not look at requirements.yaml, only at the content of the charts/ directory.
Each chart is responsible for contributing the continuity of the transitive dependency graph by insuring that its dependencies are present in charts/. Simply mentioning them in its requirements.yaml is not sufficient.
Continuing with the above example, if the chart
b has the
c's chart archive in its charts/, helm dependency update executed on
a with update requirements.lock to indicate
b as dependency, but will bring
b chart archive in charts/, and the chart archive file includes the
c chart archive.
Dynamic Dependency Management Workflow
Find a repository that exposes the dependency. You can start by searching the locally-added repositories with helm search. Also you can add additional repositories with helm repo add. Before searching, update the locally-cached information with helm repo update.
Then the dependency must be explicitly downloaded from the remote repository into the chart's charts/directory with helm dependency update. If the update step is not performed, an attempt to install the chart will end up in:
Error: found in requirements.yaml, but missing in charts/ directory: postgresql
Configure integration points in the top level, dependent's values.yaml.
Then the chart is installed with helm install. The dependency will be also installed.
Dependency configuration values should be specified in the top values.yaml, and should be prefixed with the dependency name.
It is recommended to only override values in the top level chart, and not in any subchart.
Dependency Selective Loading
All dependencies declared in requirements.yaml are loaded by default. However, tags and conditions can be used to perform selective loading. Conditions are YAML paths specified in values.yaml that can be declared to be 'true' or 'false'. Tags are list of labels associated with a specific dependency. The tags can be enabled or disabled in values.yaml by specifying the tag and a boolean value. Also, the helm instal --set parameter can be used to alter tag and condition values at installation time.
Conditions or tags should be added to any dependencies that are optional.
Importing Child Values
The dependencies declared in the charts/ directory are manually managed.
The charts declared in the "charts/" subdirectory are named "subcharts".
Subcharts and Global Values
When Helm installs or updates a chart that has dependencies, it will aggregate all Kubernetes objects declared by the chart and dependencies in a single set. sort the object by types, then by name, and create/update in that order. Also see Installation and De-Installation Order.
Retrieve Individual Chart Archives
helm pull stable/postgresql
Each element of the "dependencies" array in the requirements.yaml file allows for an optional "alias" attribute.
- Clarify the need for helm dependency update in case of dynamic dependencies. What happens if we don't do it.
- If I rely on a dependency referred from an external Helm repository, and the repository exposes newer versions, can I still rely on the fact that the old version is still available? I might not want to upgrade to the "latest", but keep using a version I tested with and was proven stable.