Kubernetes Tutorial · Operating Kubernetes · Lesson 25 of 26

Packaging with Helm and Kustomize

Template and customise manifests per environment: Helm charts and Kustomize overlays.

Create a free account to save this page, take notes and track your progress. Sign in

Kustomize

Built into kubectl (kubectl apply -k dir/). A base holds plain manifests; overlays patch them per environment (replicas, images, labels) without templates.

Helm

A chart is a package of templated manifests plus values.yaml. helm install renders templates with your values and tracks a release you can upgrade and roll back. Charts are how most third-party software (ingress controllers, databases, monitoring) is distributed.

Both render plain YAML in the end: kubectl kustomize dir/ and helm template show exactly what will be applied, which is worth reviewing in CI.

A base and a production overlay
mkdir -p base overlays/prod
cat > base/deployment.yaml <<'EOF'
apiVersion: apps/v1
kind: Deployment
metadata: {name: api}
spec:
  replicas: 1
  selector: {matchLabels: {app: api}}
  template:
    metadata: {labels: {app: api}}
    spec:
      containers: [{name: api, image: example/api:1.0.0}]
EOF
printf 'resources:\n  - deployment.yaml\n' > base/kustomization.yaml
cat > overlays/prod/kustomization.yaml <<'EOF'
resources: [../../base]
namespace: prod
images:
  - name: example/api
    newTag: 1.4.2
patches:
  - target: {kind: Deployment, name: api}
    patch: |
      - op: replace
        path: /spec/replicas
        value: 3
EOF
kubectl kustomize overlays/prod | grep -E 'namespace:|replicas:|image:'

Output

  namespace: prod
  replicas: 3
      - image: example/api:1.4.2

Run this on your computer — see “Get Started” for setup.

Test yourself

How can you see exactly what a Helm chart or Kustomize overlay will apply?

  1. You can't
  2. Render it: helm template or kubectl kustomize
  3. Apply it to production and check
  4. Read values.yaml only
Show answer

Answer: Render it: helm template or kubectl kustomize

Both tools produce plain manifests you can review and diff.

Was this page helpful?