What it is
Helm is a package manager for Kubernetes that helps you define, install, and upgrade even the most complex Kubernetes applications.
Installation
Linux
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
macOS
brew install helm
Windows (using Chocolatey)
choco install kubernetes-helm
Windows (using Scoop)
scoop install helm
Core Concepts
- Chart: A Helm package. It contains all the resource definitions needed to run an application, a tool, or a service in Kubernetes. Charts are versioned and can be shared.
- Repository: A place where charts are stored and shared. Helm can interact with chart repositories to fetch charts.
- Release: An instance of a chart running in a Kubernetes cluster. A chart can be released multiple times in a cluster, and each release can have a different configuration.
Commands / Usage
Creating and Managing Charts
helm create mychart: Create a new chart with a default directory structure and boilerplate.helm create my-nginx-charthelm package mychart: Package a chart directory into a chart archive (.tgzfile).helm package my-nginx-chart # Output: Successfully packaged chart and saved it to: my-nginx-chart-0.1.0.tgzhelm install <release-name> <chart-path-or-repo>: Install a chart into Kubernetes.helm install my-nginx ./my-nginx-chart # Output: NAME: my-nginx LAST DEPLOYED: ... STATUS: deployed REVISION: 1 ...helm install bitnami/nginx --version 15.4.1 # Output: NAME: some-nginx LAST DEPLOYED: ... STATUS: deployed REVISION: 1 ...helm upgrade <release-name> <chart-path-or-repo>: Upgrade an existing release to a new version or with a new configuration.helm upgrade my-nginx ./my-nginx-chart --version 0.2.0 # Output: UPGRADE SUCCESSFUL: ...helm uninstall <release-name>: Uninstall a release.helm uninstall my-nginx # Output: release "my-nginx" uninstalledhelm rollback <release-name> <revision-number>: Roll back a release to a previous revision.helm rollback my-nginx 1 # Output: rolled back my-nginx to ...helm list: List all releases in the current namespace.helm list # Output: NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION # my-nginx default 2 ... deployed my-nginx-chart-0.1.0 ...helm list -a: List all releases in all namespaces.helm list -ahelm history <release-name>: Show the history of a release.helm history my-nginx # Output: REVISION UPDATED STATUS CHART DESCRIPTION # 1 ... deployed ... my-nginx-chart-0.1.0 Install complete # 2 ... deployed ... my-nginx-chart-0.1.0 Upgrade "my-nginx"helm status <release-name>: Show the status of a release.helm status my-nginx # Output: NAME: my-nginx LAST DEPLOYED: ... STATUS: deployed REVISION: 2 ...
Managing Repositories
helm repo add <repo-name> <repo-url>: Add a chart repository.helm repo add bitnami https://charts.bitnami.com/bitnami # Output: "bitnami" has been added to your repositorieshelm repo list: List all configured chart repositories.helm repo list # Output: NAME URL # bitnami https://charts.bitnami.com/bitnamihelm repo update: Update the local cache of chart repositories.helm repo update # Output: ... updated.helm repo remove <repo-name>: Remove a chart repository.helm repo remove bitnami # Output: "bitnami" has been removed from your repositories
Searching for Charts
helm search repo <keyword>: Search for charts in repositories.helm search repo nginx # Output: NAME CHART VERSION APP VERSION DESCRIPTION # bitnami/nginx 15.4.1 1.21.6 NGINX Open Source is a web server that can be also used as a reverse proxy...helm search repo <repo-name>/<chart-name>: Search for a specific chart in a repository.helm search repo bitnami/redis # Output: NAME CHART VERSION APP VERSION DESCRIPTION # bitnami/redis 17.7.1 7.0 Redis is an open source, in-memory data structure store...helm search hub <keyword>: Search for charts on Artifact Hub.helm search hub prometheus # Output: NAME CHART VERSION APP VERSION PLATFORM REPOSITORY # prometheus-community/prometheus 22.0.1 2.45.0 kubernetes prometheus-community # ...
Inspecting Charts
helm show chart <chart-path-or-repo>: Show information about a chart.helm show chart bitnami/nginx # Output: apiVersion: v2 ...helm show values <chart-path-or-repo>: Show the default values for a chart.helm show values bitnami/nginx # Output: replicaCount: 1 ...helm show readme <chart-path-or-repo>: Show the README for a chart.helm show readme bitnami/nginx # Output: # NGINX Open Source ...
Customizing Installations
helm install <release-name> <chart> -f my-values.yaml: Install a chart using a custom values file.# Create a file named custom-values.yaml with: # replicaCount: 3 # service: # type: LoadBalancer helm install my-custom-nginx ./my-nginx-chart -f custom-values.yamlhelm install <release-name> <chart> --set key1=value1,key2.subkey=value2: Install a chart and override values using--set.helm install my-set-nginx ./my-nginx-chart --set replicaCount=2,service.type=NodePorthelm template <release-name> <chart> -f my-values.yaml: Render charts locally to see the Kubernetes manifests without deploying them.helm template my-nginx-preview ./my-nginx-chart -f custom-values.yaml # Output: --- apiVersion: v1 ...
Chart Hooks
helm uninstall <release-name> --no-hooks: Uninstall a release without running delete hooks.helm uninstall my-nginx --no-hookshelm upgrade <release-name> <chart> --atomic: If an upgrade fails, the release is rolled back to the previous version.helm upgrade my-nginx ./my-nginx-chart --atomic
Common Patterns
-
Deploying an application with custom configurations:
helm upgrade --install my-app bitnami/redis -f my-redis-values.yaml --namespace dev(This command installs if
my-appdoesn’t exist, or upgrades if it does. It uses a localmy-redis-values.yamlfile for configuration and deploys into thedevnamespace.) -
Finding the latest version of a chart and installing it:
CHART_INFO=$(helm search repo bitnami/nginx --devel --limit 1) CHART_NAME=$(echo "$CHART_INFO" | awk '{print $1}') LATEST_VERSION=$(echo "$CHART_INFO" | awk '{print $2}') helm install my-latest-nginx $CHART_NAME --version $LATEST_VERSION -
Rendering a chart to stdout with specific values:
helm template my-app ./my-app-chart --set image.tag=latest --namespace default -
Listing releases in a specific namespace:
helm list --namespace kube-system -
Getting the YAML output of a release’s deployed resources:
helm get manifest my-nginx
Gotchas
- Namespaces: By default, Helm operates in the
defaultnamespace. Always specify namespaces using--namespaceor ensure yourkubectlcontext is set correctly if you want to manage releases in different namespaces. - Release Names: Release names must be unique within a namespace.
- Chart Versioning: When upgrading, Helm defaults to the latest chart version. Explicitly specify
--versionif you need a specific older version to avoid unintended upgrades. helm installvshelm upgrade:helm installwill fail if a release with that name already exists.helm upgrade --install(orhelm upgrade -i) is often preferred as it will install the release if it doesn’t exist, or upgrade it if it does.- Helm 2 vs Helm 3: Helm 3 removed the Tiller component, simplifying the architecture. If you encounter older documentation or setups, be aware of the differences. Most modern usage is Helm 3.
- Chart Hooks: By default, Helm runs hooks during installation, upgrade, and uninstall. Be mindful of hooks that might interfere with automated processes or require specific conditions to run. Use
--no-hooksduring uninstall if necessary.