当前位置:网站首页>Use nsenter to enter netns to capture packets
Use nsenter to enter netns to capture packets
2022-06-10 09:51:00 【Dress Dance morning breeze】
background
We use Kubernetes Some network problems are inevitable , It is often necessary to enter the network namespace of the container (netns) in , Do some network debugging to locate the problem , This article describes how to enter the container netns.
Get the container ID
Use kubectl obtain pod In any cotnainer Of id:
kubectl -n test describe pod debug-685b48bcf5-ggn5d
Output sample clip 1 (containerd Runtime ):
Containers:
debug:
Container ID: containerd://529bbd5c935562a9ba66fc9b9ffa95d486c6324f26d8253d744ffe3dfd728289
Output sample clip 2 (dockerd Runtime ):
Containers:
debug:
Container ID: docker://e64939086488a9302821566b0c1f193b755c805f5ff5370d5ce5e6f154ffc648
obtain PID
Get container id after , We log in to pod Get its main process from the node pid.
containerd Run time usage crictl Command acquisition :
$ crictl inspect 529bbd5c935562a9ba66fc9b9ffa95d486c6324f26d8253d744ffe3dfd728289 | grep -i pid
"pid": 2266462,
"pid": 1
"type": "pid"
In this case pid by 2266462
dockerd Run time usage docker Command acquisition :
$ docker inspect e64939086488a9302821566b0c1f193b755c805f5ff5370d5ce5e6f154ffc648 | grep -i pid
"Pid": 910351,
"PidMode": "",
"PidsLimit": 0,
In this case pid by 910351
Use nsenter Into the container netns
Use... On nodes nsenter Get into pod Of netns:
nsenter -n --target 910351
Debug network
Successfully entered the netns, You can use the network tools on the node to debug the network , You can use... First ip a To validate the ip Whether the address is pod ip:
$ 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
3: eth0[email protected]: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
link/ether 6a:c6:6f:67:dd:6c brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 172.18.0.67/26 brd 172.18.0.127 scope global eth0
valid_lft forever preferred_lft forever
Original address :https://imroc.cc/kubernetes/troubleshooting/skill/network/enter-netns-with-nsenter.html#%E4%BD%BF%E7%94%A8-nsenter-%E8%BF%9B%E5%85%A5-netns-%E6%8A%93%E5%8C%85
边栏推荐
猜你喜欢

Radiolisttile is displayed in row of the shutter

Only this is the most true reason why leaders promote you. The rest is nonsense!

月赛50 F 鸡尾酒数(思维)

【高考季征文】高考那些事儿,作为过来人我有话要说

“胡说八道” DATABASE 主键设计

Pointnet: deep learning on point sets for 3D classi "location and segmentation

HMM详细介绍+举例

联调这夜,我把同事打了...

【timm】一个基于pytorch的图像模型库

基于深度学习的商品推荐系统(Web)
随机推荐
Mysql database (26): View
并发-创建线程
The R language coin package is applied to permutation tests for independence problems, one-way ANOVA and approximate k-sample permutation tests on the same data set, and comparing whether the mean val
收藏 | VLOOKUP函数的这些妙用你都知道吗?
How to handle art record? What materials should be prepared for handling the art record?
China in Classics - I
MySQL字符集utf8mb4与utf8的区别
Only this is the most true reason why leaders promote you. The rest is nonsense!
[dark horse morning post] ant group has no IPO plan yet; Weiya's husband set up a new live broadcasting company; CEO of Weibo questioned SF; JD will pilot the catering takeout business; Tencent's tale
Comparison between rancher and kubesphere
Concurrency - create thread
【边缘检测】基于matlab八方向sobel图像边缘检测【含Matlab源码 1865期】
jqGrid表格部分处理方法:
R language plot visualization: plot to visualize the overlapped normalized histogram (distplot with normal distribution), add the density curve KDE in the histogram, and add the whisker graph at the b
聯調這夜,我把同事打了...
R language uses lmperm package to apply to the replacement method (replacement test and permutation tests) of linear model, uses LM model to build polynomial regression model, and uses LMP function to
Stream stream overview
R create folders and subfolders
Genius! Only use four integers to write a snake game!
天才啊!仅用四个整数编写一个贪吃蛇游戏!