Helm and Kustomize
Stop keeping one copy of every manifest per environment: template it or patch it.
Open this lesson in the learning hubKey points
- Both solve the same problem: one definition, several environments, no three near-identical copies drifting apart.
- Helm renders Go templates against a
values.yamland records every install as a versioned release you can roll back. - Kustomize patches plain YAML - a
baseplus per-environment overlays - and is built intokubectl apply -k. - Render before you argue with the cluster:
helm templateandkubectl kustomizeboth print the final manifests. - Helm is the better fit for third-party software you install. Kustomize is usually lighter for services you own.
- A
configMapGeneratorhashes the ConfigMap name, so editing config actually rolls the pods instead of doing nothing.
Example
# --- Kustomize: base/kustomization.yaml
resources:
- deployment.yaml
- service.yaml
# --- overlays/prod/kustomization.yaml
resources:
- ../../base
replicas:
- name: orders
count: 6
images:
- name: ghcr.io/acme/orders
newTag: 1.4.2
configMapGenerator:
- name: orders-config # name gets a content hash appended
literals:
- SPRING_PROFILES_ACTIVE=prod
# kubectl kustomize overlays/prod # see it first
# kubectl apply -k overlays/prod
# --- Helm equivalent
# helm template web ./chart -f values-prod.yaml
# helm upgrade --install web ./chart -f values-prod.yaml
# helm rollback web 3
Template it or patch it, but never keep three hand-edited copies of one manifest.
This is a reading copy. The full lesson — with the visual explainer, the interactive lab and a Run button for the code — lives in the Kubernetes course, and every lesson in it is listed on the Kubernetes contents page.