Hi I am following this doc https://github.com/kubernetes/kubernetes/blob/master/docs/devel/api-conventions.md#strategic-merge-patch for strategic-merge-patch to partially update the JSON objects using PATCH REST API. The document says that it can add or delete the object, but I have tried, whenever I add new object to existing JSON it just replaces that instead of adding new. I am trying this to modify pod definition in OpenShift 3.2. can anyone please help me how it works, probably with example. I need to use delete operation also , where I can delete the value by name.
A strategic merge patch is a customized version of JSON patch and it looks like an incomplete YAML specification of a Kubernetes resource.
Organizations undertake strategic mergers with other companies to accelerate their growth, rather than growing organically. The aim of a merger is to create an organization that is stronger than the sum of its parts. The merged organization is then in a better position to achieve its strategic goals.
The kubectl patch command takes YAML or JSON. It can take the patch as a file or directly on the command line. Create a file named patch-file.json that has this content: { "spec": { "template": { "spec": { "containers": [ { "name": "patch-demo-ctr-2", "image": "redis" } ] } } } }
In Kubernetes, pods can communicate with each other a few different ways: Containers in the same Pod can connect to each other using localhost , and then the port number exposed by the other container. A container in a Pod can connect to another Pod using its IP address.
As documented it depends on annotations of the types. AFAIS the strategic merge only works if patchStrategy
and patchMergeKey
are given. For example, this is the case in pod.spec.containers
and pod.spec.volumes
.
For an example you need to provide more information about the type you want to merge.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With