<p>I've a <code>Deployment</code> object where I expose the POD ID using the <a href="https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/" rel="noreferrer">Downward API</a>. That works fine. However, I want to set up another env variable, log path, with reference to the POD ID. But, setting that variable value to <code>/var/log/mycompany/${POD_ID}/logs</code> isn't working, no logs are created in the container.
I can make the entrypoint script or the app aware of the POD ID, and build up the log path, but I'd rather not do that.</p>

<p>The correct syntax is to use <code>$(FOO)</code>, as is described in the <a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#envvar-v1-core" rel="noreferrer">v1.EnvVar <code>value:</code> documentation</a>; the syntax you have used is &quot;shell&quot; syntax, which isn't the way kubernetes interpolates variables. So:</p>
<pre><code>containers:
- env:
  - name: POD_ID
    valueFrom: # etc etc
  - name: LOG_PATH
    value: /var/log/mycompany/$(POD_ID)/logs
</code></pre>
<p>Also please note that, as mentioned in the Docs, the variable to expand must be defined before the variable referencing it.</p>
