Closed Lwxiang closed 2 years ago
I believe your use case will be supported by replacements
after completion of this feature: https://github.com/kubernetes-sigs/kustomize/issues/4053. Unfortunately, this is not available yet. However, when this done, you will be able to do the following:
source:
kind: Pod
name: pod-with-desired-env
fieldPath: spec.template.spec.containers.0.env
targets:
- select:
kind: Deployment
fieldPaths:
- spec.template.spec.containers.*.env
options:
create: true
Would this resolve your issue?
/kind support/ /triage accepted
@natasha41575: The label(s) kind/support/
cannot be applied, because the repository doesn't have them.
/kind support /unlabel needs-kind
/close
Please reopen if https://github.com/kubernetes-sigs/kustomize/issues/4053 will not solve the issue for you. Otherwise please see that issue for updates.
@natasha41575: Closing this issue.
Wouldn't the proposed solution replace all env vars in all containers? Is there a way to append to the env list (or better yet to apply a patch to every item of a list)?
Wouldn't the proposed solution replace all env vars in all containers? Is there a way to append to the env list (or better yet to apply a patch to every item of a list)?
I think some design work would be needed to support that. Functionality probably shouldn't be added to RFC6902 patches lightly (b.c. then they couldn't be called RFC6902 patches), and it's hard to imagine how this could be implemented in strategic merge patches.
origin resource
As the origin resource above, I have 2 container in 1 pod, and each has its own env. Now I want to insert an env drink=coffee into the 2 container.
I can do this by json patch:
But if I don't want to do this with every index of containers or I just don't know how many the containers are. Can I have a batch method, to add env for all containers by one step?