Course contents · Lesson 21 of 22

Helm Basics: Package Kubernetes Apps, Hands-On

Hands-On with kind · Lesson 21 of 22 · 12 min Hands-on

Your last few labs applied the same deployment.yaml and service.yaml again and again. A real team needs them per environment: one replica in development, three in staging, another image tag in production. Copy the files for each and the copies drift apart. This lesson covers Helm basics: package an app once, tune a few settings per environment, and install, upgrade and roll it back as one unit on your kind cluster from lesson 17.

Why Helm: the same YAML, many times over

An app on Kubernetes is rarely one file. Lesson 18's app needs a Deployment and a Service; real ones add Ingresses, ConfigMaps and Secrets from lessons 12 and 13. Each environment wants the same files with a few lines changed, and kubectl sees separate objects, not one app to install, upgrade or remove.

Helm is a package manager for Kubernetes, as Homebrew or apt are for your laptop. You write the YAML once, with blanks where settings change, and Helm fills them in. Four words matter:

  • Chart: the package, a folder of templates (Kubernetes YAML with blanks) and default settings.
  • Values: the settings that fill the blanks, such as the replica count. You override the defaults you need.
  • Release: one installed copy of a chart, under a name you choose, such as web. Install a chart twice under two names and you get two releases.
  • Repository: where charts are published, either a web server with an index file or an OCI registry like those that store images.

In the flowchart, notice that Helm finishes its work before anything reaches the cluster: it renders plain YAML, like the files you wrote by hand, and only then sends it to the API server from lesson 8.

Flowchart. Chart templates, YAML with blanks in templates/*.yaml, and values go into the Helm template engine. The values come from values.yaml with the defaults, then a file passed with -f such as staging-values.yaml, then --set replicaCount=2; lower ones win, and with several -f files the last wins. The engine fills every blank and produces plain Kubernetes YAML, such as replicas: 2. Preview branch: helm template prints the YAML and stops, so nothing reaches the cluster. Apply branch: helm install or upgrade, where the API server creates the objects and Helm saves the history as a Secret. Footer: same templates, different values, different YAML, no copies
Helm only fills in blanks: the cluster receives ordinary YAML.

Inside a chart: Chart.yaml, values.yaml and templates

The lab folder course-labs/containers-and-kubernetes-fundamentals/05-helm holds webchart, a chart of lesson 18's nginx app. Inside, Chart.yaml describes the package, values.yaml holds the default values and templates/ holds the YAML with blanks. The first two, trimmed:

# webchart/Chart.yaml
apiVersion: v2
name: webchart
version: 0.1.0
appVersion: "1.27"

# webchart/values.yaml
replicaCount: 1
image:
  tag: "1.27-alpine"
service:
  port: 80

apiVersion: v2 is the chart format for Helm 3 and later. name and version, the chart's own version, are required; appVersion is the app's version, for information only. Indentation nests keys, so tag belongs to image. Now the Deployment template, trimmed:

metadata:
  name: {{ .Release.Name }}
spec:
  replicas: {{ .Values.replicaCount }}
  ...
          image: "nginx:{{ .Values.image.tag }}"

Double braces hold a directive, an instruction Helm replaces with text, written in the Go template language. .Values.replicaCount reads replicaCount from the values, and each dot goes one level deeper, so .Values.image.tag is tag under image. .Release.Name is the name from your command, used for both objects, so the release web creates a Deployment and a Service named web.

In the diagram, follow each value to the line that reads it: change a value once, and every such line changes.

Folder tree of the chart webchart: Chart.yaml with the name and version, values.yaml with replicaCount: 1, image tag 1.27-alpine and service port 80, and a templates folder with deployment.yaml and service.yaml. On the right, trimmed template lines. Arrows link replicaCount to the replicas line in deployment.yaml, which reads .Values.replicaCount; the tag to the image line, nginx followed by .Values.image.tag; and the port to the port line in service.yaml, which reads .Values.service.port. A command chip, helm install web ./webchart, points to the name line of both templates: the release name web fills .Release.Name. Footer: change a value once and every line that uses it follows
Values live in one file; templates only point at them.

Preview the YAML with helm template

Before installing, ask Helm to render the chart. helm template takes a release name and the chart's folder, runs entirely on your laptop and sends nothing to the cluster. Run it from the 05-helm folder; --set overrides one value for this run:

helm template web ./webchart --set replicaCount=2

You should see two YAML documents, each after a --- line and a # Source: comment naming its template. Helm sorts objects by kind, so the Service comes first. Trimmed:

---
# Source: webchart/templates/service.yaml
apiVersion: v1
kind: Service
metadata:
  name: web
...
---
# Source: webchart/templates/deployment.yaml
...
  replicas: 2
...
          image: "nginx:1.27-alpine"

Every blank is filled. An error ending in path "./webchart" not found means you are in the wrong folder. It is the quickest way to check a template change, but the cluster's own checks, such as whether a name is taken, only happen at install.

Install and upgrade a release

helm install renders the chart the same way, sends the YAML to the cluster and records it as revision 1 of the release. The release name comes first, then the chart:

helm install web ./webchart --set replicaCount=2

You should see this, with your own date (Helm 3 leaves out the DESCRIPTION line):

NAME: web
LAST DEPLOYED: Sat Nov 28 10:15:03 2026
NAMESPACE: default
STATUS: deployed
REVISION: 1
DESCRIPTION: Install complete
TEST SUITE: None

deployed means the cluster accepted every object, and helm list now shows web at revision 1. Helm does not wait for the pods unless you add --wait. An error ending in exists and cannot be imported into the current release means lab 02's or 03's web objects are still there: Helm will not take over objects it did not create, so delete them first.

To change a release, run helm upgrade with the same name, the chart and the new values. Helm renders again and updates the objects:

helm upgrade web ./webchart --set replicaCount=3

You should see Release "web" has been upgraded. Happy Helming!, the same block with REVISION: 2, and a third pod. Only replicas changed, so the Deployment just scales, which lesson 19 showed is not a new Deployment revision. Helm counts its own revisions: every install, upgrade and rollback gets the next number.

Settings can also live in a file passed with -f. The lab's staging-values.yaml sets replicaCount: 3, so helm upgrade web ./webchart -f staging-values.yaml does the same upgrade. The chart's values.yaml is the base, -f files override it (the last file wins), and --set overrides them all.

One trap: when you pass any values to helm upgrade, Helm starts again from the chart's defaults plus what you pass now. A value you set last time and do not repeat returns to its default, unless you add --reuse-values. A values file per environment avoids this.

Roll back, uninstall, and Helm vs Kustomize

Helm saves each revision, with its rendered YAML and values, as a Secret in the release's namespace, named like sh.helm.release.v1.web.v1. helm history lists them, and helm rollback returns to one:

helm rollback web 1
helm history web

The rollback prints Rollback was a success! Happy Helming! and the pods go back to two. The history, with your own times:

REVISION  UPDATED                   STATUS      CHART           APP VERSION  DESCRIPTION
1         Sat Nov 28 10:15:03 2026  superseded  webchart-0.1.0  1.27         Install complete
2         Sat Nov 28 10:17:41 2026  superseded  webchart-0.1.0  1.27         Upgrade complete
3         Sat Nov 28 10:19:12 2026  deployed    webchart-0.1.0  1.27         Rollback to 1

Notice revision 3. As with kubectl rollout undo, the counter never rewinds: Helm copies revision 1's chart and values into a new revision, and older ones become superseded, replaced by a newer one. Without a number, Helm goes back to the previous revision.

Timeline of the release web in three cards. Revision 1: helm install web ./webchart --set replicaCount=2, two pods, replicas: 2, description Install complete, status now superseded. Revision 2: helm upgrade web ./webchart --set replicaCount=3, three pods, replicas: 3, description Upgrade complete, status now superseded. Revision 3: helm rollback web 1, back to revision 1, two pods, replicas: 2, description Rollback to 1, status now deployed. A dashed arrow from revision 3 back to revision 1 says it copies revision 1's chart and values. Footer: the history is kept as Secrets, sh.helm.release.v1.web.v1 to v3
A rollback adds a revision; it never erases one.

helm uninstall web deletes everything the release created, plus its history, and prints release "web" uninstalled.

Helm is not the only way to vary YAML. Kustomize, built into kubectl as kubectl apply -k, uses no templates: you keep plain YAML as a base plus small patches per environment, called overlays. It suits your own apps when a few patches will do; Helm suits apps with many settings, shared packages, and anything you want to upgrade and roll back as a unit.

Check yourself

The chart says replicaCount: 1 and staging-values.yaml says 3. You run helm install web ./webchart -f staging-values.yaml --set replicaCount=5. How many pods do you get?

Five. --set overrides -f files, which override the chart's defaults.

You installed with --set replicaCount=2, then run helm upgrade web ./webchart --set image.tag=1.27. How many pods run afterwards?

One, the chart's default. Because you passed values, the upgrade starts from the chart's defaults plus the new ones, so the earlier replicaCount is dropped.

After revisions 1 and 2, you run helm rollback web 1. Why does the history show revision 3 instead of going back to 1?

A rollback is a new change: Helm copies revision 1's chart and values into a new revision. Keeping every step means you could still return to revision 2.