Helm cheat sheet
The Helm commands you reach for every day, from adding a repository and installing a chart to reading a release's values and rolling it back, checked on Helm 4.2.
90 entries10 sectionsChecked on Helm 4.2Reviewed
Names such as api, web, prod and bitnami are examples: put your own release, namespace or repository there. A release lives in a namespace, so every command about one takes -n <namespace>, or the context's default when you leave it out. Helm 4 renamed a few flags of Helm 3; where one changed, its row says what it was called.
Repositories and search
Add the repositories charts come from, keep their indexes fresh and find a chart.
helm repo add bitnami https://charts.bitnami.com/bitnamiAdd a chart repository under a name of your choosing.
Tip:
--usernameand--password-stdinadd one that asks for credentials.helm repo updateDownload the latest index of every repository, so search and install see new versions.
helm repo update bitnamiUpdate one repository's index only.
helm repo listList the repositories you added, with their URLs.
helm repo remove bitnamiForget a repository; releases installed from it are left as they are.
helm search repo postgresSearch the charts of the repositories you added, by name and description.
helm search repo bitnami/postgresql --versionsList every version of a chart, with the app version each one ships.
Tip:
--version '^16.0.0'narrows the list to a semver range.helm search hub ingress-nginxSearch Artifact Hub, the public index of charts, for one you have not added.
Tip:
--list-repo-urlprints the repository tohelm repo addfor each result.helm show readme bitnami/postgresqlRead a chart's README without installing it.
helm show chart bitnami/postgresqlPrint a chart's
Chart.yaml: its version, app version and dependencies.helm pull bitnami/postgresql --version 16.4.0 --untarDownload a chart and unpack it into a folder, to read its templates.
OCI registries
Charts stored as OCI artifacts, in the same registries as images.
A chart in a registry is named by an
oci://address and needs nohelm repo add: install, pull and show take the address itself.echo "$TOKEN" | helm registry login ghcr.io -u my-user --password-stdinSign in to a registry, reading the password or token from standard input.
Warning:
-pon the command line leaves the token in your shell's history.helm registry logout ghcr.ioRemove the credentials Helm stored for a registry.
helm install api oci://ghcr.io/acme/charts/api --version 1.4.0Install a chart straight from a registry.
helm show values oci://ghcr.io/acme/charts/api --version 1.4.0Read the default values of a chart in a registry.
helm pull oci://ghcr.io/acme/charts/api --version 1.4.0Download a chart from a registry as a
.tgz.helm push api-1.4.0.tgz oci://ghcr.io/acme/chartsPush a packaged chart; its name and version come from the archive.
Tip: The address ends at the namespace: Helm appends the chart's name itself.
helm upgrade --install api oci://ghcr.io/acme/charts/api@sha256:<digest>Pin a chart to its digest, so a tag pushed again cannot change what you install.
Install and upgrade
Put a chart on the cluster as a release, then move it to new values or a new version.
helm install api bitnami/nginx -n web --create-namespaceInstall a chart as the release
api, making the namespace if it does not exist.helm install bitnami/nginx --generate-nameInstall with a name Helm makes up, such as
nginx-1712345678.helm install api ./apiInstall a chart from a folder on disk, or from a packaged
.tgz.helm upgrade --install api bitnami/nginx -n web -f values-prod.yamlInstall the release if it is not there, upgrade it if it is: the one command for CI.
Tip:
-iis short for--install.helm upgrade api bitnami/nginx --version 18.2.0 --reuse-valuesMove a release to another chart version and keep the values it already has.
helm upgrade --install api ./api --wait --timeout 10mWait until the release's Deployments and pods are ready before returning, failing after 10 minutes.
Tip: Without
--wait, Helm 4 waits for hooks only (hookOnly) and returns once the resources are sent.helm upgrade --install api ./api --rollback-on-failureRoll back to the last good revision when the upgrade fails, or uninstall a failed first install.
Tip: Helm 3 called it
--atomic, which Helm 4 still takes with a warning. It turns--waiton.helm upgrade api ./api --cleanup-on-failDelete the resources an upgrade created when it fails, so the next try does not meet them.
helm upgrade --install api ./api --dry-run=serverRender the chart and have the API server validate the result, changing nothing.
Warning: The output includes Secrets in the clear;
--hide-secretleaves them out.helm upgrade api ./api --force-replaceDelete and recreate resources that cannot be updated in place.
Tip: Helm 3 called it
--force.Warning: Pods are deleted and recreated: expect downtime.
helm install api ./api --take-ownershipAdopt resources that already exist in the cluster instead of failing on them.
helm upgrade --install api ./api --history-max 5Keep five revisions of the release, so its history Secrets do not pile up; the default is 10.
helm upgrade api ./api --server-side=falseApply with Helm's client-side three-way merge instead of server-side apply.
Tip: Helm 4 installs with server-side apply;
auto, an upgrade's default, keeps what the release used before.
Values
What a chart lets you set, and the ways to set it from files and the command line.
helm show values bitnami/postgresql > values.yamlSave a chart's default values, to copy what you change into a file of your own.
helm install db bitnami/postgresql -f values.yaml -f values-prod.yamlPass values files; when two set the same key, the later file wins.
helm install api ./api --set replicaCount=3,image.tag=1.5Set values on the command line, dots for nesting and commas between pairs.
Tip:
--setwins over every-ffile, whatever the order on the line.helm install api ./api --set 'ingress.hosts[0].host=api.example.com'Set an item of a list by its index.
helm install api ./api --set-string podAnnotations.sidecar\.istio\.io/inject=trueForce a value to a string, here an annotation that
--setwould make a boolean; a dot in a key is escaped.helm install api ./api --set-literal 'config.dsn=user=app,host=db'Set a string exactly as written, commas, dots and equals signs included.
helm install api ./api --set-json 'tolerations=[{"key":"gpu","operator":"Exists"}]'Set a list or a map as JSON in one flag.
helm install api ./api --set-file config.script=./init.shSet a value to the contents of a file.
helm get values api -n webPrint the values you supplied to the release, not the chart's defaults.
helm get values api --allPrint every value the release used: the chart's defaults merged with yours.
helm get values api --revision 3Print the values an earlier revision was given, to compare with the current one.
Releases
What is installed, in which state, and what each revision was given.
helm list -n webList the releases in a namespace, with their revision, status, chart and app version.
helm list -AList the releases in every namespace.
helm list -A --failed --pendingList the releases that failed, or are stuck in the middle of an operation.
helm list -n web -qPrint release names only, one a line, for a script.
helm status api -n webShow a release's state, its last deployment and its notes.
helm history api -n webList a release's revisions, each with its status, chart version and description.
helm get manifest api -n webPrint the Kubernetes YAML the release applied, as Helm rendered it.
helm get notes api -n webPrint the chart's NOTES, the instructions shown after an install.
helm get hooks api -n webPrint the release's hooks: the Jobs and other resources it runs before or after a change.
helm get all api -n webPrint a release's values, manifest, hooks and notes at once.
helm get metadata api -n webPrint the release's chart, versions, namespace and status,
-o jsonfor a script.
Roll back and uninstall
Go back to an earlier revision, or take a release off the cluster.
helm rollback api -n webRoll the release back to the revision before the current one.
helm rollback api 4 -n web --waitRoll back to revision 4 and wait for its resources to be ready.
Tip: A rollback is itself a new revision: after it,
historyshows revision 4's chart under a higher number.helm uninstall api -n webDelete the release's resources and its history.
helm uninstall api -n web --keep-historyDelete the resources but keep the history, so the release can be rolled back into existence.
Tip:
helm list --uninstalledlists releases removed this way.helm uninstall api -n web --dry-runShow what would be uninstalled, removing nothing.
helm uninstall api -n web --ignore-not-foundTreat a release that is not there as uninstalled, for a cleanup script that may run twice.
helm uninstallleaves the CRDs of a chart'scrds/folder, and the PersistentVolumeClaims a StatefulSet made, in place: delete them yourself when the data should go too.
Templates and debugging
Render a chart without installing it, and find out why it renders wrong.
helm template api ./api -f values-prod.yamlRender the chart's manifests to standard output, without a cluster.
helm template api ./api -s templates/deployment.yamlRender one template only.
Tip:
--show-onlyis the long form, and takes a path relative to the chart.helm template api ./api --output-dir out/Write each rendered template to its own file under
out/, to diff or review.helm template api ./api --kube-version 1.36 --api-versions monitoring.coreos.com/v1Render as for a given cluster, for templates that read
.Capabilities.helm template api ./api | kubectl apply --dry-run=server -f -Have the cluster validate what a chart renders before you install it.
helm lint ./api -f values-prod.yaml --strictCheck a chart's structure and templates with your values, failing on warnings too.
helm install api ./api --debug --dry-run=clientPrint the computed values and the rendered manifests, with Helm's own log lines.
helm diff upgrade api ./api -n web -f values-prod.yamlShow what an upgrade would change in the cluster, as a diff, from the
helm-diffplugin.Tip: Install the plugin once with
helm plugin install https://github.com/databus23/helm-diff.
Building charts
Start a chart, manage its dependencies, and package it to share.
helm create apiMake a chart folder with a Deployment, a Service, an Ingress and a values file to start from.
helm dependency update ./apiDownload the dependencies
Chart.yamllists intocharts/and writeChart.lock.helm dependency build ./apiDownload the exact versions in
Chart.lock, as CI should.helm dependency list ./apiList a chart's dependencies and whether each one is in
charts/.helm package ./apiPack a chart into
api-<version>.tgz, ready to push or to add to a repository.helm package ./api --version 1.4.0 --app-version 2.1.0Package with a chart version and an app version that override
Chart.yaml's, for CI.helm repo index ./dist --url https://charts.example.comWrite the
index.yamlof a static chart repository from the archives in a folder.helm plugin listList installed plugins, the extra subcommands such as
helm diff.
Chart files
The files of a chart to start from.
Chart.yaml
apiVersion: v2 name: api description: The Acme API type: application version: 1.4.0 appVersion: "2.1.0" dependencies: - name: postgresql version: 16.x.x repository: https://charts.bitnami.com/bitnami condition: postgresql.enabledA chart's metadata with a dependency that the values can switch off with
postgresql.enabled.values.yaml
replicaCount: 2 image: repository: ghcr.io/acme/api tag: "" resources: requests: cpu: 250m memory: 256Mi postgresql: enabled: true auth: database: apiDefaults a reader can override; a dependency's values go under its name.
templates/deployment.yaml
apiVersion: apps/v1 kind: Deployment metadata: name: {{ include "api.fullname" . }} labels: {{- include "api.labels" . | nindent 4 }} spec: replicas: {{ .Values.replicaCount }} selector: matchLabels: {{- include "api.selectorLabels" . | nindent 6 }} template: metadata: labels: {{- include "api.selectorLabels" . | nindent 8 }} spec: containers: - name: api image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" resources: {{- toYaml .Values.resources | nindent 12 }}A template with the helpers
helm createwrites, the image tag falling back toappVersion.
Pitfalls
What goes wrong with Helm, and how to get out of it.
After
helm upgradewith one--set, the values given at install are gone and the chart's defaults are back.Fix: An upgrade starts from the chart's defaults plus what this command gives. Keep the values in a file and pass
-fon every upgrade, or add--reset-then-reuse-valuesto keep the last release's.--reuse-valueskept the old values, but a key the new chart version added is missing and a template fails on it.Fix:
--reuse-valuestakes the last release's values as they are and ignores the new chart's defaults. Use--reset-then-reuse-values, which starts from the new defaults and lays the old values over them.Error: UPGRADE FAILED: another operation (install/upgrade/rollback) is in progress.Fix: An earlier run was killed and left the release
pending-upgrade. Check nothing else is running, thenhelm rollbackto the lastdeployedrevision fromhelm history.Error: release: not found, thoughhelm listshowed it yesterday.Fix: A release belongs to a namespace. Pass the
-nit was installed with, or find it withhelm list -A.A new version of a chart changed its CRDs, but the cluster still has the old ones after
helm upgrade.Fix: Helm installs the files in
crds/once and never upgrades or deletes them. Apply the new CRDs yourself withkubectl apply --server-side -f, before the upgrade.The install fails with
cannot unmarshal bool into Go struct field ... of type stringon an annotation or an env value.Fix:
--setmakestrue,falseand whole numbers into booleans and numbers. Pass the value with--set-string, or quote it in a values file.--setsplit a value at its comma, or nested a key at its dot.Fix: Escape the comma or the dot with a backslash, quote the whole flag, or use
--set-literalfor a string,--set-jsonfor a structure.Error: INSTALLATION FAILED: ... exists and cannot be imported into the current release.Fix: A resource of that name was made outside Helm, or by another release. Delete it, rename it in the values, or pass
--take-ownershipto adopt it.helm upgrade --waittimed out, and the release isfailed.Fix: The new pods never got ready: read
kubectl get podsandkubectl describefor why. Fix it and upgrade again, orhelm rollback;--rollback-on-failuredoes that for you next time.A Secret or ConfigMap changed, but the pods kept the old one after the upgrade.
Fix: Changing them does not restart a Deployment. In the chart, put a checksum of the file in the pod template's annotations, as
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}.