Is it possible for 2 containers inside a Pod to share the same Environment Variables? Is it possible for 2 containers inside a Pod to share the same Environment Variables? kubernetes kubernetes

Is it possible for 2 containers inside a Pod to share the same Environment Variables?


Short answer is No, they can't.

You can try some hack something using ShareProcessNamespace and gdb but for sure this is not correct solution for problem you are trying to solve.


No, it is not possible to just change the variables like that. One of the possible workarounds is to use an EmptyDir volume shared between the InitContainer and the main container. You can store there a the variables using a file in InitContainer and load them in the main container using a some simple shell script.