I want to get the host MAC address in kubernetes pod where that pod runing on

9/19/2019

I want to get the MAC address of the host in the POD, the POD network doesn't use hostnetwork. I found that the node UID's suffix is the host' MAC address and I want to find the source where this UID value get from?

The suffix of uid (525400a9edd3) is the MAC address(ether 52:54:00:a9:ed:d3) of that host?

kubectl get nodes node1 -o yaml
apiVersion: v1
kind: Node
metadata:
...
  uid: 96557f0f-fea6-11e8-b826-525400a9edd3
...
ifconfig eth0
        eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.16.68.1  netmask 255.255.0.0  broadcast 172.16.255.255
        inet6 fe80::5054:ff:fea9:edd3  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:a9:ed:d3  txqueuelen 1000  (Ethernet)

Could you help me to find how node uid is created accros the source code?

I want to know the host MAC address in kubernetes pod where that pod runing on.

-- toper
kubernetes

1 Answer

9/19/2019

You can look at any of the solutions posted here to see where you can find the MAC address from your filesystem. Then you simply need to mount that file into your container using a hostpath volume, and read the info from there.

-- Alassane Ndiaye
Source: StackOverflow