Expand the env value defined in kubernetes definition to container Expand the env value defined in kubernetes definition to container kubernetes kubernetes

Expand the env value defined in kubernetes definition to container


- name:  NRIA_DISPLAY_NAME  value: abc-$HOSTNAME

should have two changes made to it:

  1. Ensure the thing you wish to have substituted is also present in the env: block -- I know you might think $HOSTNAME is universally populated, but that's not always true, and it is for sure not true in the kubernetes mental model

  2. Use the syntax $(INTERPOLATION_HERE) rather than the bash-centric $VAR or ${VAR}. That syntax is documented in the PodSpec reference

Thus:

env:- name: HOSTNAME  valueFrom:    fieldRef:      fieldPath: metadata.name      # or "status.hostIP" or "spec.nodeName" etc- name: NRIA_DISPLAY_NAME  value: abc-$(HOSTNAME)