patchesJSON6902
• For similar examples, refer to the Kustomize documentation on patchesJSON6902.
• Example files are available in the Kompozit GitHub repository.
Kompozit supports JSON Patch (RFC 6902) to modify resources in a flexible way. The jsonpatch module is used internally in Kompozit to apply standard operations such as:
add: Adds a value to the specified path.
remove: Removes the value at the specified path.
replace: Replaces the value at the specified path.
This allows you to precisely control how resources are modified in your configurations.
For example, to replace the Docker image for the Traefik service, you can define the following patch in the kompozition file:
Parameters:
op: The operation you want to perform. In this case, it’s replace.
path: The JSON path where you want to apply the operation.(Here, it’s
/services/traefik/image
).value: The value to be used in the replace operation, such as "traefik:v2".
Result After Applying the Patch
Caveat
The patches defined in the kompozition file will be applied to all matching JSON paths across all resources. For example, if multiple docker-compose.yaml files define the same service name (e.g., traefik), the patch will be applied to all instances of that service, even across different files.
Last updated