Lesson 12 intermediate

Helm for Kubernetes

What Helm is, charts vs releases vs repositories, the install, upgrade and rollback workflow, what happens during an upgrade, where Helm is weak and when to use Kustomize instead.

Helm is the package manager for Kubernetes. It bundles a set of manifests into a versioned, configurable chart, installs it as a named release and keeps a history of every change so you can upgrade and roll back. You will use it for two things: installing other people’s software and, optionally, packaging your own.

Three words to know

TermMeaning
ChartA package: templates, default values and metadata
ReleaseOne installed copy of a chart, with a name and a revision history
RepositoryA place where charts are published and downloaded from

One chart can be installed many times in the same cluster, each time as a different release with its own values and history.

Why use Helm?

For third-party software, Helm is the obvious choice. Prometheus, Grafana, cert-manager, Argo CD and most other cluster tools ship as charts. One command replaces hundreds of lines of YAML:

$ helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
$ helm repo update
$ helm install monitoring prometheus-community/kube-prometheus-stack \
    --namespace monitoring --create-namespace

For your own apps, it is a trade-off. One chart can serve every environment through different values files. In exchange you write Go templates, and they become hard to read as conditionals and helpers pile up.

Helm 3 removed the old pain

Helm 2 needed an in-cluster component called Tiller with broad permissions, and it was a well-known security problem. Helm 3 removed it entirely. Helm now runs only on your machine and uses your kubeconfig, so it can do exactly what you can do and no more.

Each release’s state is stored as Secrets in the release’s namespace. That is why helm list only shows the current namespace and helm list -A shows all of them.

The everyday workflow

Here is the full cycle with the small podinfo demo chart:

$ helm repo add podinfo https://stefanprodan.github.io/podinfo
$ helm search repo podinfo
NAME             CHART VERSION   APP VERSION   DESCRIPTION
podinfo/podinfo  6.9.2           6.9.2         Podinfo Helm chart for Kubernetes
$ helm show values podinfo/podinfo > values.yaml

Edit values.yaml to change only what you need:

replicaCount: 2
resources:
  requests:
    cpu: 50m
    memory: 64Mi
  limits:
    memory: 128Mi

Install, inspect, change, undo and remove:

$ helm install demo podinfo/podinfo -f values.yaml
NAME: demo
STATUS: deployed
REVISION: 1
$ helm list
NAME   NAMESPACE   REVISION   STATUS     CHART           APP VERSION
demo   default     1          deployed   podinfo-6.9.2   6.9.2
$ helm upgrade demo podinfo/podinfo -f values.yaml --set replicaCount=3 --atomic --timeout 5m
$ helm history demo
REVISION   STATUS       CHART           DESCRIPTION
1          superseded   podinfo-6.9.2   Install complete
2          deployed     podinfo-6.9.2   Upgrade complete
$ helm rollback demo 1
Rollback was a success! Happy Helming!
$ helm uninstall demo
release "demo" uninstalled

Two habits worth building:

  • Read the default values before installing with helm show values. Chart defaults are made to start easily, not for production. Look for resources, replica counts and persistence.
  • Make upgrades atomic with --atomic and a --timeout. If the upgrade fails, Helm rolls back automatically instead of leaving a half-upgraded release. Helm 4 renamed the flag to --rollback-on-failure and still accepts --atomic as a deprecated alias.

What happens during an upgrade

Helm does a three-way merge between the manifest of the previous release, the new manifest and the live objects. Two practical consequences:

  • Changes made by hand with kubectl edit may survive an upgrade or may be overwritten, depending on the field. Decide whether Helm or humans own an object, not both.
  • If a resource disappears from the chart, Helm deletes it on upgrade, because it tracks what it created.

Preview an upgrade before you run it. The helm-diff plugin is the single most useful Helm add-on:

$ helm plugin install https://github.com/databus23/helm-diff
$ helm diff upgrade demo podinfo/podinfo -f values.yaml
default, demo-podinfo, Deployment (apps) has changed:
-   replicas: 2
+   replicas: 3

Where Helm is weak

  • CRDs: CustomResourceDefinitions placed in a chart’s crds/ folder are installed once and then never upgraded or deleted by Helm. Apply new CRD versions yourself before upgrading, following the chart’s release notes.
  • Readability: deeply nested templates and _helpers.tpl files are hard to follow. helm template renders the final YAML so you can see what will really be applied.
  • Rollbacks are partial: helm rollback restores Kubernetes objects only. It does not undo database migrations or bring back data from a deleted volume.

Helm or Kustomize?

HelmKustomize
ApproachTemplates with variablesPatches on plain YAML
ReadabilityGets harder as charts growBase files stay valid YAML
DistributionVersioned packages in repositoriesNo packaging
Release trackingBuilt in, with rollbackNone, relies on Git
Built into kubectlNoYes: kubectl apply -k
EcosystemAlmost every tool ships a chartMostly used for your own manifests

A sensible default: Helm for third-party software, Kustomize for your own manifests. GitOps tools such as Argo CD and Flux support both, even Kustomize patches on top of a rendered chart.

Quick reference

TaskCommand
Add a repositoryhelm repo add <name> <url>
Searchhelm search repo <term>
See the settingshelm show values <chart>
Installhelm install <release> <chart> -f values.yaml
Install or upgradehelm upgrade --install <release> <chart> -f values.yaml --atomic
All releaseshelm list -A
Historyhelm history <release>
Roll backhelm rollback <release> <revision>
Render without installinghelm template <release> <chart> -f values.yaml
Removehelm uninstall <release>

Exercise

Where does Helm 3 keep the history of a release?

  1. In the Tiller component inside the cluster
  2. In Secrets in the release’s namespace
  3. In a local folder on the machine that ran helm install
  4. In the chart repository
Show answer

Answer: B. Each revision is stored as a Secret next to the release. That is why helm list is per namespace, and why a teammate on another machine sees the same history.

Exercise

You want to see the final YAML a chart would produce with your values, without installing anything. Which command do you use?

  1. helm show values
  2. helm status
  3. helm history
  4. helm template
Show answer

Answer: D. helm template renders the chart locally with your values and prints the manifests. It is the quickest way to understand what complex templates really generate.

Key takeaways

  • A chart is the package, a release is an installed copy of it.
  • Helm 3 has no Tiller and acts with your own kubeconfig permissions.
  • Read helm show values before installing anything.
  • Upgrade with --atomic and a timeout; preview with helm diff.
  • Helm never upgrades CRDs from the crds/ folder.
  • helm rollback restores objects, not data or migrations.
  • Helm for third-party software, Kustomize for your own manifests, is a solid default.

FAQ

Do I need Helm?

To install third-party tools, practically yes, since that is how they are distributed. For your own applications it is optional: plain manifests or Kustomize are often easier to read.

What is the difference between a chart and a release?

A chart is the package you download. A release is one installation of it in a cluster, with its own name, values and revision history.

How do I roll back a release?

Find the revision with helm history <release> and run helm rollback <release> <revision>. It only restores Kubernetes objects, so plan database changes separately.

Is Helm safe in production? What happened to Tiller?

Yes. Tiller existed only in Helm 2. Helm 3 and later run entirely client-side with your own permissions. Any guide that mentions helm init or Tiller is describing Helm 2.

↑ ↓ navigate Enter open Esc close