Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

kubernetes strategic merge patch

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.

like image 284
priyank Avatar asked Dec 09 '16 11:12

priyank


People also ask

What is a strategic merge patch?

A strategic merge patch is a customized version of JSON patch and it looks like an incomplete YAML specification of a Kubernetes resource.

What is strategic merge?

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.

What is patch command in Kubernetes?

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" } ] } } } }

How do you communicate between two services in Kubernetes?

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.


1 Answers

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.

like image 80
svenwltr Avatar answered Sep 29 '22 05:09

svenwltr