I have suchlike problem:
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
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:
value: INSIDE://:9092,OUTSIDE://_kafka-6b97669c5c-lhfp7:9094
Thank you.
You can use $(ENV_NAME)
format inside other config, The details is here, Using environment variables inside of your config.