I've a Deployment
object where I expose the POD ID using the Downward API. 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 /var/log/mycompany/${POD_ID}/logs
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.
The correct syntax is to use $(FOO)
, as is described in the v1.EnvVar value:
documentation; the syntax you have used is "shell" syntax, which isn't the way kubernetes interpolates variables. So:
containers:
- env:
- name: POD_ID
valueFrom: # etc etc
- name: LOG_PATH
value: /var/log/mycompany/$(POD_ID)/logs
Also please note that, as mentioned in the Docs, the variable to expand must be defined before the variable referencing it.