Use Kustomize patchesJson6902 with a target selector to apply an RFC 6902 patch to one resource in an overlay

domain: kubectl.docs.kubernetes.io · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. In the overlay's kustomization.yaml, add a patchesJson6902: list entry with a target: selector specifying at minimum version, kind, and name (plus group: if the resource's apiVersion has a group prefix, e.g. group: apps for a Deployment or StatefulSet) so it matches exactly one resource.
  2. Provide the patch operations either inline via patch: |- (a YAML list of RFC 6902 ops) or via path: pointing at a separate file of JSON or YAML RFC 6902 operations (op: add/replace/remove/copy/move/test, each with path and value/from as applicable).
  3. Scope the patch to a single resource instance by including name (and namespace where relevant) in target — matching only by kind/version without a name will not select a single resource; Kustomize also supports labelSelector/annotationSelector on the target for matching by label instead of by name.
  4. Run kustomize build . (or kubectl apply -k .) to verify the patch applies only to the intended resource in the overlay and doesn't alter the shared base definition.
  5. Be aware patchesJson6902 was deprecated in Kustomize v5.0.0 in favor of the unified patches: field, which accepts the same target selector plus either patch: or path:; run kustomize edit fix to auto-migrate an existing kustomization.yaml.

Known gotchas

Related routes

Use Kustomize components to inject a shared sidecar and ConfigMap across multiple overlays without duplicating patch files
kubectl.docs.kubernetes.io · 6 steps · unrated
Build a Kustomize overlay structure for three environments (dev, staging, prod) that patches replica counts, resource limits, and image tags without duplicating base manifests
Kustomize · 6 steps · unrated
Build a Kustomize component that adds a common sidecar container and shared volume across multiple overlays without duplicating the patch in each overlay
kubernetes.io · 5 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans