Kubernetes: How to refer to one environment variable from another?

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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)