In this guide, you’ll learn how to maintain a shared base configuration and apply environment-specific changes using Overlays in Kustomize. Overlays let you centralize common resources in aDocumentation Index
Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
Use this file to discover all available pages before exploring further.
base/ directory and then customize or extend them for dev, stg, prod, or any other environment.

| Directory | Contents | Purpose |
|---|---|---|
| base/ | nginx-depl.yaml, service.yaml, redis-depl.yaml | Shared deployments and services |
| overlays/dev | config-map.yaml + kustomization file | Dev-specific patches (e.g., replica count) |
| overlays/stg | config-map.yaml + kustomization file | Staging tweaks |
| overlays/prod | config-map.yaml + kustomization file | Production patches and extra resources |
1. Base kustomization
The base holds all common Kubernetes manifests.Make sure each file listed under
resources: has a valid manifest. You can validate your YAML with kubectl apply --dry-run=client -f.2. Dev Overlay
The Dev overlay references the base and patches the replica count using JSON 6902.| Field | Description |
|---|---|
resources: | Relative path to the shared base directory |
patchesJson6902 | JSON 6902 patch to modify /spec/replicas to 2 |
3. Production Overlay
For production, you can both patch existing resources and add new ones (e.g., a Grafana deployment).Ensure new resources like
grafana-depl.yaml are listed under resources: in the overlay’s kustomization.yaml. Otherwise, they won’t be rendered.4. Flexible Directory Structures
Kustomize supports organizing both base and overlays in nested feature folders. For example:- Feature-based grouping: Split
base/intodb/andapi/with individualkustomization.yaml. - Overlay mirroring: Maintain a similar hierarchy under each overlay for targeted patches.
- Cross-references: Each overlay’s kustomization file imports the correct child resources and patches.