Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Is it possible for an InitContainer to change the environment variables of the application container when running inside the same Pod?

Note that I am looking for a detailed answer that describes the technical reasons why this is or isn't possible. Example: 'Current container technology supports environment variable isolation between containers and Pods cannot bypass that restriction by "grouping" containers in the same "environment variable space"'.

like image 422
atomaras Avatar asked May 06 '18 19:05

atomaras


2 Answers

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.

like image 122
Maciek Sawicki Avatar answered Oct 02 '22 03:10

Maciek Sawicki


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.

like image 25
Jakub Avatar answered Oct 02 '22 03:10

Jakub