Helm charts in depth
Writing and operating Helm charts: named templates, values schemas, required values, hooks, release history in Secrets, rollbacks, and what Helm 4 changed.
Deployments and ReplicaSetsServer-side apply and field ownership
Helm charts in depth
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- A chart is Go templates plus values. Named templates in _helpers.tpl (define, include, nindent) keep names and labels consistent across every manifest.
- values.schema.json makes Helm reject bad values before rendering, and the required function fails a render with your own message, so mistakes surface at helm template time, not in the cluster.
- Each install or upgrade is a numbered revision stored as a Secret (sh.helm.release.v1.<release>.v<N>) in the release's namespace, holding the rendered manifest and the values used.
- A helm upgrade that passes any value starts from chart defaults, dropping what you passed before. With none at all it reuses the last release's values. Keep values in files under version control and pass them every time.
- A rollback is a new revision that re-applies an old one. Without --wait, Helm reports success as soon as the API server accepts the objects, even if the new image never starts.
- Hooks (pre-install, pre-upgrade and others) run Jobs at points in the release lifecycle. Helm 4 applies resources with server-side apply, so it shows up as a field manager like any other client.
From using charts to writing them
The devops lesson on Helm and Kustomize showed why Helm exists: one templated chart, rendered with different values per environment, installed as a release you can upgrade and roll back. It looked at a chart from the outside. This lesson builds one and drives the release lifecycle against a real API server, which is where most Helm surprises live: values that vanish on upgrade, rollbacks that are really roll-forwards, and “successful” releases whose Pods never start.
The examples use a Helm 4.3 binary built from the helm.sh/helm/v4 v4.3.2 module source (the current release) against a local Kubernetes v1.37.3 API server.
Anatomy of a chart
helm create notes scaffolds:
notes/Chart.yaml
notes/values.yaml
notes/.helmignore
notes/templates/_helpers.tpl
notes/templates/deployment.yaml
notes/templates/service.yaml
notes/templates/serviceaccount.yaml
notes/templates/hpa.yaml
notes/templates/ingress.yaml
notes/templates/httproute.yaml
notes/templates/NOTES.txt
notes/templates/tests/test-connection.yaml
Chart.yaml has two versions: version is the chart’s own SemVer, bumped whenever the chart changes, and appVersion is the software it deploys. dependencies there pulls in subcharts, from a repository or an OCI registry, fetched with helm dependency update.
The current scaffold includes an httproute.yaml for the Gateway API next to the Ingress.
Named templates keep things consistent
Files starting with _ render nothing on their own. _helpers.tpl defines named templates:
{{- define "notes.labels" -}}
helm.sh/chart: {{ include "notes.chart" . }}
{{ include "notes.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
Every manifest then uses {{- include "notes.labels" . | nindent 4 }}. Use include rather than template so the output can be piped. nindent adds a newline and indents, which is how YAML structure survives templating. {{- and -}} trim whitespace. Most rendering bugs are indentation bugs, so render often with helm template.
Fail early: schemas and required
A chart’s values are its API, so validate them. A values.schema.json next to values.yaml:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"required": ["image", "replicaCount"],
"properties": {
"replicaCount": {"type": "integer", "minimum": 1, "maximum": 20},
"image": {
"type": "object",
"required": ["repository"],
"properties": {"repository": {"type": "string", "pattern": "^registry\\.example\\.com/"}}
}
}
}
$ helm template web notes --set image.repository=docker.io/nginx --set replicaCount=50
Error: values don't meet the specifications of the schema(s) in the following chart(s):
notes:
- at '/replicaCount': maximum: got 50, want 20
- at '/image/repository': 'docker.io/nginx' does not match pattern '^registry\\.example\\.com/'
Both violations are reported at once, before any template runs. For conditional requirements, the required function fails with your own message:
args: ["migrate", "--to", {{ required "migrations.target is required" .Values.migrations.target | quote }}]
Error: execution error at (notes/templates/migrate-job.yaml:20:37): migrations.target is required
Hooks
That line belongs to a hook, a resource Helm runs at a lifecycle point instead of treating it as part of the release:
metadata:
name: {{ include "notes.fullname" . }}-migrate-{{ .Release.Revision }}
annotations:
"helm.sh/hook": pre-install,pre-upgrade
"helm.sh/hook-weight": "-5"
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
Before installing or upgrading, Helm creates this Job, waits for it to complete, and only then applies the rest. A failing migration stops the upgrade. Hooks aren’t tracked as release resources, so the delete policy matters, or old Jobs pile up. helm template prints hooks alongside everything else, so tools that render charts and apply the output themselves have to treat them specially.
The release lifecycle, for real
Install, two upgrades, then a rollback, against the lab API server:
$ helm install web notes -n notes
$ helm upgrade web notes -n notes --set image.tag=1.17.0 --set replicaCount=3
$ helm upgrade web notes -n notes --set image.tag=1.18.0-broken
$ helm rollback web 2 -n notes
$ helm history web -n notes
REVISION STATUS CHART DESCRIPTION
1 superseded notes-0.1.0 Install complete
2 superseded notes-0.1.0 Upgrade complete
3 superseded notes-0.1.0 Upgrade complete
4 deployed notes-0.1.0 Rollback to 2
Three lessons are in that history.
Values don’t carry over. helm get values web --revision 3 showed only image.tag: 1.18.0-broken. The replicaCount=3 from revision 2 was gone, so revision 3 ran one replica. As soon as an upgrade passes any value, Helm starts from chart defaults plus what you passed this time. (Pass none at all and it reuses the previous release’s values, which I checked too: a bare helm upgrade kept replicaCount: 3.) Keep per-environment values in files in Git and pass them every time.
Broken releases “succeed”. The 1.18.0-broken upgrade printed Happy Helming!. Helm only knew the API server accepted the objects. Add --wait and a --timeout, and in CI --rollback-on-failure (Helm 4’s name for --atomic), so a release whose Pods never become ready fails and reverts.
Rollback is a new revision. Revision 4 re-applied revision 2’s manifest and values. The Deployment came back to 3 registry.example.com/notes:1.17.0.
Where releases live
NAME TYPE DATA
sh.helm.release.v1.web.v1 helm.sh/release.v1 1
sh.helm.release.v1.web.v2 helm.sh/release.v1 1
sh.helm.release.v1.web.v3 helm.sh/release.v1 1
sh.helm.release.v1.web.v4 helm.sh/release.v1 1
Each revision is a Secret holding a base64, gzipped JSON release. Decoding revision 4 gave the keys name, info, chart, config, manifest, hooks, version, namespace, apply_method. config is the values, so passwords passed as values are readable by anyone who can read Secrets in that namespace. --history-max caps how many are kept (10 by default).
apply_method is new in Helm 4, which applies resources with server-side apply. The Deployment’s managedFields listed helm Apply next to kube-controller-manager Update. Field ownership now resolves conflicts between Helm and other writers, such as an HPA owning replicas, instead of Helm’s old three-way merge.
Practices for chart authors
- Bump
versionon every chart change. Publish to an OCI registry (helm push) and install by digest for immutability. - Ship a schema, sensible defaults, and
helm lintplushelm templatein CI. - Don’t template what users never change. Every value is an interface you must maintain.
- Leave
replicasout of the template when an HPA is enabled, as the scaffold does.
About the video
The embed is DevOps Journey’s “How to Create Helm Charts - The Ultimate Guide”, October 2022, 22 minutes. Its chapters take a plain manifest and turn it into a chart: helm create, installing, templating, NOTES.txt, and templating for prod and dev environments. It is Helm 3 era. Templating hasn’t changed, but it predates Helm 4’s server-side apply and renamed flags. I judged it from chapters and description only, since transcripts couldn’t be fetched. English was judged from its “English (US) original” audio track. The Helm maintainers’ 2026 KubeCon talk in deeper covers what Helm 4 changed and what comes next.
What was run: every Helm command and output above came from a Helm 4.3 binary built from the v4.3.2 module source, run against a local Kubernetes v1.37.3 API server whose nodes run no containers. The hook Job was rendered but not installed, since it would wait forever for a Job that can’t run. --wait and --rollback-on-failure are from the Helm docs, checked 2026-11-29.
Where this fits
Helm templates. The other approach patches plain YAML: Kustomize in depth.
Check yourself
You ran helm upgrade web ./chart --set replicaCount=3, then later helm upgrade web ./chart --set image.tag=1.18.0. How many replicas run now, and why?
The chart default (1). Because the second upgrade passed a value, Helm computes values from the chart defaults plus what you passed this time. The earlier --set isn't carried over unless you pass it again, use a values file, or use --reuse-values.
Where does Helm keep release history, and what does that imply for access control?
In Secrets of type helm.sh/release.v1 in the release's namespace, one per revision, holding the gzipped release with its values. Anyone who can read Secrets there can read every value ever passed, including passwords supplied as values.
helm upgrade printed 'Happy Helming!' but the new Pods are in ImagePullBackOff. Why didn't Helm notice?
Helm 4's default wait strategy, hookOnly, only waits for hooks. Otherwise it only waits for the API server to accept the objects. Use --wait with a timeout, plus --rollback-on-failure (formerly --atomic) in CI, so a release that never becomes ready fails and reverts.
What's the advantage of values.schema.json over checking values inside templates with fail or required?
The schema validates every value's type and constraints in one pass and reports all violations at once, before any template runs. It also documents the chart's interface for tools and editors.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.