kubernetes 实用技巧: 进入容器 netns

 

 

 

 

 

 

 

 

root@ubuntu:~# kubectl get pod
NAME                                READY   STATUS             RESTARTS   AGE
debian-6c44fc6956-ltsrt             0/1     CrashLoopBackOff   4615       16d
mc1                                 2/2     Running            0          16d
my-deployment-68bdbbb5cc-bbszv      0/1     ImagePullBackOff   0          35d
my-deployment-68bdbbb5cc-nrst9      0/1     ImagePullBackOff   0          35d
my-deployment-68bdbbb5cc-rlgzt      0/1     ImagePullBackOff   0          35d
my-nginx-5dc4865748-jqx54           1/1     Running            2          35d
my-nginx-5dc4865748-pcrbg           1/1     Running            2          35d
nginx                               0/1     ImagePullBackOff   0          35d
nginx-deployment-6b474476c4-r6z5b   1/1     Running            0          8d
nginx-deployment-6b474476c4-w6xh9   1/1     Running            0          8d
web2-6d784f67bf-4gqq2               1/1     Running            0          19d
root@ubuntu:~# kubectl get ns
NAME              STATUS   AGE
default           Active   243d
kube-node-lease   Active   243d
kube-public       Active   243d
kube-system       Active   243d
kubeedge          Active   40d
root@ubuntu:~# kubectl -n  default     describe pod  my-nginx-5dc4865748-jqx54 | grep  Container
Containers:
    Container ID:   containerd://270994804d4c87638dcfd98a9ca1489f8c268998a0930cc5d3eef52887797777
  ContainersReady   True 
root@ubuntu:~# crictl inspect 270994804d4c87638dcfd98a9ca1489f8c268998a0930cc5d3eef52887797777 | grep -i pid
    "pid": 27134,
            "pid": 1
            "type": "pid" 
root@ubuntu:~# nsenter -n --target  27134
root@ubuntu:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
3: eth0@if641: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue state UP group default 
    link/ether fa:66:b3:ab:05:9f brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 10.244.0.19/24 brd 10.244.0.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::f866:b3ff:feab:59f/64 scope link 
       valid_lft forever preferred_lft forever
root@ubuntu:~# exit
logout
root@ubuntu:~# 

 

 

 

 

 

Kubernetes 问题定位技巧:容器内抓包

kubernetes 实用技巧: 进入容器 netns

上一篇:vmware虚拟机安装openSUSE-Leap-15.2全过程


下一篇:nginx+keepalived 主备搭建