其他分享
首页 > 其他分享> > Kubernetes Pod内没有工具怎么测试网络

Kubernetes Pod内没有工具怎么测试网络

作者:互联网

先获取容器pid

[root@ECS2 ~]# docker inspect 9eb8e8d053ba | grep -i pid

 

使用nsenter进入容器网络空间

[root@ECS2 ~]# nsenter -t 28279 -n /bin/bash

 

查看你就发现你在网络空间内了,并且使用的命令都是宿主机的

[root@ECS2 ~]# ifconfig 
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1480
        inet 10.20.71.213  netmask 255.255.255.255  broadcast 10.20.71.213
        ether 42:66:2f:19:c0:4a  txqueuelen 0  (Ethernet)
        RX packets 5  bytes 446 (446.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
  
[root@ECS2 ~]# netstat 
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags       Type       State         I-Node   Path
unix  3      [ ]         STREAM     CONNECTED     319784392 
unix  3      [ ]         STREAM     CONNECTED     319784391 
unix  3      [ ]         STREAM     CONNECTED     319784389 
unix  3      [ ]         STREAM     CONNECTED     319784390 

 

标签:errors,STREAM,Kubernetes,RX,bytes,overruns,unix,测试,Pod
来源: https://www.cnblogs.com/determined-K/p/15065158.html