Kubernetes · Chapter 24 of 28
Helm
By the end of this chapter you can read a Helm chart, install it as a release with your own values, upgrade it, look back through its history, roll it back to a revision that worked, see what it will make before it makes it, and turn a fixed part of a template into a value. Build it in your browser: a real editor and terminal, AI that explains, and tests that tell you when it works.
- Part: Packaging and operating
- 4 tasks
- Kubernetes
- In the all labs plan
The first 2 chapters of Kubernetes are free. This one comes with the all labs plan.
Why you need this
Jhatpat opens in Kanpur after Diwali, then Agra and Varanasi next year. Every city needs the same catalog: a Deployment and a Service, with the city's name in CITY and its own number of pods. Lucknow runs 2 catalog pods on a normal day and 4 on a festival evening.
With what you know so far, that means copies. Tushar would keep catalog-lucknow.yaml, catalog-kanpur.yaml and two more, the same 40 lines each with three words changed, and every fix to one has to be made by hand in all four. And kubectl apply has no memory: it does not know which files you applied last week, it cannot tell you what Lucknow ran before the festival change, and "go back to yesterday" means finding yesterday's file in git and hoping nobody changed the cluster by hand since. Ritika asked Ammar one question after the Dhanteras outage: "when a release goes wrong, how fast can we be back on the last one that worked?" With plain manifests, the honest answer is "it depends who is awake".
Helm answers both: one chart (templates with blanks, and the values that fill them), installed once per city as a release that remembers every revision.
What you build: 4 tasks
Each task has tests. You write the code in the lab's editor and press Check.
- Task 1
jhatpat: install the chart for Lucknow
Install the Jhatpat chart once, for the city Lucknow.
1. Read the chart in the folder jhatpat. values.yaml lists the values, and the templates show where city goes.
2. Install the chart folder jhatpat with helm, as a release named lucknow.
3. Set the value city to lucknow on the command line. city has no default, so an install without it is refused.
4. List the releases and the pods.
To pass: the release lucknow is in ch24 and its latest revision is deployed. It made the Deployment lucknow-catalog with CITY=lucknow and the Service lucknow-catalog, and all the Deployment's pods are ready. Helm must make them: a Deployment made with kubectl does not count.
- Task 2
lucknow: upgrade to 4 replicas, then roll back
Change the release with Helm, then undo the change with Helm.
1. Upgrade the release lucknow with replicaCount 4. Keep city as lucknow.
2. List the pods. You should see 4 catalog pods.
3. Read the release's history. Find the revision number from before the upgrade.
4. Roll the release back to that revision.
To pass: the release history has a revision with replicaCount 4, and a later revision that is a rollback. lucknow-catalog is back at 2 replicas, and its CITY is still lucknow. kubectl scale does not count: Helm must make each change.
- Task 3
jhatpat/templates/deployment.yaml: make the image tag a value
The image tag 1.2 is written into the template. Make it a value, so each release can choose it.
1. In jhatpat/values.yaml, add a value named imageTag with the default "1.2" (with the quotes).
2. In jhatpat/templates/deployment.yaml, use .Values.imageTag in the image line, after jhatpat/catalog:
3. Test it with helm template: with no imageTag, and with another imageTag.
4. Upgrade the release lucknow with imageTag 2.0. Keep its other values.
To pass: with no imageTag the chart renders jhatpat/catalog:1.2, and with another imageTag it renders that tag. lucknow-catalog runs jhatpat/catalog:2.0 with 2 replicas, CITY is still lucknow, and both pods are ready.
- Task 4 · interview question
Interview: what Helm adds over kubectl apply
Interview question: what does Helm give Jhatpat that kubectl apply on plain YAML files does not?
1. Ammar will ask: "We already keep YAML in git and run kubectl apply. Why add Helm?"
2. Write your answer in two or three sentences of your own.
3. Save it in answer.txt, below the notes.
To pass: answer.txt says one thing about values and templates, and one thing about releases. Lines that start with # do not count.
What you will learn
- Charts: Chart.yaml, values.yaml and templates, and helm create.
- Values: --set, -f values.yaml, defaults, required, and what an upgrade keeps.
- Releases: helm install, upgrade, list, history, rollback, uninstall, and where Helm keeps them.
- Looking first: helm template, --dry-run and helm lint.
- Where charts come from: repositories, and charts in folders and .tgz files.
More in Packaging and operating
Build "Helm" yourself
Jhatpat delivers groceries in ten minutes from 14 dark stores across Lucknow, and its hand-run servers fall over on festival evenings. You move it onto Kubernetes. A real editor and terminal in your browser, AI that explains, and a Check that says when it works.
The first 2 chapters of Kubernetes are free. This one comes with the all labs plan.