Patches: strategic merge & JSON6902
Change exactly what differs.
Patches are how an overlay changes specific fields of a base resource. Kustomize supports two styles. A strategic-merge patch is a partial manifest — you write just the fields you want to change, with enough identity (kind + name) to match, and Kustomize merges it into the base. A JSON6902 patch is a precise op list (add/replace/remove at a JSON path), ideal for surgical edits and for changing list elements where merge semantics are ambiguous.
# patches/resources.yaml — only the fields that changeapiVersion: apps/v1kind: Deploymentmetadata: { name: payments-api }spec:template:spec:containers:- name: appresources:limits: { cpu: "2", memory: 1Gi }# kustomization.yaml: patches: [{ path: patches/resources.yaml }]
patches:- target: { kind: Deployment, name: payments-api }patch: |-- op: replacepath: /spec/replicasvalue: 4- op: addpath: /spec/template/spec/containers/0/env/-value: { name: TIER, value: prod }
Choosing a patch style
Reach for strategic-merge for most changes — it reads like the manifest and merges maps naturally. Use JSON6902 when you need to target a list element by index, remove a field entirely, or when merge behavior on a list is not what you want (strategic merge can append or replace lists depending on patch strategy). Both are declarative and both are visible in kustomization.yaml, so the overlay documents exactly what it changes.