Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

patchesStrategicMerge for non-kubernetes resources #742

Closed
johnhny opened this issue Jan 29, 2019 · 1 comment
Closed

patchesStrategicMerge for non-kubernetes resources #742

johnhny opened this issue Jan 29, 2019 · 1 comment

Comments

@johnhny
Copy link

@johnhny johnhny commented Jan 29, 2019

Hi everybody 馃憢

I'm curious how to use Kustomize patchesStrategicMerge to patch non-kubernetes resources.

I created a tiny example project, to demonstrate the issue:
https://github.com/johnhny/kustomize-patch-non-k8s

  1. A k8s deployment with a patch that should MERGE into the original deployment.yml
  2. A non-k8s resource ("bee") with a patch that should MERGE into the original bee.yml

When you run and compare these two configurations like:

diff <(kustomize build bee) <(kustomize build deployment)

... you will notice, that Kustomize/patchesStrategicMerge is not merging but replacing the original tree in the bee.yml:
image
For the k8s-deployment patch, all works like expected 馃憤

Can you give us a hint, how we can get this to work in the same way for a non-k8s resource?

Thank you,
Arno

@Liujingfang1
Copy link
Contributor

@Liujingfang1 Liujingfang1 commented Jan 29, 2019

patchesStrategicMerge treats the patch as a strategic merge patch when corresponding resource is native in Kubernetes. If a kind is not found, such as a custom resource, the patch is treated as json merge patch. The JSON patch will replace the whole tree as @johnhny observed. To keep the volumes under spec, you also need to add them in the patch.

Here is some background related to this. Strategic merge patch doesn't work for custom resources since the metadata needed by this kind of patch is missing in the custom resources. kubernetes/kubernetes#53558

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants