This guide explains how to define patches using JSON 6902 and strategic merge patch methods with inline and separate file approaches.
In this guide, we explain how to define patches using both JSON 6902 and strategic merge patch methods. There are two primary approaches to defining a patch:
Inline—where the patch is embedded directly within the kustomization.yaml file.
Separate File—where the patch is stored in an external YAML file, keeping the kustomization.yaml file clean and uncluttered.
In the inline approach, the patch is directly embedded in your kustomization.yaml file. This method is ideal for simple or singular modifications. For example:
Alternatively, you can store your patch in an external YAML file and reference it in your kustomization.yaml file. This approach is beneficial when dealing with multiple patches or when you want to keep your main configuration file streamlined.In your kustomization.yaml file, reference the external patch file:
Choose the inline method for simplicity when only a few patches are needed, or opt for the separate file approach to maintain a cleaner and more manageable kustomization.yaml—especially when dealing with multiple or complex patches.For further details on patching strategies and best practices, refer to the Kustomize documentation.