A Kustomize patch declaratively changes selected fields in a Kubernetes manifest while preserving the reusable base. Overlays use patches to adapt configurations for environments such as staging without duplicating complete YAML files. section 5.3.2
Change staging replicas
Keep Deployment and Service definitions in a base, then target the my-app Deployment from overlays/staging and replace /spec/replicas with 3. Apply the result with kubectl apply -k overlays/staging/ and verify it with kubectl get deploy. section 5.3.2
resources:
- ../../base
patches:
- target:
kind: Deployment
name: my-app
patch: |-
- op: replace
path: /spec/replicas
value: 3
Inspect the overlay structure: reference the base, select the Deployment by kind and name, and apply a JSON-style replacement patch. section 5.3.2
Preview generated objects without applying them by running kubectl kustomize overlays/staging/. Removing an object from Kustomize does not automatically remove that object from the cluster. section 5.3.2
