Home › CKAD practice tasks › Build a staging overlay with Kustomize
CKAD · Application Deployment

Create a Staging Overlay with Kustomize

The catalog team keeps a reusable base for their application in `/root/catalog/base`: a Deployment and a Service, both named `catalog`. Namespace `catalog-staging` exists. The staging environment needs its own overlay in `/root/catalog/overlays/staging`; the base is shared with other environments and must not change.

Live lab access

This task description is public. Live practice requires full access unless this is the selected free weekly task. AI Lab Coach is available in single-task labs, including the free weekly task. See this week's free task.

Create an account to continue →

Read this week's free task →

On a phone? Read the task and create your account here, then sign in on a desktop or laptop for the terminal lab. Nothing starts until you choose Start.

The task

The catalog team keeps a reusable base for their application in /root/catalog/base: a Deployment and a Service, both named catalog. Namespace catalog-staging exists. The staging environment needs its own overlay in /root/catalog/overlays/staging; the base is shared with other environments and must not change.

Requirements
1. Create /root/catalog/overlays/staging/kustomization.yaml that uses ../../base, places every resource in namespace catalog-staging and adds the label env: staging to every resource.
2. Change the image of container api to nginx:1.27.5 through the overlay.
3. Add the environment variable LOG_LEVEL=debug to container api using a patch file in the overlay directory.
4. Apply the overlay and ensure the catalog Deployment in catalog-staging is available.

Do not modify the files in /root/catalog/base.

Original Prepium guide · Written for Kubernetes v1.35 and checked against the official documentation on 6 October 2026. Use a disposable practice cluster. Kustomize is built into kubectl, so no extra install is needed.

Kustomize overlays: change an environment without touching the base

A base is a directory with a kustomization.yaml listing shared manifests. An overlay is another directory whose kustomization.yaml pulls the base in as a resource and layers changes on top. The base never learns about its overlays, so dev, QA and prod can share one copy of the manifests. The exam habit that matters most: render with kubectl kustomize and read the output before you apply anything.

prepium-kz/
  base/          kustomization.yaml, deployment.yaml     (shared, unchanged)
  overlays/qa/   kustomization.yaml, cpu-request.yaml    (QA differences only)

1. A base with a generated ConfigMap

base/deployment.yaml is an ordinary Deployment named notes (one replica, container web, image nginx:1.27-alpine) whose container loads envFrom a ConfigMap called notes-settings. The base kustomization generates that ConfigMap:

# base/kustomization.yaml
resources:
- deployment.yaml
configMapGenerator:
- name: notes-settings
  literals:
  - GREETING=hello

Run kubectl kustomize base. The ConfigMap comes out as notes-settings- plus a hash of its contents, and the Deployment's configMapRef has been rewritten to that exact name. Change the literal and the hash changes, so the Pod template changes and a new rollout starts: config edits can no longer go unnoticed by running Pods.

2. An overlay that changes only what differs

# overlays/qa/kustomization.yaml
resources:
- ../../base
namespace: prepium-tutorial
namePrefix: qa-
labels:
- pairs:
    tier: qa
replicas:
- name: notes
  count: 2
configMapGenerator:
- name: notes-settings
  behavior: merge
  literals:
  - GREETING=hola
patches:
- path: cpu-request.yaml

cpu-request.yaml is a partial Deployment: apiVersion, kind, metadata.name: notes, then just spec.template.spec.containers with name: web and a resources.requests.cpu value. Strategic merge matches containers by name, so only that field is added.

3. Read the rendered result

kubectl kustomize overlays/qa

What to look for:

Images work the same way: an images list can swap a name, tag or digest without writing a patch.

4. Apply and confirm

kubectl create namespace prepium-tutorial
kubectl apply -k overlays/qa
kubectl -n prepium-tutorial get deploy,cm --show-labels

Common mistakes

Example checkEvidence
Base untouchedFiles under base/ unchanged; overlay lists ../../base
Cross-cutting fields appliedRendered objects show prefix, namespace and labels
Patch landed on the right containerExactly one container, with the patched field
Generated config wired upDeployment references the hashed ConfigMap name that exists in the namespace

Cleanup: kubectl delete -k overlays/qa and kubectl delete namespace prepium-tutorial. References: Declarative management using Kustomize, labels, patches, configMapGenerator. Next, try Helm releases.

Difficulty
Medium · 8 minutes target
Domain
Application Deployment
Grading
Live checks · partial credit

Practice scope

This additional curriculum lab is available in single-task practice with the existing 12-minute limit. The three CKAD mocks keep their original 17-task sets. Hints, an explained solution and requirement-by-requirement feedback are available in the lab.

Browse CKAD practice tasks →