I was wondering if it's possible to refer to image field in Kubernetes deployment yaml file, as
env:
- name: VERSION
value:
valueFrom:
containerField: spec.imagePlease let me know. Thank you.
image value in pod definition cannot be passed as environment variable using fieldRef.
The only supported values are metadata.name, metadata.namespace, metadata.labels, metadata.annotations, spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs and resource fields (memory, cpu request/limits) and container ephemeral storage limit/request.
As a workaround it can be passed using labels and then passing this label as an environment variable, example:
env:
- name: VERSION
valueFrom:
fieldRef:
fieldPath: metadata.labels['version']