<p>This on-liner work on k8s 1.20:</p>
<pre><code>kubectl -n kube-system get pod -l component=kube-apiserver -o=jsonpath=&quot;{.items[0].metadata.annotations.kubeadm\.kubernetes\.io/kube-apiserver\.advertise-address\.endpoint}&quot;
</code></pre>

CC BY-SA 4.0
2022-10-04T08:19:19.577Z
2022-10-04T08:19:19.577Z
Fabrice Jammes
<p>The apiserver runs on master nodes. To get a list of all the master node IP's, this should help-</p>

<pre><code>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}"
</code></pre>

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

CC BY-SA 4.0
2018-11-13T15:38:38.210Z
2018-11-13T15:38:38.210Z
Gavin
<h1>Question</h1>

<p>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. </p>

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

<pre><code>$ 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 
</code></pre>

CC BY-SA 3.0
2017-12-13T19:43:50.780Z
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
CC BY-SA 4.0
2018-06-26T16:51:42.333Z
the api server is usually on your master node, do you know where that is?
Jeff Garrett
<kubernetes><networking>
How to identify the physical IP of where Kubernetes API server runs
mon
# How to identify the physical IP of where Kubernetes API server runs

(Asked by: username_0 on 2017-11-24)

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

**Tags:** kubernetes, networking

> **Comments:**
> **username_1**: 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?  
> **username_2**: the api server is usually on your master node, do you know where that is?  

---

## 2 answers

### Answer by username_3 on 2022-10-04. Score: 1

This on-liner work on k8s 1.20:
kubectl -n kube-system get pod -l component=kube-apiserver -o=jsonpath="{.items[0].metadata.annotations.kubeadm\.kubernetes\.io/kube-apiserver\.advertise-address\.endpoint}"


---

### Answer by username_4 on 2018-11-13. Score: 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.


---

