A Kustomize overlay is an environment-specific configuration layer that modifies shared Kubernetes manifests while keeping YAML configurations DRY. Kustomize uses kustomization.yaml files and integrates directly with kubectl, so no separate CLI is required. section 5.3.2 section 5.5
Use an overlay when an application shares a base configuration but needs environment-specific changes:
- Keep common resources such as a Deployment and Service in a base directory. section 5.3.2
- Create a directory such as overlays/staging with its own kustomization.yaml. section 5.3.2
- Reference the base and apply a patch that changes only the staging requirements. section 5.3.2
- Render or apply the selected configuration with kubectl and verify the resulting Deployment and Service. section 5.3.2
Staging overlay with three replicas
A base kustomization lists deployment.yaml and service.yaml. The staging overlay references ../../base and applies a JSON patch targeting Deployment my-app, replacing /spec/replicas with 3. Applying the overlay produces the staging desired state without editing the shared base files.
resources:
- ../../base
patches:
- target:
kind: Deployment
name: my-app
patch: |-
- op: replace
path: /spec/replicas
value: 3
Inspect the overlay definition to see how a base directory and targeted replica patch combine into an environment-specific configuration. section 5.3.2
