本文介绍了如何从Pod内部获取节点IP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在运行一个go应用,该应用正在创建作为节点特定指标的prometheus指标,并且希望能够将节点IP添加为标签.
I am running a go app that is creating prometheus metrics that are node specific metrics and I want to be able to add the node IP as a label.
有没有一种方法可以从Pod内捕获节点IP?
Is there a way to capture the Node IP from within the Pod?
推荐答案
使用 env: valueFrom: fieldRef: status.hostIP
;整个(?)列表显示在 envVarSource
文档,我想是因为objectFieldSelector
可以出现在多个上下文中.
Yes, easily, using the env: valueFrom: fieldRef: status.hostIP
; the whole(?) list is presented in the envVarSource
docs, I guess because objectFieldSelector
can appear in multiple contexts.
如此:
containers:
- env:
- name: NODE_IP
valueFrom:
fieldRef:
status.hostIP
这篇关于如何从Pod内部获取节点IP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!