Difficulty: Intermediate
What is Kustomize, and how does it let you manage per-environment Kubernetes manifests without templates?
Kustomize is a template-free configuration tool for Kubernetes that builds final manifests by layering patches and transformations on top of plain YAML. You keep a shared base and add small overlays for each environment, and it is built into kubectl, so kubectl apply -k overlays/prod renders and applies everything in one step.
Every Kustomize directory has a kustomization.yaml that lists what to include and what to change:
resources: the YAML files or other kustomization directories to start frompatches: strategic merge patches or JSON 6902 patches that change specific fieldsimages: swap image names or tags without touching the DeploymentnamePrefix / nameSuffix and namespace: rename or move every resourcelabels: add labels (and optionally selectors) everywhereconfigMapGenerator / secretGenerator: create ConfigMaps and Secrets from files or literalsA typical layout is base/ with the Deployment and Service, then overlays/dev, overlays/staging and overlays/prod, each referencing ../../base and changing only what differs, such as replicas, resources and the image tag.
The base files are valid Kubernetes YAML that you can kubectl apply directly. There are no {{ }} placeholders, so linters, IDE schemas and code review all work on real manifests. Kustomize understands Kubernetes object structure, which means a patch only needs the identifying fields (apiVersion, kind, metadata.name) plus the fields you want to change.
| Aspect | Kustomize | Helm |
|---|---|---|
| Approach | Patch plain YAML | Render Go templates |
| Built into kubectl | Yes (-k) | No, separate CLI |
| Packaging and versioning | None, just directories | Versioned charts in repos/OCI |
| Release tracking and rollback | No | Yes, stored revisions |
| Best for | Your own apps across environments | Distributing reusable apps |
Many teams combine them: install third-party software with Helm and manage in-house services with Kustomize, or use Kustomize's helmCharts field (with --enable-helm) to patch a chart's output.
configMapGenerator appends a content hash to the name (for example app-config-7f8k2m). When the config changes, the name changes, the Deployment reference updates, and Pods roll out automatically. This is a feature, but surprises people who hard-code the name.kustomize binary, so newer fields may only work with the standalone tool.patchesStrategicMerge, patchesJson6902 and commonLabels are deprecated in favour of patches and labels; kustomize edit fix migrates them.# base/kustomization.yaml
resources:
- deployment.yaml
- service.yaml
# overlays/prod/kustomization.yaml
resources:
- ../../base
namespace: shop-prod
images:
- name: ghcr.io/acme/checkout
newTag: "1.5.0"
patches:
- target:
kind: Deployment
name: checkout
patch: |-
- op: replace
path: /spec/replicas
value: 6
configMapGenerator:
- name: checkout-config
literals:
- PAYMENT_TIMEOUT_MS=3000
The prod overlay reuses the base unchanged and only declares the differences: namespace, image tag, replica count and config.
# See the final YAML without applying
kubectl kustomize overlays/prod
# Compare with what is running
kubectl diff -k overlays/prod
# Apply
kubectl apply -k overlays/prod
Rendering and diffing before applying is the standard review loop for Kustomize changes.
Kustomize, Bases and Overlays, Patches, configMapGenerator, kubectl apply -k