Helm and Kustomize

Kubernetes · lesson 23 of 32 · 4 min read

Stop keeping one copy of every manifest per environment: template it or patch it.

Open this lesson in the learning hub

Key points

  • Both solve the same problem: one definition, several environments, no three near-identical copies drifting apart.
  • Helm renders Go templates against a values.yaml and records every install as a versioned release you can roll back.
  • Kustomize patches plain YAML - a base plus per-environment overlays - and is built into kubectl apply -k.
  • Render before you argue with the cluster: helm template and kubectl kustomize both print the final manifests.
  • Helm is the better fit for third-party software you install. Kustomize is usually lighter for services you own.
  • A configMapGenerator hashes 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.