Skip to content
Opsfolk
Kubernetes

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.

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.

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 no helm repo add: install, pull and show take the address itself.

  • echo "$TOKEN" | helm registry login ghcr.io -u my-user --password-stdin

    Sign in to a registry, reading the password or token from standard input.

    Warning: -p on the command line leaves the token in your shell's history.

  • helm registry logout ghcr.io

    Remove the credentials Helm stored for a registry.

  • helm install api oci://ghcr.io/acme/charts/api --version 1.4.0

    Install a chart straight from a registry.

  • helm show values oci://ghcr.io/acme/charts/api --version 1.4.0

    Read the default values of a chart in a registry.

  • helm pull oci://ghcr.io/acme/charts/api --version 1.4.0

    Download a chart from a registry as a .tgz.

  • helm push api-1.4.0.tgz oci://ghcr.io/acme/charts

    Push 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-namespace

    Install a chart as the release api, making the namespace if it does not exist.

  • helm install bitnami/nginx --generate-name

    Install with a name Helm makes up, such as nginx-1712345678.

  • helm install api ./api

    Install a chart from a folder on disk, or from a packaged .tgz.

  • helm upgrade --install api bitnami/nginx -n web -f values-prod.yaml

    Install the release if it is not there, upgrade it if it is: the one command for CI.

    Tip: -i is short for --install.

  • helm upgrade api bitnami/nginx --version 18.2.0 --reuse-values

    Move a release to another chart version and keep the values it already has.

  • helm upgrade --install api ./api --wait --timeout 10m

    Wait 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-failure

    Roll 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 --wait on.

  • helm upgrade api ./api --cleanup-on-fail

    Delete the resources an upgrade created when it fails, so the next try does not meet them.

  • helm upgrade --install api ./api --dry-run=server

    Render the chart and have the API server validate the result, changing nothing.

    Warning: The output includes Secrets in the clear; --hide-secret leaves them out.

  • helm upgrade api ./api --force-replace

    Delete 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-ownership

    Adopt resources that already exist in the cluster instead of failing on them.

  • helm upgrade --install api ./api --history-max 5

    Keep five revisions of the release, so its history Secrets do not pile up; the default is 10.

  • helm upgrade api ./api --server-side=false

    Apply 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.yaml

    Save 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.yaml

    Pass values files; when two set the same key, the later file wins.

  • helm install api ./api --set replicaCount=3,image.tag=1.5

    Set values on the command line, dots for nesting and commas between pairs.

    Tip: --set wins over every -f file, 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=true

    Force a value to a string, here an annotation that --set would 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.sh

    Set a value to the contents of a file.

  • helm get values api -n web

    Print the values you supplied to the release, not the chart's defaults.

  • helm get values api --all

    Print every value the release used: the chart's defaults merged with yours.

  • helm get values api --revision 3

    Print 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 web

    List the releases in a namespace, with their revision, status, chart and app version.

  • helm list -A

    List the releases in every namespace.

  • helm list -A --failed --pending

    List the releases that failed, or are stuck in the middle of an operation.

  • helm list -n web -q

    Print release names only, one a line, for a script.

  • helm status api -n web

    Show a release's state, its last deployment and its notes.

  • helm history api -n web

    List a release's revisions, each with its status, chart version and description.

  • helm get manifest api -n web

    Print the Kubernetes YAML the release applied, as Helm rendered it.

  • helm get notes api -n web

    Print the chart's NOTES, the instructions shown after an install.

  • helm get hooks api -n web

    Print the release's hooks: the Jobs and other resources it runs before or after a change.

  • helm get all api -n web

    Print a release's values, manifest, hooks and notes at once.

  • helm get metadata api -n web

    Print the release's chart, versions, namespace and status, -o json for a script.

Roll back and uninstall

Go back to an earlier revision, or take a release off the cluster.

  • helm rollback api -n web

    Roll the release back to the revision before the current one.

  • helm rollback api 4 -n web --wait

    Roll back to revision 4 and wait for its resources to be ready.

    Tip: A rollback is itself a new revision: after it, history shows revision 4's chart under a higher number.

  • helm uninstall api -n web

    Delete the release's resources and its history.

  • helm uninstall api -n web --keep-history

    Delete the resources but keep the history, so the release can be rolled back into existence.

    Tip: helm list --uninstalled lists releases removed this way.

  • helm uninstall api -n web --dry-run

    Show what would be uninstalled, removing nothing.

  • helm uninstall api -n web --ignore-not-found

    Treat a release that is not there as uninstalled, for a cleanup script that may run twice.

  • helm uninstall leaves the CRDs of a chart's crds/ 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.yaml

    Render the chart's manifests to standard output, without a cluster.

  • helm template api ./api -s templates/deployment.yaml

    Render one template only.

    Tip: --show-only is 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/v1

    Render 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 --strict

    Check a chart's structure and templates with your values, failing on warnings too.

  • helm install api ./api --debug --dry-run=client

    Print the computed values and the rendered manifests, with Helm's own log lines.

  • helm diff upgrade api ./api -n web -f values-prod.yaml

    Show what an upgrade would change in the cluster, as a diff, from the helm-diff plugin.

    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 api

    Make a chart folder with a Deployment, a Service, an Ingress and a values file to start from.

  • helm dependency update ./api

    Download the dependencies Chart.yaml lists into charts/ and write Chart.lock.

  • helm dependency build ./api

    Download the exact versions in Chart.lock, as CI should.

  • helm dependency list ./api

    List a chart's dependencies and whether each one is in charts/.

  • helm package ./api

    Pack 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.0

    Package with a chart version and an app version that override Chart.yaml's, for CI.

  • helm repo index ./dist --url https://charts.example.com

    Write the index.yaml of a static chart repository from the archives in a folder.

  • helm plugin list

    List 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.enabled

    A 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: api

    Defaults 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 create writes, the image tag falling back to appVersion.

Pitfalls

What goes wrong with Helm, and how to get out of it.

  • After helm upgrade with 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 -f on every upgrade, or add --reset-then-reuse-values to keep the last release's.

  • --reuse-values kept the old values, but a key the new chart version added is missing and a template fails on it.

    Fix: --reuse-values takes 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, then helm rollback to the last deployed revision from helm history.

  • Error: release: not found, though helm list showed it yesterday.

    Fix: A release belongs to a namespace. Pass the -n it was installed with, or find it with helm 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 with kubectl apply --server-side -f, before the upgrade.

  • The install fails with cannot unmarshal bool into Go struct field ... of type string on an annotation or an env value.

    Fix: --set makes true, false and whole numbers into booleans and numbers. Pass the value with --set-string, or quote it in a values file.

  • --set split 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-literal for a string, --set-json for 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-ownership to adopt it.

  • helm upgrade --wait timed out, and the release is failed.

    Fix: The new pods never got ready: read kubectl get pods and kubectl describe for why. Fix it and upgrade again, or helm rollback; --rollback-on-failure does 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 }}.

Every cheat sheet