Module 12 ยท Lesson 12.1
Helm
Every lab so far has had you hand-write and kubectl apply plain YAML.
That's fine for one Deployment and a Service โ it gets unwieldy fast once
a real app is a dozen objects that all need to change together for a
release, or vary slightly between dev/staging/prod. Helm is Kubernetes's
most widely used answer to that problem.
Charts: templates plus values
A chart is a directory with a Chart.yaml (name/version metadata), a
values.yaml (the default settings), and a templates/ folder of YAML
files with Go-template placeholders like {{ .Values.image.tag }}. Helm's
whole job is substitution: take the templates, plug in values, produce
plain Kubernetes YAML.
From chart to cluster
Chart.yaml + templates/
Go-template YAML, with {{ .Values.x }} placeholders
values.yaml
the substitutions โ a missing key just renders empty
helm template
renders plain YAML โ nothing touches the cluster yet
helm install / upgrade
applies the rendered YAML, tracked as a release
Nothing here is magic โ helm template <chart> does exactly that
substitution and prints the result, with zero cluster contact. That command
is your best debugging tool: if something's wrong after a helm install,
render it first and read the YAML Kubernetes actually received, before
you even look at kubectl describe.
Releases: install, upgrade, rollback
helm install <release-name> <chart> renders and applies a chart for the
first time, giving it a release name Helm tracks. helm upgrade re-renders
against new values and applies the diff โ this is the one you'll use far
more often, the same way kubectl apply is your everyday verb and create
is a one-time thing.
Helm keeps a revision history per release, and helm rollback <release> <revision> reverts to an older one โ directly analogous to kubectl rollout undo from Module 3, just operating on a whole bundle of objects
instead of one Deployment's pod template.
What Helm doesn't save you from
Templates are just text substitution โ Helm doesn't know or care whether
.Values.image.tag actually exists in your values.yaml. Reference a key
that isn't there and you don't get an error; you get an empty string
silently spliced into the output. That's a real, common failure mode, and
it's exactly what you'll hit in this lesson's lab.
The infrastructure analogy
A chart is closest to a parameterized CloudFormation/Terraform module โ same idea of "a template plus a set of inputs, versioned and releasable together" โ except Helm's unit of "release" is a live, continuously reconciled set of Kubernetes objects rather than a one-shot provisioning run.
๐งช Lab: lab-24-helm
Preview onlyGoal
Install a Helm chart, hit a realistic templating bug, diagnose it the fast way (render without installing), and fix it.
Tasks
- Create the namespace:
kubectl create namespace lab-24-helm - Render the chart without installing anything, so you can read exactly
what Kubernetes would receive:
helm template lab24 manifests/mychartLook at theimage:line in the rendered Deployment. Something's wrong. - Install it anyway, to see the live symptom:
helm install lab24 manifests/mychart -n lab-24-helm kubectl get pods -n lab-24-helmโ the pod won't beRunning. Find out why:kubectl describe pod <name> -n lab-24-helmand check the Events.- The bug is in
manifests/mychart/values.yamlโimage.tagis missing entirely, sotemplates/deployment.yaml's{{ .Values.image.repository }}:{{ .Values.image.tag }}renders asnginx:(empty tag). Add atag:key with a real nginx tag, e.g."1.27". - Apply the fix:
helm upgrade lab24 manifests/mychart -n lab-24-helm - Confirm:
kubectl get pods -n lab-24-helmshows the podRunning.
Check
Run the check once the pod is Running on a valid image tag.
This lab runs against a real local Kubernetes cluster with an automated grader โ clone the repo and run make start to do it for real.
๐ Quiz
1. What does `helm template <chart>` actually do?
2. A template references `{{ .Values.image.tag }}`, but values.yaml has no `tag` key under `image`. What happens when you render it?scenario
3. You already applied a release once and need to change a value. What's the right command?
4. Helm's `helm rollback <release> <revision>` is most directly analogous to which Module 3 concept?
5. After `helm install`, a pod shows `InvalidImageName`. What's the fastest way to confirm whether it's a chart/values problem before digging into the live pod?scenario
Progress isn't saved in this preview โ run the course locally to track completion and grade labs for real.