Chart Dependencies
Some charts may depend on others. For instance, because WordPress requires a database to store its data, it will not function properly otherwise. A WordPress chart depends on a database chart, such as MariaDB or MySQL.
Another example is kube-prometheus-stack, a comprehensive monitoring toolkit for Kubernetes clusters that integrates Prometheus, Alertmanager, and Grafana into a single Helm chart. Therefore, it has some dependencies on other charts, such as:
- kube-state-metrics
- node-exporter
- Grafana
To better understand how chart dependencies work, let's explore how the author of the kube-prometheus-stack chart has defined its dependencies. Run the following commands to download the chart and inspect its Chart.yaml file:
# Install yq if you don't have it already
apt-get install -y yq
# Add the Prometheus Community Helm repository
helm repo add prometheus-community \
https://prometheus-community.github.io/helm-charts
# Download the chart locally
cd $HOME &&
helm pull prometheus-community/kube-prometheus-stack \
--version 80.0.0
# Extract the chart:
tar -xvf kube-prometheus-stack-*.tgz
# Check the `Chart.yaml` file and extract the dependencies section:
cat kube-prometheus-stack/Chart.yaml | yq '.dependencies' --yaml-output
You should see the following output representing the dependencies of our chart:
- condition: crds.enabled
name: crds
repository: ''
version: 0.0.0
- condition: kubeStateMetrics.enabled
name: kube-state-metrics
repository: https://prometheus-community.github.io/helm-charts
version: 6.4.2
- condition: nodeExporter.enabled
name: prometheus-node-exporter
repository: https://prometheus-community.github.io/helm-charts
version: 4.49.2
- condition: grafana.enabled
name: grafana
repository: https://grafana.github.io/helm-charts
version: 10.3.0
- condition: windowsMonitoring.enabled
name: prometheus-windows-exporter
repository: https://prometheus-community.github.io/helm-charts
version: 0.12.*
ℹ️ Dependencies used to be defined in the
requirements.yamlfile in older Helm versions (v2.x). Now, they are defined directly in theChart.yamlfile.
When installed, the kube-prometheus-stack chart, based on the dependencies section above, will automatically install the following charts:
- Kube State Metrics chart version 6.4.2
- Node Exporter chart version 4.49.2
- Grafana chart version 10.3.0
- Windows Exporter chart version 0.12.*
If you were the author of the chart, after carefully selecting the dependencies and their versions, and after defining them in the Chart.yaml file, you would need to download the dependencies locally before releasing the chart. You can do this by running the following commands:
helm dependency build $HOME/kube-prometheus-stack
This command will download the required dependencies and place them in the charts/ directory of the extracted chart, and create a lock file named Chart.lock that contains the exact versions of the dependencies used. You can list the contents of the charts/ directory using:
ls $HOME/kube-prometheus-stack/charts/
Helm in Practice
Designing, Deploying, and Operating Kubernetes Applications at ScaleEnroll now to unlock current content and receive all future updates for free. Your purchase supports the author and fuels the creation of more exciting content. Act fast, as the price will rise as the course nears completion!
Hurry! This limited time offer ends in:
To redeem this offer, copy the coupon code below and apply it at checkout:
