K8s by Example: Kustomize Overlays
| Overlays customize a base for different environments. Base contains shared config. Overlays add environment-specific patches, replicas, and images. |
| directory-structure | |
| Standard layout: base directory with shared manifests, overlays directory with environment-specific customizations. Each overlay references the base. | |
| base/kustomization.yaml | |
| Base kustomization with shared resources. Contains the common configuration that all environments inherit. | |
| overlays/production/kustomization.yaml | |
| Overlay references base and adds customizations. Different replica counts, images, and config per environment. Namespace scopes all resources. | |
| overlays/production/increase-resources.yaml | |
| Strategic merge patches modify specific fields. First section shows kustomization.yaml referencing the patch. Second section is the patch file itself (increase-resources.yaml). Only specify what changes, the rest inherits from base. | |
| kustomization-jsonpatch.yaml | |
| JSON patches for precise modifications. Use | |
| terminal | |
| Deploy different environments by pointing to the overlay directory. Compare rendered output to see differences between environments. | |