Home > Enterprise >  Any way we can add an ENV to a pod or a new pod in kubernetes?
Any way we can add an ENV to a pod or a new pod in kubernetes?

Time:12-23

Summarize the problem: Any way we can add an ENV to a pod or a new pod in kubernetes? For example, I want to add HTTP_PROXY to many pods and the new pods it will generate in kubeflow 1.4. So these pods can be access to internet.

Describe what you’ve tried: I searched and found istio maybe do that, but it's too complex for me. The second, there are too many yamls in kubeflow, as to I cannot modify them one by one to use configmap or add ENV just in them.

So anyone has a good simle way to do this? Like doing this in kubernetes configuation.

CodePudding user response:

Use "PodPreset" object to inject common environment variables and other params to all the matching pods.

Please follow below article https://v1-19.docs.kubernetes.io/docs/tasks/inject-data-application/podpreset/

CodePudding user response:

If PodPreset is indeed removed from v1.20, then you seem to need a webhook.

You will have to run an additional service in your cluster that will change the configuration of the pods.

Here is an example, on the basis of which I created my webhook, which changed the configuration of the pods in the cluster, in this example the developer used the logic adding a sidecar to the pod, but you can set your own to forward the required ENV:

https://github.com/morvencao/kube-mutating-webhook-tutorial/blob/master/medium-article.md

  • Related