<p>I have two env vars in a pod (or a config map):<br>
- <code>TARGET_URL=http://www.example.com</code><br>
- <code>TARGET_PARAM=param</code></p>

<p>Is there any way for me to provide a third env var which is derived from both these vars, something like <code>${TARGET_URL}/mysite/${TARGET_PARAM}</code>.</p>

<p>Thanks!</p>

Pavel Tarno
<p>For environment variables (and a couple of other fields in the pod spec, including <code>args</code> and <code>command</code>) there is a Make-like <code>$(VARIABLE)</code> name that will get expanded; see for example <a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.13/#envvar-v1-core" rel="nofollow noreferrer">the documentation for <code>.env.value</code></a>.  This could look like:</p>

<pre><code>env:
  - name: TARGET_URL
    valueFrom:
      configMapKeyRef:
        key: cm
        name: TARGET_URL
  - name: TARGET_PARAM
    valueFrom:
      configMapKeyRef:
        key: cm
        name: TARGET_PARAM
  - name: TARGET_DETAIL_URL
    value: $(TARGET_URL)/mysite/$(TARGET_PARAM)
</code></pre>

<p>If you are depending on mounting a ConfigMap into a container as files, then it can only contain static content; this trick won't work.</p>
