In helm, one chart can be dependent on another chart. For instance, a WordPress
application requires a database to start functioning. In helm, we can deploy WordPress as part of the parent chart and MySQL
or any other required application as a dependency of the parent chart.
Helm charts store their dependencies in ‘charts/’. There are two different ways to add dependency charts to parent charts:
Listing all the dependencies inside the Chart.yaml file and helm will download the dependencies and store them in the ‘charts/’ Directory.
Manually populate the dependency chart inside the ‘charts/’ directory.
List dependencies inside the Chart.yaml file
Before listing dependencies in the Chart.yaml file, By default Chart.yaml file looks like this :
# Chart.yaml
apiVersion: v2
name: webserver
description: A Helm chart for Kubernetes
type: application
version: 0.1.0
appVersion: "1.16.0"
Now, let's see how we can populate the dependencies into the Chart.yaml file:
dependencies:
- name: mysql
version: "9.3.4"
repository: "https://charts.bitnami.com/bitnami"
After adding dependencies to the Chart.yaml file :
# Chart.yaml
apiVersion: v2
name: webserver
description: A Helm chart for Kubernetes
type: application
version: 0.1.0
appVersion: "1.16.0"
dependencies:
- name: mysql
version: "9.3.4"
repository: "https://charts.bitnami.com/bitnami"
Using a simple helm command we can pull the chart from the repository defined in the dependencies field:
helm dependency update [CHART]
>> helm dependency update ~/webserver
The above-defined command will generate .webserver/Chart.lock file as well as download all dependencies into the .webserver/charts directory
The Chart.lock
file lists the exact versions of immediate dependencies and their dependencies and so on.
Top comments (0)