[英]How to get the System HostName of kubernetes deployment inside pod?
在 kube.netes 中,我们可以使用环境变量来传递 hostIP
env:
- name: NODE_IP
valueFrom:
fieldRef:
fieldPath: status.hostIP
那么类似地如何获取 hostName 而不是 HostIP?
env:
- name: MY_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
正如已经回答的那样,那应该是spec.nodeName
。
我还想提一下,您可以使用的字段数量有限。 检查下行能力 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.