Skip to content
LF Cert Trainer

Lesson 133 · Section 11: Helm & Kustomize

Lesson 133: Helm charts and values: what is inside a chart and how to change it

Open a chart and see how it works: Chart.yaml, values.yaml and templates. Find the setting you need, override it with a values file or --set, know which value wins, and preview the rendered YAML with helm template before anything touches the cluster. · 20 min read · 2 min video

Official competency this lesson covers

1/7Charts and values
0:00 / 1:44

Narrated by the local narrator voice. Keys: Space plays and pauses, J and L step, C captions, F full screen.

Why values matter

The previous lesson installed a chart with its defaults. In practice, and in exam tasks, you nearly always change something: the number of replicas, the Service type, an image tag, a resource limit, whether a component is enabled. A chart exposes those choices as values. Your job is to find the right key and set it, without editing the chart's templates.

Inside a chart

Inside a chartpodinfo/the chart folderChart.yamlname, versionvalues.yamldefaultstemplates/manifests + {{ }}charts/dependenciescrds/applied once
Inside a chart. Chart.yaml names and versions the package, values.yaml holds every default, and templates/ holds the manifests with placeholders. charts/ holds dependencies, crds/ holds CRDs that are applied once and never templated.

Parts:

  • podinfo/ (the chart folder)
  • Chart.yaml (name, version)
  • values.yaml (defaults)
  • templates/ (manifests + {{ }})
  • charts/ (dependencies)
  • crds/ (applied once)

Connections:

  • podinfo/ to Chart.yaml
  • podinfo/ to values.yaml
  • podinfo/ to templates/
  • podinfo/ to charts/
  • podinfo/ to crds/

Download a chart and unpack it to look inside:

helm pull podinfo/podinfo --untar        # creates ./podinfo/
tree podinfo
podinfo
├── Chart.yaml
├── README.md
├── values.yaml
└── templates
    ├── _helpers.tpl
    ├── deployment.yaml
    ├── hpa.yaml
    ├── NOTES.txt
    ├── service.yaml
    └── ...
File or folderWhat it holds
Chart.yamlapiVersion: v2, name, version (the chart version), appVersion, dependencies
values.yamlEvery value the templates use, with its default. The chart's documentation, in practice
templates/Manifests with Go template placeholders. Files starting with _ (like _helpers.tpl) hold reusable snippets and render nothing on their own
templates/NOTES.txtThe text printed after install
charts/Charts this one depends on (subcharts), downloaded by helm dependency update
crds/CRDs, applied as they are before the templates, only on first install, never upgraded or deleted

A template, simplified:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ .Release.Name }}-podinfo
  namespace: {{ .Release.Namespace }}
spec:
  replicas: {{ .Values.replicaCount }}
  template:
    spec:
      containers:
        - name: podinfo
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
          {{- with .Values.resources }}
          resources:
            {{- toYaml . | nindent 12 }}
          {{- end }}

.Release holds facts about the install (name, namespace, revision), .Values holds the merged values, .Chart holds Chart.yaml. with, if and range are Go template blocks, and toYaml | nindent copies a whole YAML block from values into the manifest. You do not need to write templates for the CKA, but reading one tells you exactly which value controls which field.

Finding the setting you need

helm show values podinfo/podinfo > defaults.yaml     # every value and its default
helm show readme podinfo/podinfo | less               # the chart's own documentation
helm show chart podinfo/podinfo                       # Chart.yaml: versions, dependencies

Search defaults.yaml for the field you want to change (grep -n -i replica defaults.yaml) and note its full path. Indentation is the path: type under service: is service.type.

Overriding values

With a values file

Write only what you change:

# my.yaml
replicaCount: 3
service:
  type: NodePort
resources:
  limits:
    memory: 256Mi
helm install web podinfo/podinfo -n shop -f my.yaml

A values file is merged into the defaults key by key: service.type changes, while service.httpPort and the other keys under service keep their defaults. Lists are the exception: a list in your file replaces the whole default list.

With --set

helm install web podinfo/podinfo -n shop \
  --set replicaCount=3 \
  --set service.type=NodePort \
  --set-string podAnnotations.version=2
You wantWrite
A nested key--set service.type=NodePort
Several at once--set replicaCount=3,service.type=NodePort
A list item--set tolerations[0].key=gpu
A whole list--set 'args={--kubelet-insecure-tls,--v=2}'
A key that contains dots--set 'podAnnotations.prometheus\.io/scrape=true'
A value that must stay a string--set-string image.tag=1.10 (otherwise 1.10 becomes the number 1.1)
The content of a file--set-file config=./app.conf

Which value wins

Which value winsoverriddenoverriddenoverriddenvalues.yamlchart defaults-f base.yamlfirst file-f prod.yamllater file--setcommand lineFinal valuesused to render
Which value wins. Values are merged from left to right. A later source overrides an earlier one, key by key; keys it does not mention keep their earlier value.

Parts:

  • values.yaml (chart defaults)
  • -f base.yaml (first file)
  • -f prod.yaml (later file)
  • --set (command line)
  • Final values (used to render)

Connections:

  • values.yaml to -f base.yaml: overridden
  • -f base.yaml to -f prod.yaml: overridden
  • -f prod.yaml to --set: overridden
  • --set to Final values

Values merge from left to right: the chart's values.yaml, then each -f file in the order given, then every --set flag. The rightmost source wins for each key it sets.

helm install web podinfo/podinfo -f base.yaml -f prod.yaml --set replicaCount=5

If base.yaml says 2 replicas and prod.yaml says 4, the release gets 5.

Previewing the result

Look before you installYoua chart + valueshelm templatelocal, no clusterinstall --dry-run=server: validateshelm get valuesexisting releaseYAML on screennothing applied
Look before you install. Three ways to see the result without changing anything. helm template renders locally; --dry-run also asks the API server; helm get shows what an existing release used.

Parts:

  • You (a chart + values)
  • helm template (local, no cluster)
  • install --dry-run (=server: validates)
  • helm get values (existing release)
  • YAML on screen (nothing applied)

Connections:

  • You to helm template
  • You to install --dry-run
  • You to helm get values
  • helm template to YAML on screen
  • install --dry-run to YAML on screen
  • helm get values to YAML on screen
helm template web podinfo/podinfo -n shop -f my.yaml > rendered.yaml
grep -n -A2 'kind: Service' rendered.yaml

helm template renders locally and prints the manifests: no cluster needed, nothing installed, no release record. It is the fastest way to check that your value landed in the right field.

helm install web podinfo/podinfo -n shop -f my.yaml --dry-run=server

--dry-run=server goes one step further: it renders and also asks the API server to validate the objects (so a wrong field or a missing CRD shows up), still without creating anything. --dry-run=client stays on your machine, like helm template.

For a release that already exists:

helm get values web -n shop          # only the values you supplied
helm get values web -n shop -a       # every value, defaults included
helm get manifest web -n shop        # the YAML that was applied

Example · Install metrics-server with one changed argument

A common real use: metrics-server on a lab cluster whose kubelets use self-signed certificates.

helm repo add metrics-server https://kubernetes-sigs.github.io/metrics-server/
helm repo update
helm show values metrics-server/metrics-server | grep -A1 '^args'
args: []
helm upgrade --install metrics-server metrics-server/metrics-server -n kube-system \
  --set 'args={--kubelet-insecure-tls}'
kubectl -n kube-system rollout status deploy/metrics-server
kubectl top nodes

args is a list, so the curly-brace form sets it. upgrade --install installs when the release does not exist and upgrades when it does, which makes the command safe to repeat. The next lesson covers upgrades in detail.

Under the hood · Changing the chart itself

Sometimes no value controls the field you need. Then you have three choices, in order of preference:

  1. Ask Kustomize to patch the output (lessons 203 to 205): helm template ... > all.yaml, then a kustomization that patches all.yaml. You lose Helm's release tracking unless you use a post-renderer.
  2. Copy the chart and edit it: helm pull --untar, change a template, helm install web ./podinfo. You now own a fork that you must update yourself.
  3. Create your own chart: helm create mychart writes a working skeleton with a Deployment, Service, Ingress and HPA, all driven by values.

helm lint ./podinfo checks a chart folder for errors after you edit it.

Tricks

Common mistakes

  • A wrong key path such as --set replicas=3 when the chart reads replicaCount. Nothing fails; nothing changes. Check helm show values and the rendered output.
  • Expecting a list to merge. A list in your values replaces the default list entirely.
  • Putting -f before the file name in the wrong place, as in helm install -f web chart my.yaml. The flag takes the file right after it.
  • Editing values.yaml inside the downloaded chart and installing from the repository: your edit is not used. Install from the local folder, or better, pass a separate file.
  • Forgetting -n with helm template: {{ .Release.Namespace }} renders as default.

Recap

  • A chart is Chart.yaml + values.yaml + templates/ (+ charts/, crds/). Templates read .Values, .Release and .Chart.
  • Find keys with helm show values; override with -f file.yaml (merged key by key, lists replaced) or --set (dots for nesting, {a,b} for lists, --set-string for strings).
  • Order: chart defaults, then -f files in order, then --set; the last one wins.
  • Preview with helm template (local) or --dry-run=server; inspect a release with helm get values [-a] and helm get manifest.

Official docs

Quiz: check what you learned

5 questions on this lesson · about 3 min · instant feedback. Missed questions come back in your review queue.

Sign in to take the quiz and keep your score.

Practise: try it on a real cluster

2 hands-on labs for this lesson. You get goals, not steps: any solution that reaches them passes.

  • Add a Helm repository, install metrics-server from its chart with the values the cluster needs, and look up chart versions.

    Build · Level 2 · standard · target 20 min

  • Roll a Helm release back to the revision that worked, then upgrade it again without losing its values.

    Fix · Level 2 · standard · target 20 min

Discussion

Learners ask and answer questions here. Sign in to read and join the discussion.