World map

 

BM: Baca dalam Bahasa Melayu

World K4: Notes, Lockers & Packages

Kustomize bases and overlays

You will learn: to run one app in two kitchens with a base and overlays, using kubectl apply -k.

Checked with Kubernetes 1.37 on 31 Oct 2026

The problem

You are here: cluster kind-dev namespace default
ls shows two folders, base and overlays. overlays holds dev and prod. prod holds kustomization.yaml, namespace.yaml and settings-patch.yaml. Terminal output: $ ls base overlays $ ls overlays dev prod $ ls overlays/prod kustomization.yaml namespace.yaml settings-patch.yaml

Same shop, two kitchens. Dev wants 1 tray and chatty logs. Prod wants 3 trays and quiet logs. Copy all the YAML twice? Then you fix every bug twice.

Watch

This is overlays/prod/kustomization.yaml. Tap the three lines that make prod different.

0 of 3 found

Kustomize: One base recipe plus a sticky note per kitchen. Built into kubectl (kubectl apply -k). keeps one base recipe. Each overlay: The sticky note for one kitchen: it changes the base for dev, staging or prod. is a sticky note on top, for one kitchen. The base never changes.

Try it

Preview prod first. This only prints YAML. Nothing reaches the cluster.

You are here: cluster kind-dev namespace default
Stalls: 3. Trays: 0 (0 ready). Waiting for a stall: 0.
dev-control-planeOpenManager

No trays here.

dev-workerOpen

No trays here.

dev-worker2Open

No trays here.

Time: +0s (sped up)

Predict

You just ran kubectl kustomize overlays/prod. How many prod trays are running now?

Pick one answer.

Try it

Now open the prod kitchen for real.

You are here: cluster kind-dev namespace default
Stalls: 3. Trays: 0 (0 ready). Waiting for a stall: 0.
dev-control-planeOpenManager

No trays here.

dev-workerOpen

No trays here.

dev-worker2Open

No trays here.

Time: +0s (sped up)

Check

You are here: cluster kind-dev namespace default
Both overlays are applied. The dev tray prints debug. A prod tray prints warn. Terminal output: $ kubectl apply -k overlays/dev namespace/dev created configmap/settings created deployment.apps/shop created $ kubectl apply -k overlays/prod namespace/prod created configmap/settings created deployment.apps/shop created $ kubectl rollout status deployment/shop -n prod --timeout=120s Waiting for deployment "shop" rollout to finish: 0 of 3 updated replicas are available... deployment "shop" successfully rolled out $ kubectl exec -n dev deploy/shop -- printenv LOG_LEVEL debug $ kubectl exec -n prod deploy/shop -- printenv LOG_LEVEL warn

One base, two kitchens. Dev says debug, prod says warn. The patch changed one line of the note.

Check

Build the command that opens the dev kitchen.

Tap the pieces in the right order.

…

You did it!

You can now run one app in many kitchens with Kustomize.

Go deeper (optional)

Overlays can do more: images: swaps a tag, namePrefix: renames things, labels: adds labels. configMapGenerator adds a hash to the note’s name, so a change rolls the trays. kubectl diff -k overlays/prod shows changes first.

Real rep (optional), on a practice kind cluster:

Real mission

  1. kubectl kustomize overlays/prod
  2. kubectl apply -k overlays/prod
  3. kubectl diff -k overlays/prod
  4. kubectl delete -k overlays/prod

0 of 5 steps done · Your ticks are saved.