Introduction to Helm
What Happens When You Install a Chart?
To understand how Helm manages dependencies during installation, let's summarize the whole process of installing a chart with dependencies. When you run the command:
helm install my-release kube-prometheus-stack
The following actions take place:
Helm will check if the dependencies are already present in the local cache (in the folder
/root/.cache/helm/repository).If they are not present, it will determine the repository URL and the version of each dependency from the
Chart.yamlfile.It will then download the corresponding
.tgzarchives from the repositories, extract them, and store them locally in the cache.It always starts with a folder called
crds/that may contain Custom Resource Definitions used by the chart.It then moves to the dependencies of the dependencies, and so on, until it reaches the top-level chart.
The order of installation is important because some charts may depend on others. Helm uses hooks usually defined in the
annotationssection of the metadata to manage the order of installation.
Example:
metadata:
name: a-dependency
annotations:
"helm.sh/hook": pre-install
"helm.sh/hook-weight": "0"
The pre-install hook indicates that this resource should be created before the main chart is installed. If other resources have the same hook, the helm.sh/hook-weight annotation determines the order in which they are created:
- Helm uses the ascending order of weights to install resources. Lower weight resources are installed before higher weight ones.
- If two hooks share the same weight, they’re ordered lexicographically by name.
- Weight can be a negative or positive integer.
- If no weight is specified, it defaults to
0.
Example:
# Runs first
metadata:
annotationsCloud-Native Microservices With Kubernetes - 2nd Edition
A Comprehensive Guide to Building, Scaling, Deploying, Observing, and Managing Highly-Available Microservices in KubernetesEnroll now to unlock all content and receive all future updates for free.
