Skip to main content
After authoring kustomization.yaml files and exploring Kustomize features, the next step is to assemble everything and apply environment-specific changes. Kustomize exists to let you take a shared “base” Kubernetes configuration and customize it per environment (development, staging, production, etc.) without duplicating manifests. A typical Kustomize project separates reusable manifests (the base) from environment-specific overlays (patches and extras). This approach improves maintainability, reduces duplication, and makes deployments predictable. Example project layout
Reference the base kustomization from an overlay using a relative path. Older Kustomize versions used the bases field; the recommended practice is to reference the base via resources: - ../../base so Kustomize includes the base kustomization.
How base + overlays work
  • Base: contains shared manifests used by multiple environments (deployments, services, config maps common to all).
  • Overlay: references the base using a relative path and applies environment-specific patches or adds resources unique to that environment.
Base: shared resources base/kustomization.yaml
base/nginx-depl.yaml (snippet)
Example: change replicas per environment If the base declares 1 replica but your development environment needs 2, add an overlay that references the base and applies a strategic merge patch. overlays/dev/kustomization.yaml
overlays/dev/replica-patch.yaml
Notes on relative paths:
  • Overlay file: k8s/overlays/dev/kustomization.yaml
  • ../../base resolves by moving from dev → overlays → k8s and into base, importing the base kustomization.
Production overlay example For production, you might apply a different patch: overlays/prod/kustomization.yaml
overlays/prod/replica-patch.yaml
Add new resources in overlays Overlays can also include entirely new resources not present in the base (e.g., monitoring or logging components). Example layout with Grafana in prod:
overlays/prod/kustomization.yaml
overlays/prod/grafana-depl.yaml (snippet)
Flexible directory structures Kustomize is flexible — you can break the base into feature subdirectories (for example, db/ and api/) and mirror or reorganize overlays however makes sense for your team. Each kustomization.yaml should import required resources (including sub-kustomizations) and keep environment patches close to the overlay they modify. Example of a more modular layout:
Quick commands: build and apply an overlay
  • Build the manifests for an overlay:
    • kustomize build overlays/dev or kubectl kustomize overlays/dev
  • Apply directly with kubectl:
    • kubectl apply -k overlays/dev
Comparison: base vs overlay Best practices
  • Keep the base minimal and generic — only the common configuration used across environments.
  • Place environment-specific settings in overlays, close to the overlay’s kustomization.yaml.
  • Prefer patchesStrategicMerge for simple field overrides like replicas or container images. Use patchesJson6902 for precise JSON Patch-style changes when needed.
  • Use relative paths for referencing the base (resources: - ../../base) to keep overlays portable.
  • Add new resources in overlays when a component should exist only in specific environments (monitoring, debug tools, etc.).
Summary
  • Use a base/ directory for shared configuration.
  • Create an overlays/ directory with one overlay per environment that references the base via a relative path.
  • Apply environment-specific changes using patches (e.g., patchesStrategicMerge).
  • Overlays can also add new resources that don’t exist in the base.
  • Organize directories in the structure that best fits your project—Kustomize is flexible.
If you need JSON Patch-style modifications, you can use patchesJson6902 instead of patchesStrategicMerge. Strategic merge patches are often simpler for changing fields like replicas.
Links and references

Watch Video

Practice Lab