Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you get the Node IP from inside a Pod?

Tags:

kubernetes

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.

Is there a way to capture the Node IP from within the Pod?

like image 745
frederix Avatar asked Aug 27 '18 21:08

frederix


People also ask

Do pods have IP addresses?

Each Pod has a single IP address assigned from the Pod CIDR range of its node. This IP address is shared by all containers running within the Pod, and connects them to other Pods running in the cluster. Each Service has an IP address, called the ClusterIP, assigned from the cluster's VPC network.


1 Answers

The accepted answer didn't work for me, it seems fieldPath is required now:

  env:
    - name: NODE_IP
      valueFrom:
        fieldRef:
          fieldPath: status.hostIP
like image 184
Nick Avatar answered Oct 26 '22 21:10

Nick