A kustomization.yaml file declares Kubernetes resources and the transformations applied to them. Kustomize keeps shared base YAML separate from environment-specific overlays, supporting DRY configuration and GitOps workflows. section 5.3.2
Use the file to:
- List resources such as a Deployment and Service. section 5.3.2
- Apply a base configuration with kubectl apply -k base/. section 5.3.2
- Create overlays that customize a base for staging, production, or development. section 5.3.2
Base resources and a staging overlay
Create deployment.yaml and service.yaml under base/, then reference them from kustomization.yaml. A staging kustomization can reference ../../base and patch the Deployment named my-app, replacing /spec/replicas with 3. Apply the base with kubectl apply -k base/ and verify the result with kubectl get deploy,svc. section 5.3.2
resources: - deployment.yaml - service.yaml
Shows the minimal resources list for a base kustomization. section 5.3.2
resources:
- ../../base
patches:
- target:
kind: Deployment
name: my-app
patch: |-
- op: replace
path: /spec/replicas
value: 3
Shows an overlay referencing a base and applying a JSON patch to increase replicas. section 5.3.2
