-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
extend patch from one target to multiple targets #720
Comments
/cc @monopole @pwittrock |
This is one I've recently ran into when trying to adapt We really like the idea of being able to apply a single patch to many different resources without needing to alter the resources themselves. This issue also sounds like it might be similar to #627 (at least somewhat) |
May also include a related request #824 |
Open a KEP for this request: kubernetes/enhancements#897 |
Is it already work in progress? @Liujingfang1 |
Is it possible to have the PR approved to test this new feature? |
This is not started yet. We recently added support for generator and transformer plugins. |
@Liujingfang1 Is there somewhere docs on how to this or some examples? |
Another possible use case might be updating/appending labels, like the ones recommended at https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/ |
@mkobit you can use |
kubernetes/enhancements#897 Looks really good 👍 |
In case anyone is interested, we've implemented |
We plan to implement this feature. Any one who is interested in it is welcome to contribute. Here are the tasks that we can break this feature into.
|
@adrienbrault Do you want to contribute to this feature? We can write a new builtin transformer for it. I listed the steps above. |
Also include the feature request from #1157 |
@Liujingfang1 Sure! I'll try to open a PR next week/in the next few weeks. |
All the tasks are done except detecting conflict. We'll address it separately if needed. |
@Liujingfang1 Started trying out those features last week with the latest release, it's working great so far! Thank you! |
I'm excited that this feature has been implemented, but it's not clear to me how to use it. I get an error message when trying to apply a patch to multiple deployments: % kustomize version
Version: {KustomizeVersion:3.1.0 GitCommit:95f3303493fdea243ae83b767978092396169baf BuildDate:2019-07-26T18:11:16Z GoOs:linux GoArch:amd64}
% kustomize build .
Error: builtin patch config: [112 97 116 104 58 32 114 101 97 100 121 46 121 97 109 108 10 116 97 114 103 101 116 58 10 32 32 107 105 110 100 58 32 68 101 112 108 111 121 109 101 110 116 10]: unable to get either a Strategic Merge Patch or JSON patch 6902 from kustomization.yaml resources:
- deployment.yaml
patches:
- path: ready.yaml
target:
kind: Deployment ready.yaml kind: Deployment
spec:
minReadySeconds: 120 deployment.yaml kind: Deployment
metadata:
name: first
spec:
template:
spec:
containers:
- name: app
command:
- true
---
kind: Deployment
metadata:
name: second
spec:
template:
spec:
containers:
- name: app
command:
- true |
@Liujingfang1 Just tested this feature in a project that was halted waiting for it, it worked wonderfully! Thanks to you and all involved! Saved me a lot of redundant projects just to change some environment values! |
@keithkml You need to have |
Is this feature gone? I'm on the latest version of
If necessary, I will create a new issue |
@leroy0211 Try adding |
How do I make a patch that applies to all of the containers in a deployment with this feature? |
Just to give a (i thought common) use case: We are using minikube for local development and mount our sourcecode into the pod so that we do not have to rebuild the docker image and restart the pod everytime we change code. So we need to mount volumes for the minikube environment but not for test and production. Creating a patch for every container is not pretty appropriate. To summarize the problem I like to solve: I can only patch CRD dynamically via |
Was this use case addressed? |
It looks like there's still no way to apply the same strategic merge patch to multiple target resources. Was that desire supposed to be addressed here? |
I don't think this allows you to patch multiple configuration elements within a single resource by pattern-matched or wildcard paths, e.g. match all |
Thanks for implementing this! I sifted through the docs several times and I still couldn't figure out how to do this. I'm probably just hard-headed, but it doesn't seem well documented yet in the docs at patches field nor on PatchTransformer. Thanks to the help from the messages above, here's a simplified working example that I was able to use for a deployment with kustomization.yaml # ... snip...
patches:
- target:
kind: Deployment
path: patch-deployment.yaml patch-deployment.yaml apiVersion: apps/v1
kind: Deployment
metadata: # THIS IS IGNORED
name: name-is-ignored
spec:
template:
spec:
imagePullSecrets:
- name: image-pull-secret Hope this helps anyone else (including future me). 😄 EDIT: p.s. It was the |
The error:
could definitely use a specific hint in the case where a SM patch lacks a required Hopefully the comments here will help people, especially with exact error message cited. |
I am still missing this. My use-case is to add a ca-certificate replicated by trust-manager in all my containers. (I do not think I am the only one with this use-case ;) ) So actually I am doing this:
Looking for a solution to change
|
Currently, there are different types of patches supported in Kustomize: strategic merge patch and JSON patch.
Both types need GVKN info to find the unique target to perform the patching. In strategic merge patch, GVKN is included in the patch itself. In JSON patch, the GVKN is specified in
kustomization.yaml
.We have seen requests for patching multiple targets by one patch: #409, #412, #567.
The use cases related to those requests include but not limit to
We need to figure out the scope of extending the patches and investigate the trade-off among different approaches. Here are some questions to think about
The text was updated successfully, but these errors were encountered: