Kustomize Cheatsheet
Top commands.
Overview
Kustomize is the template-free Kubernetes manifest customiser, baked directly into kubectl. Five primitives carry most of the operational work: base manifests plus environment overlays, strategic-merge patches in place of templates, native kubectl integration, ConfigMap and Secret generators, and reusable Components for cross-cutting concerns.
- Base plus overlays. Common manifests live in
base/; environment-specific differences live inoverlays/dev,overlays/prod. Clean separation by design. - No templating. Strategic-merge and JSON-6902 patches replace Go templates. Manifests stay readable as plain YAML.
- Built into
kubectl.kubectl apply -krenders and applies in one step. No extra binary required. - Generators plus Components.
configMapGeneratorandsecretGeneratorfor declarative config; Components for reusable manifest fragments shared across applications.
The approach
Five commands and patterns carry most operational weight. Memorising them turns multi-environment Kubernetes deploys from copy-paste exercises into reviewable diff workflows.
kustomize build overlays/prod. Render the prod overlay locally without applying. The review step before any cluster contact.kubectl apply -k overlays/prod. Render and apply in one command. Replaces multi-step pipelines.- Strategic-merge patches. Override individual fields without copying entire resources. Overlays stay small and intent-focused.
configMapGeneratorpluscommonLabels. ConfigMaps from files or literals;commonLabelsapplied across every resource for consistent metadata.
Why this compounds
Each base captures application packaging once and supplies it to every environment. The team’s overlay library grows quarter over quarter; new services inherit the conventions instead of inventing them.
- Reusable bases reduce duplication. One base, many environments and applications. Operational surface stays small.
- Environment consistency. Same base, different overlays, identical structure. Drift between dev and prod shrinks.
kubectl-native tooling. No extra dependencies; nothing to keep in version sync with the cluster.- Year-one investment, year-two habit. The first base is a learning exercise. By the third, the patterns are settled and authoring is fast.