Kustomize and Helm
Render environment-specific Kubernetes objects and understand how Helm tracks a release.
What you will understand
- Read a Kustomize overlay and identify the changes it makes to its base.
- Explain how a Helm chart and values become Kubernetes objects.
- Review the rendered manifests before submitting them to the API.
Builds on: Metrics, logs, and traces
Make environment changes without copying manifests
You run the same API in a training namespace and in production. The two environments share a Deployment and Service, but production needs more replicas and a different approved image. Copying both YAML files starts out easy. Over time, a change may make it into only one copy. Kustomize lets you keep shared manifests in a base and apply a set of deliberate differences in each environment’s overlay.
Kustomize reads resources and applies transformations such as a namespace change, image substitution, or patch. It produces ordinary Kubernetes manifests. Kubernetes receives those objects after rendering. In the first scene, trace which fields come from the base and which change when you pick the training overlay.
Which fields did the training overlay change?
Kustomize transforms a common base into ordinary manifests. Inspect the rendered object to see exactly what reaches the API.
Start from the shared base
- Base resourcesTraining overlayresources reference
The base holds ordinary Kubernetes objects. Its selector and port relationships remain important after reuse.
Substitute training values
- Training overlayRendered manifestsrender
The overlay changes only intended fields, producing a concrete rendered artifact that can be reviewed.
Validate and diff the rendered YAML
- Rendered manifestsAPI dry-rundry-run + diff
Server dry-run tests API validation and admission without running the application; diff exposes live changes.
Apply and verify the workload
- Rendered manifestsCluster controllersapply
Controllers see the rendered resources. A rollout check and a real request test are still required after apply.
The base already contains a Deployment with a replicas field and a matching Service.
Inspect YAML or commands
Apply focused transformations
kubectl kustomize overlays/trainingValidate and diff the result
kubectl apply --dry-run=server -f rendered.yamlExplore another case
Render and review a Kustomize overlay
This example expects an api Deployment in base and a training overlay under overlays/training. The image transformation changes the nginx tag. The patch replaces the existing spec.replicas field on the api Deployment with three. Render the final result first and inspect the changes. Server-side dry run checks what the API would accept for the current identity and policy. kubectl diff compares the proposed configuration with live resources and exits with code 1 when it finds changes.
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
namespace: learning
images:
- name: nginx
newTag: 1.27-alpine # Training tag; pin an approved digest for releases.
patches:
- target:
kind: Deployment
name: api
patch: |-
- op: replace
path: /spec/replicas
value: 3kubectl kustomize overlays/training > rendered.yaml
kubectl apply --dry-run=server -f rendered.yaml
kubectl diff -k overlays/training
kubectl apply -k overlays/training
kubectl rollout status deployment/api -n learning --timeout=120sInstall a Helm chart and inspect the release
Helm packages templates and default values into a chart. Environment-specific values fill in parts of the templates, such as the replica count or image. An installed chart instance is a release. Helm records release revisions, which you can inspect after an install or upgrade. Try changing a value in the second scene and compare the rendered object with the chart input.
From Helm values to a release revision
A chart renders Kubernetes manifests from templates and values, and Helm records a revision when it installs or upgrades the release.
Combine templates and values
- ChartRendered resourcestemplate structure
- ValuesRendered resourceseffective values
The chart defines the configuration interface; final values select the manifest details. Package version and application image version are different identifiers.
Inspect rendered manifests
- Rendered resourcesHelm release apireviewed artifact
Lint and template make output reviewable, including selectors, privileges and configuration references.
Install or upgrade the release
- Helm release apiCluster workloadinstall / upgrade
Helm tracks a named release while Kubernetes reconciles its objects. Wait settings do not prove every business request works.
Check what rollback can restore
- Helm release apiExternal databaseoutside rollback boundary
A historical manifest revision can be reapplied, but external migrations or messages may be irreversible or incompatible with old code.
Local chart and values are already reviewed; external business state is outside Helm resource rollback.
Inspect YAML or commands
Inspect before install
helm template api ./chart -n learning -f values-training.yamlSeparate resource rollback from data
helm history api -n learningExplore another case
The optional example needs your own local chart and values-training.yaml. helm lint checks the chart, helm template renders it for inspection, and helm upgrade --install creates or updates the release. Look at the rendered manifests as carefully as you would look at handwritten YAML. Examine the effective values and recorded manifest to confirm the release used the configuration you intended.
# Optional extension: supply a local chart and values file first.
# They are not included in the downloadable Kustomize baseline.
helm lint ./chart
helm template api ./chart -n learning -f values-training.yaml > helm-rendered.yaml
helm upgrade --install api ./chart -n learning \
-f values-training.yaml --wait --timeout 5m
helm history api -n learning
helm get values api -n learning --all
helm get manifest api -n learningTrack the inputs that produced the release
The application delivery lab includes a runnable Kustomize baseline. Use a different environment or workload name for Helm practice so the tools do not both manage the same fields on the same objects. Pin the chart and image versions for real releases, and record the base and values used to produce them. A release name by itself cannot tell a teammate what was deployed.
Check your understanding
You change the training overlay to three replicas, but the running Deployment still shows two. What should you verify?
Render the training overlay and check that it targets the correct Deployment and namespace. Then confirm it was applied. Rendering alone makes a local manifest and leaves the running object as it was.
Primary documentation
Go to the source
Reviewed 2026-10-27 · Kubernetes 1.37 · Related local exercise