In kubernetes we can use environment variable to pass hostIP using
env:
- name: NODE_IP
valueFrom:
fieldRef:
fieldPath: status.hostIP
So similarly how get hostName instead of HostIP?
CodePudding user response:
env:
- name: MY_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
CodePudding user response:
That should be, as already answered, spec.nodeName
.
What I also wanted to mention, there is a limited number of fields you can use. Check Capabilities of the Downward API.
Information available via fieldRef:
metadata.name
metadata.namespace
metadata.uid
metadata.labels['<KEY>']
metadata.annotations['<KEY>']
In addition, the following information is available through downwardAPI volume fieldRef:
metadata.labels
metadata.annotations
The following information is available through environment variables:
status.podIP - the pod's IP address
spec.serviceAccountName
spec.nodeName - the node's name, available since v1.4.0-alpha.3
status.hostIP - the node's IP, available since v1.7.0-alpha.1