Helm: install, upgrade, roll back

Charts, repositories, releases and revisions: install a pinned chart version with your values, upgrade it, roll it back, and inspect what Helm actually applied.

Architecture · 25%40 min2 tasks

After this lesson

  • 01You can add a chart repository, list a chart's versions and read its default values before installing.
  • 02You can install a specific chart version into a named namespace with --set or a values file, then upgrade and roll it back.
  • 03You can find a release in any namespace, read its history and the values it was installed with, and uninstall it cleanly.

The competency reads Use Helm and Kustomize to install cluster components, and Helm is the half that ships most cluster add-ons: ingress controllers, CNI plugins, monitoring stacks, operators. Exam tasks name a repository, a chart, a chart version, a release name, a namespace and one or two values. Every one of those is checked. The helm.sh documentation is allowed in the exam browser, but helm <command> --help is faster and lists every flag with an example.

Charts, releases and revisions

A chart is a versioned package: Chart.yaml holds the chart version and the appVersion of the software inside, values.yaml holds defaults, and templates/ renders those values into manifests. A repository is an HTTP index of charts; OCI registries work too and skip helm repo add. A release is one installation of a chart, identified by its name and its namespace. Each install, upgrade and rollback writes a new revision, stored as a Secret named sh.helm.release.v1.<release>.v<revision> in the release namespace. There is no in-cluster Helm component; the client talks to the API server with your kubeconfig and permissions.

Install the client and look inside a chartbash
# macOS
brew install helm
# Linux: the installer script from the Helm docs
curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-4 | bash
helm version

# Scaffold a chart to see the anatomy
helm create demo
find demo -type f | sort
#   demo/Chart.yaml                name, version (the chart), appVersion (the software)
#   demo/values.yaml               defaults; templates read them as .Values.<key>
#   demo/templates/*.yaml          Go templates: deployment, service, ingress, hpa, serviceaccount, ...
#   demo/templates/_helpers.tpl    named snippets such as the fullname and labels
#   demo/templates/NOTES.txt       printed after install
helm lint demo
helm template demo ./demo --set replicaCount=2 | grep -nE 'kind:|replicas:'

Read a chart before you install it

Repositories, versions and valuesbash
helm repo add podinfo https://stefanprodan.github.io/podinfo
helm repo update                                   # refresh every index (or: helm repo update podinfo)
helm repo list
helm search repo podinfo                           # newest chart version only
helm search repo podinfo/podinfo --versions | head # every chart version with its app version
helm show chart podinfo/podinfo --version 6.14.0
helm show values podinfo/podinfo --version 6.14.0 > /tmp/cka/podinfo-values.yaml   # every key and its default

# Render locally: no release is created and nothing reaches the cluster
helm template web podinfo/podinfo --version 6.14.0 -n arx-demo --set replicaCount=3 > /tmp/cka/web.yaml
grep -nE 'replicas:|image:' /tmp/cka/web.yaml

# Download and unpack a chart to read its templates
helm pull podinfo/podinfo --version 6.14.0 --untar --untardir /tmp/cka/charts

The release lifecycle

Install, inspect, upgrade, roll back, uninstallbash
helm install web podinfo/podinfo --version 6.14.0 \
  -n arx-demo --create-namespace \
  --set replicaCount=2 --set ui.message="hello" \
  --wait --timeout 5m

helm list -n arx-demo                     # NAME, REVISION, STATUS, CHART (<name>-<chart version>), APP VERSION
helm list -A                              # every namespace; plain "helm list" shows the current namespace only
helm status web -n arx-demo
helm get values web -n arx-demo           # only the values you supplied
helm get values web -n arx-demo --all     # merged with the chart defaults
helm get manifest web -n arx-demo | grep -n 'kind:'

# Upgrade. Repeat --version, or Helm moves you to the newest chart in the repo.
helm upgrade web podinfo/podinfo --version 6.14.0 -n arx-demo \
  --reuse-values --set replicaCount=3 --wait --timeout 5m
# Install-or-upgrade in one idempotent command, with values from a file
helm upgrade --install web podinfo/podinfo --version 6.14.0 -n arx-demo -f /tmp/cka/web-values.yaml

helm history web -n arx-demo
helm rollback web 1 -n arx-demo --wait --timeout 5m   # writes a NEW revision with revision 1's content
helm uninstall web -n arx-demo                        # deletes the objects and the release history
FlagWhat it doesTrap
--version 6.14.0Chooses the chart version (Chart.yaml version), not the app versionLeft off an upgrade, Helm installs the newest chart in the repository
--set k=v, -f values.yamlOverride values. Later flags win; --set beats -f; nested keys use dots (ui.message)--set turns 4 and true into a number and a boolean; use --set-string when the chart expects a string
--reuse-valuesStart from the previous revision's values, then apply the new overridesAn upgrade with any --set or -f and without this flag resets every earlier override you do not repeat
-n NS --create-namespaceSets the release namespace and creates it if missingThe release is invisible to helm list without the same -n (or -A)
--wait --timeout 5mBlocks until the release's resources are readyWithout it the command reports success as soon as the objects are accepted, even if no Pod ever starts

In the docs · the tab you get on exam day

Taskar-helm-1
Architecture7%~8 min

context · kubectl config use-context kind-cka

Install a pinned chart, upgrade it, roll it back

Using Helm and the chart repository https://stefanprodan.github.io/podinfo (add it as podinfo): first, install a release named web of chart podinfo/podinfo, chart version 6.14.0, into namespace arx-helm (create the namespace) with replicaCount set to 2. Next, upgrade web so it runs 4 replicas and shows the UI message release two (value ui.message), keeping chart version 6.14.0. Finally, the message was not approved: roll web back to its first revision. The release must end with exactly three revisions and the Deployment must run 2 replicas.
  1. 01

    Set up the scenario

    curl -fsSL https://codewithmuh.com/labs/cka/t/ar-helm-1/setup | bash
  2. 02

    Solve it in your terminal

    Work the way the exam makes you: kubectl, the docs, nothing else. Put any answer files under /tmp/cka/.

  3. 03

    Check your work

    curl -fsSL https://codewithmuh.com/labs/cka/t/ar-helm-1/verify | bash
    Counts toward your readiness score.
  4. 04

    Clean up

    curl -fsSL https://codewithmuh.com/labs/cka/t/ar-helm-1/cleanup | bash
Taskar-helm-2
Architecture5%~6 min

context · kubectl config use-context kind-cka

Audit releases: remove the failed one, save the values of another

One Helm release in the cluster is in the failed state. Write its namespace and name as <namespace>/<name> to /tmp/cka/helm/failed-release.txt, then uninstall it. Next, save the values that were supplied when release catalog in namespace arx-helm-audit was installed (only the user-supplied values, not the chart defaults) to /tmp/cka/helm/catalog-values.yaml. Do not change catalog.
  1. 01

    Set up the scenario

    curl -fsSL https://codewithmuh.com/labs/cka/t/ar-helm-2/setup | bash
  2. 02

    Solve it in your terminal

    Work the way the exam makes you: kubectl, the docs, nothing else. Put any answer files under /tmp/cka/.

  3. 03

    Check your work

    curl -fsSL https://codewithmuh.com/labs/cka/t/ar-helm-2/verify | bash
    Counts toward your readiness score.
  4. 04

    Clean up

    curl -fsSL https://codewithmuh.com/labs/cka/t/ar-helm-2/cleanup | bash

Finished reading?

0 of 2 tasks passed. Readiness counts tasks, so run them before you move on.