1

Question

In a Kubernetes cluster, there is a Docker network IP which looks to be the API server. However, not sure how to identify the physical IP and location of the box in which it is working.

If there is a guidance how to proceed, it would be appreciated. I have been handed over the system but no information.

$ curl https://172.30.0.1
{
  "paths": [
    "/api",
    "/api/v1",
    "/apis",
    "/apis/apps",
    "/apis/apps/v1beta1",
    ...
  ]
}


$ kubectl get pods -o wide
NAME                    READY     STATUS    RESTARTS   AGE       IP
logging-fluentd-2vc4v   1/1       Running   0          1d        10.1.13.155
logging-fluentd-bvdtz   1/1       Running   0          1d        10.1.3.3
logging-fluentd-xvxrk   1/1       Running   0          1d        10.1.10.71    

$ sudo iptables -t nat -L -n
Chain KUBE-SERVICES (2 references)
target                     prot opt source               destination         
....
KUBE-SVC-NPX46M4PTMTKRN6Y  tcp  --  0.0.0.0/0            172.30.0.1           /* default/kubernetes:https cluster IP */ tcp dpt:443
KUBE-SVC-BA6I5HTZKAAAJT56  tcp  --  0.0.0.0/0            172.30.0.1           /* default/kubernetes:dns-tcp cluster IP */ tcp dpt:53
....


$ ip route
default via 10.0.4.1 dev eth0 proto static metric 100 
10.0.4.0/22 dev eth0 proto kernel scope link src 10.0.4.21 metric 100 
10.1.0.0/16 dev tun0 proto kernel scope link 
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 
172.30.0.0/16 dev tun0 scope link 
2
  • Based on the output of the ip route command the IP address of that machine is 10.0.4.21. Is that the address you're looking for? – Adrian Dec 13 '17 at 19:43
  • the api server is usually on your master node, do you know where that is? – Jeff Garrett Jun 26 '18 at 16:51
1

The apiserver runs on master nodes. To get a list of all the master node IP's, this should help-

kubectl -n kube-system get po | grep -i apiserver | cut -f1 -d" " | xargs kubectl -n kube-system get po $1 -o=jsonpath="{.items[*].status.hostIP}"

Based on the version of Kubernetes you are running, you might need to update the location of the hostIP in the jsonPath parameter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.