<p>I need to populate an env file located into pod filesystem filled by an init container previously.</p>

<p>I look up <code>envFrom</code> <a href="https://kubernetes.io/docs/reference/federation/extensions/v1beta1/definitions/#_v1_envfromsource" rel="nofollow noreferrer">documentation</a> but I've not been able to figure out how to use it and I've been able to find some relevant examples in internet.</p>

<p>Guess an init container creates a file on <code>/etc/secrets/secrets.env</code>, so the pod container spec has to look up on <code>/etc/secrets/secrets.env</code> in order to populate env variables.</p>

Jordi
<p>You will not be able to reference any filesystem component to populate an environment variable using the PodSpec, because it creates a chicken-and-egg problem: kubernetes cannot create the filesystem without a complete PodSpec, but it cannot resolve variables in the PodSpec without access to the Pod's filesystem</p>

<p>If <code>/etc/secrets</code> is a <code>volume</code> that the <code>initContainer</code> and the normal <code>container</code> share, then you can supersede the <code>command:</code> of your <code>container</code> to source that into its environment before running the actual command, but that is as close as you're going to get:</p>

<pre><code>containers:
- name: my-app
  command:
  - bash
  - -ec
  - |
    . /etc/secrets/secrets.env
    ./bin/run-your-server-command-here
</code></pre>
