背景:有时候k8s集群有问题需要验证各个组件是否正常运行时,需要用busybox镜像工具来验证!

 busybox: BusyBox 是一个集成了三百多个最常用Linux命令和工具的软件。BusyBox 包含了一些简单的工具,例如ls、cat和echo等等,还包含了一些更大、更复杂的工具,例grep、find、mount以及telnet。有些人将 BusyBox 称为 Linux 工具里的瑞士军刀。简单的说BusyBox就好像是个大工具箱,它集成压缩了 Linux 的许多工具和命令,也包含了 Linux 系统的自带的shell

1.运行busybox进入互交

kubectl run -it test --rm  --image=radial/busyboxplus:curl -n kube-system #进入kube-system 调试

1.1 验证coredns 是否解析成功:

#同一个名称空间下:

[ root@test:/ ]$ nslookup nginx-deployment
Server: 10.96.0.10
Address 1: 10.96.0.10 kube-dns.kube-system.svc.cluster.local

Name: nginx-deployment
Address 1: 10.107.150.167 nginx-deployment.kube-system.svc.cluster.local

#不同名称空间下

root@nginx-6799fc88d8-6hbp9:/# nslookup metrics-server.kube-system.svc.cluster.local
Server: 10.96.0.10
Address: 10.96.0.10#53

Name: metrics-server.kube-system.svc.cluster.local
Address: 10.96.0.254

[ root@test:/ ]$

1.2  验证 kube-proxy:

[ root@test:/ ]$ curl http://nginx-deployment
2021-08-29
[ root@test:/ ]$

1.3 验证 pod 内网

kube-system 空间:

[ root@test:/ ]$ ping 172.168.154.202
PING 172.168.154.202 (172.168.154.202): 56 data bytes
64 bytes from 172.168.154.202: seq=0 ttl=62 time=0.455 ms
64 bytes from 172.168.154.202: seq=1 ttl=62 time=0.566 ms

default 空间:

[ root@test:/ ]$ ping 10.96.0.1
PING 10.96.0.1 (10.96.0.1): 56 data bytes
64 bytes from 10.96.0.1: seq=0 ttl=64 time=0.063 ms
64 bytes from 10.96.0.1: seq=1 ttl=64 time=0.064 ms
64 bytes from 10.96.0.1: seq=2 ttl=64 time=0.068 ms
64 bytes from 10.96.0.1: seq=3 ttl=64 time=0.061 ms

 

posted on 2021-09-01 12:16  MhaiM  阅读(502)  评论(0编辑  收藏  举报