<p>I have suchlike problem:</p>

<pre><code>    spec:
  hostname: kafka
  containers:
  - name: kafka
    image: registry/wurstmeister:latest
    imagePullPolicy: Always
    restartPolicy: Always
    env:
      - name: HOSTNAME_COMMAND
        valueFrom:
          fieldRef: {fieldPath: metadata.name}
      - name: KAFKA_ADVERTISED_LISTENERS
        value: INSIDE://:9092,OUTSIDE://_${HOSTNAME_COMMAND}:9094
</code></pre>

<p>First HOSTNAME_COMMAND resolves successfully, so I see the pod's hostname.
I need to have the same for the second HOSTNAME_COMMAND, so I need to see something like this:</p>

<pre><code>value: INSIDE://:9092,OUTSIDE://_kafka-6b97669c5c-lhfp7:9094
</code></pre>

<p>Thank you.</p>

user37033
<p>You can use <code>$(ENV_NAME)</code> format inside other config, The details is here, <a href="https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/#using-environment-variables-inside-of-your-config" rel="nofollow noreferrer">Using environment variables inside of your config</a>.</p>
