Managing Chart Dependencies
1. Declaring Dependencies
| Property | Values | Description |
|---|---|---|
| dependencies | [] |
List of chart dependencies |
| name | string |
Name of the dependency chart |
| alias | string |
Alias to use for the dependency |
| version | string |
Version of the dependency chart |
| repository | string |
Repository URL or alias for the dependency chart |
| condition | string |
Condition to enable the dependency |
| tags | [] |
Tags to include the dependency |
| import-values | [] |
Import values from the dependency chart |
Example: Declaring a dependency in Chart.yaml
apiVersion: v2
name: my-app
version: 1.0.0
dependencies:
- name: nginx
version: "1.2.3"
repository: "https://charts.bitnami.com/bitnami"
- name: postgresql
version: "10.1.2"
repository: "@bitnami"
condition: postgresql.enabled
2. Specifying Dependency Version
| Field | Description | Example |
|---|---|---|
| version | Version of the dependency chart to use | "1.2.3" |
| repository | Repository URL or alias where the chart is located | "https://example.com/charts" |
| condition | Conditional value to enable or disable the dependency | "server.enabled" |
| tags | List of tags to include or exclude dependencies | ["frontend", "backend"] |
| import-values | Import values from parent chart to child chart | [{"childKey": "server.port", "parentKey": "port"}] |
Example: Specifying Chart Version in requirements.yaml
dependencies:
- name: nginx
version: "1.2.3"
repository: "https://kubernetes-charts.storage.googleapis.com"
Note: The
version field supports semantic versioning (SemVer) and can use wildcards like * or >=1.0.0.
3. Setting Dependency Repository
| Repository Name | URL | Notes |
|---|---|---|
| stable | https://charts.helm.sh/stable |
Official stable Helm charts repository |
| bitnami | https://charts.bitnami.com/bitnami |
Bitnami charts repository |
| incubator | https://charts.helm.sh/incubator |
Community incubated charts |
Example: Adding a Repository
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update
Note: After adding a repository, run
helm repo update to refresh the local cache.
4. Using Local Dependencies
| Dependency Type | Specification | Notes |
|---|---|---|
| local | local: ./my-local-chart |
Path to local chart directory relative to Chart.yaml |
Example: Local Dependency in Chart.yaml
apiVersion: v2
name: my-app
version: 1.0.0
dependencies:
- name: my-local-chart
alias: local-chart
version: 0.1.0
repository: "@local"
condition: local-chart.enabled
tags:
- frontend
Note: Local dependencies must be placed in the
charts/ directory or referenced via a relative path from Chart.yaml.
5. Enabling Conditional Dependencies
Conditional dependencies in Helm charts allow you to include or exclude chart dependencies based on specific conditions. This is useful for enabling features only when certain criteria are met, such as environment-specific configurations or feature flags.
| Field | Description | Example |
|---|---|---|
| condition | Specifies the path to a boolean value in the values file that determines whether to include the dependency. | server.enabled |
| tags | Allows dependencies to be included based on tags defined in the values file. | ["frontend", "backend"] |
Example: Using condition in Chart.yaml
dependencies:
- name: nginx
version: 1.2.3
condition: server.enabled
Note: The
condition field checks for a boolean value in the values file. If the value is false, the dependency will not be included in the release.
Note: Tags are useful for grouping dependencies and enabling them collectively. They can be used in combination with conditions.
6. Using Tag-based Dependencies
| Dependency | Tag | Notes |
|---|---|---|
| name | my-app |
Unique identifier for the dependency |
| alias | app |
Optional alias to use in templates |
| version | 1.2.3 |
Version of the chart to use |
| repository | https://example.com/charts |
URL to the chart repository |
| condition | app.enabled |
Conditional rendering based on values |
| tags | frontend,production |
Tags to filter dependencies |
Example: Tag-based dependency in requirements.yaml
dependencies:
- name: my-app
version: 1.2.3
repository: https://example.com/charts
tags:
- frontend
- production
Note: Tag-based dependencies are useful for organizing and filtering chart dependencies in complex environments.
Warning: Ensure that tags are consistently applied across all charts to avoid misconfigurations.
7. Downloading Dependencies
| Command | Description | Options |
|---|---|---|
| helm dependency get | Downloads chart dependencies from Chart.yaml |
--cert-file, --key-file, --ca-file |
| helm dependency update | Updates dependencies and regenerates Chart.lock |
--skip-refresh, --verify |
8. Building Dependency Charts
| Field | Description | Example |
|---|---|---|
| name | Name of the dependency chart | nginx |
| version | Version of the dependency chart | 1.2.3 |
| repository | Repository URL or alias for the chart | https://charts.example.com |
| condition | Conditional value to enable/disable the chart | server.enabled |
| tags | Tags to include or exclude charts | ["frontend", "backend"] |
| import-values | Import values from parent chart to child chart | [{"child": "server.port", "parent": "port"}] |
Example: Defining a dependency in Chart.yaml
apiVersion: v2
name: my-app
version: 1.0.0
dependencies:
- name: nginx
version: 1.2.3
repository: https://charts.example.com
condition: nginx.enabled
tags:
- frontend
Note: The
repository field can be an alias defined in repositories.yaml.
Example: Using import-values to pass values
apiVersion: v2
name: my-app
version: 1.0.0
dependencies:
- name: mysql
version: 8.0.0
repository: https://charts.bitnami.com/bitnami
import-values:
- child: "auth.rootPassword"
parent: "mysqlRootPassword"
9. Listing Dependencies
| Command | Description | Flags |
|---|---|---|
| helm dependency list | Lists all dependencies defined in the Chart.yaml file |
--chart-repo-url, --output |
Note: The
helm dependency list command reads from the Chart.yaml and requirements.yaml files to display the chart dependencies.
10. Importing Child Values
| Property | Description | Example |
|---|---|---|
| values.yaml | Defines values that can be overridden by child charts | |
| import | Used to import values from child charts into parent chart | |
Example: Importing Values from Child Chart
child:
config: "example-value"
import:
childValues: "{{ .Values.child.config }}"
Note: The
import key allows parent charts to access values defined in child charts, enabling shared configuration.
11. Overriding Subchart Values
When a Helm chart depends on subcharts (defined in Chart.yaml), you can override the values of those subcharts using the values.yaml file or command-line flags.
| Override Path | Description | Example |
|---|---|---|
| parent.subchart.key | Override a value in a subchart by prefixing the key with the subchart name. | |
Example: Overriding MySQL Subchart Values
mysql:
auth:
rootPassword: "secret"
username: "admin"
resources:
limits:
cpu: "500m"
Note: Values must be valid YAML and follow the structure defined by the subchart's
values.yaml.
12. Managing Chart.lock File
| Property | Description | Values |
|---|---|---|
| apiVersion | API version of the lock file | v2 |
| entries | List of dependencies and their resolved versions | Array of dependency objects |
| entries.name | Name of the dependency chart | String |
| entries.version | Resolved version of the dependency chart | String |
| entries.repository | Repository URL where the dependency is located | String |
| entries.digest | SHA256 digest of the chart archive | String |
Example: Chart.lock content
apiVersion: v2
entries:
- name: nginx
version: 15.2.0
repository: https://charts.bitnami.com/bitnami
digest: sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef
- name: postgresql
version: 12.1.10
repository: https://charts.bitnami.com/bitnami
digest: sha256:abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890
Note: The
Chart.lock file is automatically generated and managed by Helm. It ensures reproducible deployments by locking dependency versions.