

patchStrategicMerge.
Instead of providing a list of operations like JSON Patch, patchStrategicMerge uses an overlay: a snippet of Kubernetes YAML that represents the desired partial state. Kyverno merges this overlay into the resource being created.

kubectl patch, this will feel familiar: Kyverno applies the overlay and creates missing fields as needed.
Example: set a default seccomp profile for all Pods
Alex wants to improve cluster security by ensuring every Pod uses the RuntimeDefault seccomp profile. A Kubernetes-style strategic merge patch in a Kyverno mutate rule looks like this:
securityContext or seccompProfile do not exist, Kyverno will create them. The patch is concise and easy to read.
The key advantage — and the reason to prefer patchStrategicMerge in many cases — is autogen. Because overlays do not rely on fixed JSON paths like /spec/containers/0, Kyverno can auto-generate equivalent mutate rules for higher-level controllers. A single Pod-matching patch can be applied to Deployments, ReplicaSets, StatefulSets, CronJobs, and more, with Kyverno placing the overlay correctly inside their pod templates.

- Use
patchStrategicMergefor most common tasks: adding labels, setting defaults, or applying securityContext fields. It is declarative, readable, and works well with Kyverno autogen for pod controllers. - Use
patchesJson6902(JSON Patch) when you need very precise edits that overlays cannot express — for example, removing a specific field, operating on a particular list index, or performing fine-grained operations like replace/remove at an exact path.
A note about conditional logic
patchStrategicMerge supports conditional anchors and expressions directly within the patch. That allows patterns like “add this label only if it doesn’t already exist.” JSON Patch does not support that style of inline conditional logic. We’ll cover conditional anchors and expressions in the next lesson.
Summary
- Prefer
patchStrategicMergeas the default for most mutate rules because it’s declarative, autogen-friendly, and easier to maintain. - Reserve
patchesJson6902for targeted, path-based edits when overlays can’t express the required change.

patchStrategicMerge supports conditional anchors and expressions directly within the patch, letting you say things like “add this label only if it doesn’t already exist.” JSON Patch does not support this style of conditional logic. Conditional anchors will be covered later.
Finally, strategic merge patches are generally simpler and easier to read, which makes them a great default choice for many mutation scenarios.
Choose
patchStrategicMerge for declarative overlays and autogen-friendly mutations. Reserve JSON Patch for targeted, path-based edits that overlays can’t express.
- Kyverno Documentation
- kubectl patch reference
- Kyverno autogen and mutate rule behavior — see the Kyverno docs for details on how autogen maps Pod-level patches to controllers.