Kustomize: Template-Free YAML Customization (base & overlays)
Customize manifests per environment with bases and overlays-no templates required.
In plain words
Kustomize is a layered transparent film placed over a common map, changing labels and streets without rewriting the base drawing. The simple Kubernetes rule is: Kustomize builds resources from a base and overlays by applying resources, patches, generators, and transformers without a string-template language.
Think of it like…
Kustomize is a layered transparent film placed over a common map, changing labels and streets without rewriting the base drawing.
Where you’ve seen it
A platform team reviews a promoted source revision and runs kubectl kustomize environments/prod | kubectl diff -f -; kubectl apply -k environments/prod. Expected evidence: Kustomize builds resources from a base and overlays by applying resources, patches, generators, and transformers without a string-template language. If the run instead shows this symptom, stop and restore the last known state: A name prefix, patch target, or namespace transformer in an overlay can change selectors and references differently, producing invalid cross-resource ownership.
Words you’ll hear
- Base
- For this lesson, Base is the controlling idea: Kustomize builds resources from a base and overlays by applying resources, patches, generators, and transformers without a string-template language.
- Overlays
- Overlays is the checkpoint; run
kubectl kustomize environments/prod | kubectl diff -f -; kubectl apply -k environments/prodand inspect the owner chain. A name prefix, patch target, or namespace transformer in an overlay can change selectors and references differently, producing invalid cross-resource ownership. - kustomization.yaml
- kustomization.yaml is the outcome to preserve; the cost is explicit: The template-free model is reviewable and composes well, but complex branching or conditional policy often becomes a large patch hierarchy.
- Verification evidence
- The evidence command is
kubectl kustomize environments/prod | kubectl diff -f -; kubectl apply -k environments/prod. It connects the declaration to this behavior: Customize manifests per environment with bases and overlays-no templates required.
Visual diagram
Theory & deep dive
How Base reaches the intended state
Customize manifests per environment with bases and overlays-no templates required. Kustomize builds resources from a base and overlays by applying resources, patches, generators, and transformers without a string-template language.
The concrete checkpoint is kubectl kustomize environments/prod | kubectl diff -f -; kubectl apply -k environments/prod; compare the Base owner, Overlays state, and kustomization.yaml outcome instead of treating YAML acceptance as proof.
Run kubectl kustomize environments/prod | kubectl diff -f -; kubectl apply -k environments/prod after the change and correlate the result with Events and the owning object. Kustomize builds resources from a base and overlays by applying resources, patches, generators, and transformers without a string-template language.
Overlays: failure boundary and production cost
A name prefix, patch target, or namespace transformer in an overlay can change selectors and references differently, producing invalid cross-resource ownership. The prerequisite contract is concrete: Kustomize builds resources from a base and overlays by applying resources, patches, generators, and transformers without a string-template language.
The template-free model is reviewable and composes well, but complex branching or conditional policy often becomes a large patch hierarchy. A safe design limits blast radius, records the last good configuration, and uses kubectl kustomize environments/prod | kubectl diff -f -; kubectl apply -k environments/prod as a deterministic rollback checkpoint.
Capture the current state with kubectl kustomize environments/prod | kubectl diff -f -; kubectl apply -k environments/prod, then correct the controlling manifest rather than patching a child object; the relevant divergence signal is specific: A name prefix, patch target, or namespace transformer in an overlay can change selectors and references differently, producing invalid cross-resource ownership.
How it works, step by step
Step 1 of 41. Choose the source of truth
Version the source and describe the review, render, and reconciliation boundary: Kustomize builds resources from a base and overlays by applying resources, patches, generators, and transformers without a string-template language.
- Goal
- Customize manifests per environment with bases and overlays-no templates required.
- Owner
- Base
When to use it & trade-offs
What it is
Customize manifests per environment with bases and overlays-no templates required. Kustomize builds resources from a base and overlays by applying resources, patches, generators, and transformers without a string-template language.
Why it matters: A name prefix, patch target, or namespace transformer in an overlay can change selectors and references differently, producing invalid cross-resource ownership. The invariant at risk is specific: Kustomize builds resources from a base and overlays by applying resources, patches, generators, and transformers without a string-template language. The quickest fact check before changing the design is kubectl kustomize environments/prod | kubectl diff -f -; kubectl apply -k environments/prod.
When to reach for it
- Use Base to enforce this invariant: Kustomize builds resources from a base and overlays by applying resources, patches, generators, and transformers without a string-template language.
- Use Overlays evidence from
kubectl kustomize environments/prod | kubectl diff -f -; kubectl apply -k environments/prodin reviews and incident timelines. Customize manifests per environment with bases and overlays-no templates required. - Choose the platform operator workflow route only when this cost is justified by governance or scale: The template-free model is reviewable and composes well, but complex branching or conditional policy often becomes a large patch hierarchy.
When to avoid or be careful
- Avoid assuming Base is complete after YAML submission; the required behavior is concrete: Kustomize builds resources from a base and overlays by applying resources, patches, generators, and transformers without a string-template language.
- Avoid treating the next symptom as random; check the owner and state with
kubectl kustomize environments/prod | kubectl diff -f -; kubectl apply -k environments/prodfirst: A name prefix, patch target, or namespace transformer in an overlay can change selectors and references differently, producing invalid cross-resource ownership. - Avoid adopting a heavier platform wrapper before measuring its cost: The template-free model is reviewable and composes well, but complex branching or conditional policy often becomes a large patch hierarchy.
Native, manual, and managed paths for Base
kubectl kustomize environments/prod | kubectl diff -f -; kubectl apply -k environments/prod.Strengths: Kustomize builds resources from a base and overlays by applying resources, patches, generators, and transformers without a string-template language.
Watch out: The template-free model is reviewable and composes well, but complex branching or conditional policy often becomes a large patch hierarchy. Recovery must also recognize this signal: A name prefix, patch target, or namespace transformer in an overlay can change selectors and references differently, producing invalid cross-resource ownership.
kubectl kustomize environments/prod | kubectl diff -f -; kubectl apply -k environments/prod; the expected invariant is: Kustomize builds resources from a base and overlays by applying resources, patches, generators, and transformers without a string-template language.Strengths: kubectl kustomize environments/prod | kubectl diff -f -; kubectl apply -k environments/prod gives immediate feedback without first building a platform layer.
Watch out: A manual change can hide drift, and unlike Base, it does not make this symptom self-documenting: A name prefix, patch target, or namespace transformer in an overlay can change selectors and references differently, producing invalid cross-resource ownership.
kubectl kustomize environments/prod | kubectl diff -f -; kubectl apply -k environments/prod.Strengths: Platform controls can wrap this exact behavior in policy or dashboards: Kustomize builds resources from a base and overlays by applying resources, patches, generators, and transformers without a string-template language.
Watch out: The added platform ownership buys value at this cost: The template-free model is reviewable and composes well, but complex branching or conditional policy often becomes a large patch hierarchy.
Interview signals & numbers to know
When this topic comes up
- Interview anchor: Kustomize builds resources from a base and overlays by applying resources, patches, generators, and transformers without a string-template language.
- Trace Base to kustomization.yaml through Overlays; the invariant is: Kustomize builds resources from a base and overlays by applying resources, patches, generators, and transformers without a string-template language.
- Recognize the symptom: A name prefix, patch target, or namespace transformer in an overlay can change selectors and references differently, producing invalid cross-resource ownership.
- Justify the cost: The template-free model is reviewable and composes well, but complex branching or conditional policy often becomes a large patch hierarchy.
- Verify with kubectl kustomize environments/prod | kubectl diff -f -; kubectl apply -k environments/prod instead of only inspecting YAML.
Benchmarks & rules of thumb
- 2
- principal layers: base and overlay
- 1
- rendered result should be reviewed before apply
- 0
- custom Go template execution is required for a patch
Common mistakes & follow-ups
Common interview mistakes
- Debugging only the child object misses the Base owner contract: Kustomize builds resources from a base and overlays by applying resources, patches, generators, and transformers without a string-template language.
- Ignoring this telltale condition leads to unrelated changes: A name prefix, patch target, or namespace transformer in an overlay can change selectors and references differently, producing invalid cross-resource ownership.
- Repeating
kubectl kustomize environments/prod | kubectl diff -f -; kubectl apply -k environments/prodwithout an owner for remediation wastes retry cost. The template-free model is reviewable and composes well, but complex branching or conditional policy often becomes a large patch hierarchy.
Likely interviewer follow-ups
- How would API output and runtime evidence prove this behavior: Kustomize builds resources from a base and overlays by applying resources, patches, generators, and transformers without a string-template language?
- Which owner object, logs, and Events would you inspect for this symptom-A name prefix, patch target, or namespace transformer in an overlay can change selectors and references differently, producing invalid cross-resource ownership-?
- At what threshold would this cost become unacceptable: The template-free model is reviewable and composes well, but complex branching or conditional policy often becomes a large patch hierarchy?
kubectl kustomize environments/prod | kubectl diff -f -; kubectl apply -k environments/prod, name the failure, then justify the cost. Invariant: Kustomize builds resources from a base and overlays by applying resources, patches, generators, and transformers without a string-template language. Failure: A name prefix, patch target, or namespace transformer in an overlay can change selectors and references differently, producing invalid cross-resource ownership. Cost: The template-free model is reviewable and composes well, but complex branching or conditional policy often becomes a large patch hierarchy.Knowledge check
Put it into practice
Practice related interview Q&A
Apply Kustomize: Template-Free YAML Customization (base & overlays) with generative AI interview Q&A and hands-on practice.