如何从Kubernetes配置中获取节点IP?

huangapple go评论50阅读模式
英文:

How to get node IP from kubernetes config?

问题

我尝试使用 status.hostIP,但它给我返回了"no value"。

spec:
  containers:
    - image: ...
      env:
        - name: 'hostIP'
          valueFrom:
            fieldRef:
              fieldPath: status.hostIP

你能帮帮我吗,拜托?

我还尝试过 status.HostIP

英文:

I tried to use status.hostIP ,but it gives me "no value"

spec:
  containers:
    - image : ...
      env:
        - name: 'hostIP'
          valueFrom:
            fieldRef:
              fieldPath: status.hostIP

Can you help me, please?

I also tried status.HostIP

答案1

得分: 1

你可以尝试在你的机器上运行以下命令:kubectl get pod,并加上选项 -o wide

英文:

probably you should try:
kubectl get pod command on your machine, with the option -o wide

答案2

得分: 1

So the answer was to add hostNetwork: true to pod spec.

英文:

So the answer was to add hostNetwork: true to pod spec

huangapple
  • 本文由 发表于 2023年2月6日 07:18:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/75356183.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定