首页 > 其他分享 >在k8s集群中,如何知道某个pod ip段,是属于哪个主机的?

在k8s集群中,如何知道某个pod ip段,是属于哪个主机的?

时间:2023-03-23 14:00:42浏览次数:63  
标签:node 16 ip proto dev nccztsjb pod k8s 172.23


问题:你如何才能知道,k8s集群中,某个pod网段是属于节点的?

 

有两种方法,可以轻松获取到pod网段所在的主机信息...

 

方法 一 :通过kubectl get pod -o wide来查看

[root@nccztsjb-node-16 ~]# kubectl get pod -A  -o wide | grep 172.23.106
kube-system            coredns-6bd4c84698-tmnkd                                1/1     Running   0          13d    172.23.106.1    nccztsjb-node-16   <none>           <none>
kube-system            dns-autoscaler-5556d9d664-p52v4                         1/1     Running   0          13d    172.23.106.2    nccztsjb-node-16   <none>           <none>
kube-system            kube-eventer-5897cc5f78-nf4f2                           1/1     Running   0          13d    172.23.106.19   nccztsjb-node-16   <none>           <none>
kube-system            kubernetes-cronhpa-controller-6cdbbf9d7f-tgsk6          1/1     Running   0          13d    172.23.106.22   nccztsjb-node-16   <none>           <none>
kube-system            metrics-server-6c86bfbc9c-d6h9j                         2/2     Running   1          3d2h   172.23.106.27   nccztsjb-node-16   <none>           <none>
kube-system            monitor-agent-r5qph                                     1/1     Running   0          13d    172.23.106.12   nccztsjb-node-16   <none>           <none>
kube-system            redis-commander-7f885d97bc-9z5dq                        1/1     Running   0          13d    172.23.106.21   nccztsjb-node-16   <none>           <none>
kuboard                kuboard-agent-2-866c9f9d97-r62rs                        1/1     Running   2          13d    172.23.106.9    nccztsjb-node-16   <none>           <none>
kuboard                kuboard-agent-5949665f49-7crwc                          1/1     Running   2          13d    172.23.106.10   nccztsjb-node-16   <none>           <none>
kuboard                kuboard-questdb-5bf9ccf6c9-ws8gg                        1/1     Running   0          13d    172.23.106.13   nccztsjb-node-16   <none>           <none>
kuboard                kuboard-v3-7cdff587cf-t9ztn                             1/1     Running   0          13d    172.23.106.6    nccztsjb-node-16   <none>           <none>
logging                log-fluentd-nwrbs                                       1/1     Running   0          13d    172.23.106.18   nccztsjb-node-16   <none>           <none>
minio-default-tenant   minio-default-tenant-console-85c5d55578-gjz6n           1/1     Running   0          13d    172.23.106.15   nccztsjb-node-16   <none>           <none>
minio-default-tenant   minio-default-tenant-ss-0-2                             1/1     Running   0          13d    172.23.106.14   nccztsjb-node-16   <none>           <none>
yks                    autoops-568487d9d5-p6j7g                                1/1     Running   0          13d    172.23.106.8    nccztsjb-node-16   <none>           <none>
yks                    nfs-client-provisioner-79598fb9c9-dnpwk                 1/1     Running   0          13d    172.23.106.7    nccztsjb-node-16   <none>           <none>
yonbip                 iuap-devops-console-7f5b445b45-hzfbl                    1/1     Running   0          13d    172.23.106.26   nccztsjb-node-16   <none>           <none>
yonbip                 iuap-yks-console-899bf7659-nfjqc                        1/1     Running   0          13d    172.23.106.24   nccztsjb-node-16   <none>           <none>
yonbip                 iuap-yks-manage-5cc4f4d7d5-ptrfv                        1/1     Running   0          13d    172.23.106.25   nccztsjb-node-16   <none>           <none>
yonbip                 iuap-ypr-56694bcdb9-gn8lc                               1/1     Running   0          13d    172.23.106.20   nccztsjb-node-16   <none>           <none>
[root@nccztsjb-node-16 ~]# 

 

 

 

左面的一列是pod的ip,右面的一列是所在的主机节点

 

 

方法 二:通过在某个calico节点上,查看路由信息

[root@iuap120 ~]# ip r
default via 172.16.8.254 dev eth0 proto static metric 100 
172.16.8.0/24 dev eth0 proto kernel scope link src 172.16.8.120 metric 100 
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown 
172.23.16.128/26 via 172.16.8.122 dev eth0 proto bird 
172.23.20.0/26 via 172.16.8.236 dev eth0 proto bird 
172.23.41.192/26 via 172.16.8.233 dev eth0 proto bird 
172.23.48.64/26 via 172.16.8.247 dev eth0 proto bird 
172.23.56.0/26 via 172.16.9.79 dev tunl0 proto bird onlink 
172.23.97.0/26 via 172.16.8.169 dev eth0 proto bird 
172.23.111.64/26 via 172.16.8.121 dev eth0 proto bird 
172.23.123.64/26 via 172.16.8.239 dev eth0 proto bird 
172.23.127.0/26 via 172.16.8.96 dev eth0 proto bird 
172.23.172.128/26 via 172.16.8.219 dev eth0 proto bird 
172.23.178.128/26 via 172.16.8.240 dev eth0 proto bird 
172.23.179.0/26 via 172.16.8.234 dev eth0 proto bird 
172.23.185.0/26 via 172.16.8.242 dev eth0 proto bird 
blackhole 172.23.191.192/26 proto bird 
172.23.191.211 dev calic4b6be6ed36 scope link 
172.23.191.212 dev cali7df11ab4fb9 scope link 
172.23.191.213 dev calif4b76ee927f scope link 
172.23.207.128/26 via 172.16.8.237 dev eth0 proto bird 
172.23.223.0/26 via 172.16.8.119 dev eth0 proto bird 
172.23.236.192/26 via 172.16.9.78 dev tunl0 proto bird onlink 
172.23.248.192/26 via 172.16.8.245 dev eth0 proto bird 
172.23.253.128/26 via 172.16.9.80 dev tunl0 proto bird onlink

 

 

左一列是pod网段信息,右面一列是所在的主机信息。

标签:node,16,ip,proto,dev,nccztsjb,pod,k8s,172.23
From: https://www.cnblogs.com/chuanzhang053/p/17247236.html

相关文章