- Base Configuration: Contains all shared and default Kubernetes resource definitions.
- Overlay Directories: Each environment (e.g., dev, stg, prod) has its own overlay folder with patches to modify the base configuration as needed.

In this setup, the base folder holds the shared resource files, while each overlay folder contains a
kustomization.yaml that references the shared resources in the base along with overlays (patches or additional resources) specific to that environment.Base Configuration Example
Imagine that you have annginx-deployment.yaml file within your base folder with a replica count set to 1. The corresponding kustomization.yaml in the base folder might look like this:
nginx-depl.yaml file is defined as follows:
Creating Overlays
Development Overlay
To create an overlay for the development environment, you would set up akustomization.yaml file in the dev overlay folder. This file references the base configuration and includes a patch to update the replica count:
bases property points to the shared base resources using the relative path ../../base. The patch then modifies the replica count from 1 to 2 for the development environment.
Production Overlay
Similarly, to tailor the configuration for production, the overlay can reference the same base while applying a different patch:Adding New Resources in Overlays
Overlays can also introduce new resources that don’t exist in the base configuration. For instance, if you want to add a production-specific Grafana deployment, you can include its YAML file in the production overlay:Kustomize is flexible in the way you structure your configurations. While the base can be organized into subdirectories based on features, the overlay directories do not need to mirror that structure. The critical factor is correctly referencing the shared resources in the appropriate
kustomization.yaml file.
Summary
Overlays in Kustomize enable you to:- Import and reuse a base configuration containing shared resources.
- Apply environment-specific patches to adjust base resources such as replica counts.
- Introduce new resources within an overlay without affecting the base configuration.