Skip to main content
Kustomize supports two patch strategies—JSON 6902 and Strategic Merge—to help you customize Kubernetes manifests. Use inline patches for quick edits or external patch files for better organization as your configuration grows.

Patch Overview


JSON 6902 Patches

JSON 6902 patches let you apply JSON-style operations to modify existing resources.

1. Inline Definition

Embed the patch directly in your kustomization.yaml under patchesJson6902:

2. External File

Separate the patch into its own file (replica-patch.yaml) and reference it: kustomization.yaml
replica-patch.yaml
External JSON 6902 patches are ideal when you need to apply multiple operations or share patches across environments.

Strategic Merge Patches

Strategic Merge Patches allow you to declaratively merge fields into existing resources.

1. Inline Definition

Define the merge patch inline in kustomization.yaml under patchesStrategicMerge:

2. External File

Store the merge patch in a file (strategic-replica-patch.yaml) and reference it: kustomization.yaml
strategic-replica-patch.yaml
The metadata.name in your patch must exactly match the target resource name; otherwise, the patch won’t be applied.

Best Practices

  • Use inline patches for small, one-off tweaks.
  • Move to external files when your patches multiply or you need reuse.
  • Group related patches in directories to manage environment overlays (e.g., overlays/staging, overlays/production).

References

Watch Video