<p>I have an environment variable file that is declared like following inside a <code>deployment.yaml</code> file:</p>
<pre><code>          env:
            - name: NATS_CLIENT_ID
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
</code></pre>
<p>I am just wondering to know if I want to use an <code>.env</code> file instead of the <code>deployment.yaml</code> file, how can I declare the above port within the <code>.env</code>?</p>

best_of_man
<p>Maybe you can create a configmap that contains your <code>.env</code> and use your configmap to inject the environment variables.</p>
<p>An example here: <a href="https://humanitec.com/blog/handling-environment-variables-with-kubernetes" rel="nofollow noreferrer">https://humanitec.com/blog/handling-environment-variables-with-kubernetes</a></p>
