<p>I have an application that needs to know it's assigned NodePort. Unfortunately it is not possible to write a file to a mountable volume and then read that file in the main container. Therefore, i'm looking for a way to either have the initContainer set an environment variable that gets passed to the main container or to modify the main pod's launch command to add an additional CLI argument. I can't seem to find any examples or documentation that would lead me to this answer. TIA.</p>

<p>There's no direct way so you have to get creative. For example you can make a shared emptyDir mount that both containers can access, have the initContainer write <code>export FOO=bar</code> to that file, and then change the main container command to something like <code>[bash, -c, &quot;source /thatfile &amp;&amp; exec originalcommand&quot;]</code></p>
