排查 Pod 一直 Terminating
有时候删除 Pod 一直卡在 Terminating 状态,一直删不掉,本文给出排查思路与可能原因。 分析思路 Pod 处于 Terminating 状态说明 Pod 是被删除,但一直无法结束。 Pod 被删除主要可能是: 用户主动删除的 Pod。 工作负载在滚动更新,自动删除的 Pod。 触发了节点驱逐,自动清理的 Pod。 节点长时间处于 <font style="color:rgb(28, 30, 33);">NotReady</font> 状态,Pod 被自动删除以便被重新调度。 Pod 被删除的流程: APIServer 收到删除 Pod 的请求,Pod 被标记删除,处于 <font style="color:rgb(28, 30, 33);">Terminating</font> 状态。 节点上的 kubelet watch 到了 Pod 被删除,开始销毁 Pod。 Kubelet 调用运行时接口,清理相关容器。 所有容器销毁成功,通知...
排查 Pod 一直 Pending
Pod 一直 Pending 一般是调度失败,通常我们可以通过 describe 来看下 event 来判断 pending 原因: 123456$ kubectl describe pod tikv-0...Events: Type Reason Age From Message ---- ------ ---- ---- ------- Warning FailedScheduling 3m (x106 over 33m) default-scheduler 0/4 nodes are available: 1 node(s) had no available volume zone, 2 Insufficient cpu, 3 Insufficient memory. 任何节点中都没有足够的资源来分配 pod Kubernetes 会根据 Pod 的 Request...
排查 device or resource busy
背景 在 kubernetes 环境中,可能会遇到因目录被占用导致 pod 一直 terminating: 1Aug 27 15:52:22 VM-244-70-centos kubelet[906978]: E0827 15:52:22.816125 906978 nestedpendingoperations.go:270] Operation for "\"kubernetes.io/secret/b45f3af4-3574-472e-b263-c2b71c3b2ea0-default-token-fltdk\" (\"b45f3af4-3574-472e-b263-c2b71c3b2ea0\")" failed. No retries permitted until 2021-08-27 15:54:24.816098325 +0800 CST m=+108994.575932846 (durationBeforeRetry 2m2s). Error:...
使用 wireshark 分析数据包
分析 DNS 异常 找出没有收到响应的 dns 请求 1dns && (dns.flags.response == 0) && ! dns.response_in 根据 dns 请求 id 过滤 1dns.id == 0xff0b 找出慢响应 超过 100 ms 的响应: 1dns.flags.rcode eq 0 and dns.time gt .1 过滤 NXDomain 的响应 所有 `No such name` 的响应: 1dns.flags.rcode == 3 排除集群内部 service: 1((dns.flags.rcode == 3) && !(dns.qry.name contains ".local") && !(dns.qry.name contains ".svc") && !(dns.qry.name contains...
使用 tcpdump 抓包与分析
抓包基础 12345678# 抓包内容实时显示到控制台tcpdump -i eth0 host 10.0.0.10 -nn -tttttcpdump -i any host 10.0.0.10 -nn -tttttcpdump -i any host 10.0.0.10 and port 8088 -nn -tttt# 抓包存到文件tcpdump -i eth0 -w test.pcap# 读取抓包内容tcpdump -r test.pcap -nn -tttt 常用参数: <font style="color:rgb(28, 30, 33);">-r</font>: 指定包文件。 <font style="color:rgb(28, 30, 33);">-nn</font>: 显示数字ip和端口,不转换成名字。 <font style="color:rgb(28, 30, 33);">-tttt</font>: 显示时间戳格式:...
使用 Systemtap 定位疑难杂症
安装 Ubuntu 安装 systemtap: 1apt install -y systemtap 运行 <font style="color:rgb(28, 30, 33);">stap-prep</font> 检查还有什么需要安装: 1234567$ stap-prepPlease install linux-headers-4.4.0-104-genericYou need package linux-image-4.4.0-104-generic-dbgsym but it does not seem to be available Ubuntu -dbgsym packages are typically in a separate repository Follow https://wiki.ubuntu.com/DebuggingProgramCrash to add this repositoryapt install -y linux-headers-4.4.0-104-generic 提示需要 dbgsym...
Linux 常用排查命令
查看 socket buffer 查看是否阻塞: 123$ netstat -antup | awk '{if($2>100||$3>100){print $0}}'Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program nametcp 2066 36 9.134.55.160:8000 10.35.16.97:63005 ESTABLISHED 1826655/nginx <font style="color:rgb(28, 30, 33);">Recv-Q</font> 是接收队列,如果持续有堆积,可能是高负载,应用处理不过来,也可能是程序的 bug,卡住了,导致没有从 buffer 中取数据,可以看看对应 pid 的 stack 卡在哪里了(<font...
使用 ksniff 远程抓包 副本
概述 Kubernetes 环境中遇到网络问题需要抓包排查怎么办?传统做法是登录 Pod 所在节点,然后 [使用 nsenter 进入 Pod netns 抓包](https://imroc.cc/kubernetes-troubleshooting/skill/enter-netns-with-nsenter),最后使用节点上 tcpdump 工具进行抓包。整个过程比较繁琐,好在社区出现了 [ksniff](https://github.com/eldadru/ksniff) 这个小工具,它是一个 kubectl 插件,可以让我们在 Kubernetes 中抓包变得更简单快捷。 本文将介绍如何使用 ksniff 这个工具来对 Pod 进行抓包。 安装 ksniff 一般使用 [krew](https://github.com/kubernetes-sigs/krew) 这个 kubectl 包管理器进行安装: 1kubectl krew install sniff 使用 wireshark 实时分析 抓取指定 Pod 所有网卡数据包,自动弹出本地安装的...
使用 nsenter 进入 netns 抓包
背景 我们使用 Kubernetes 时难免发生一些网络问题,往往需要进入容器的网络命名空间 (netns) 中,进行一些网络调试来定位问题,本文介绍如何进入容器的 netns。 获取容器 ID 使用 kubectl 获取 pod 中任意 cotnainer 的 id: 1kubectl -n test describe pod debug-685b48bcf5-ggn5d 输出示例片段1 (containerd运行时): 123Containers: debug: Container ID: containerd://529bbd5c935562a9ba66fc9b9ffa95d486c6324f26d8253d744ffe3dfd728289 输出示例片段2 (dockerd运行时): 123Containers: debug: Container ID: docker://e64939086488a9302821566b0c1f193b755c805f5ff5370d5ce5e6f154ffc648 获取 PID 拿到 container...
Hello World
Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub. Quick StartCreate a new post1$ hexo new "My New Post" More info: Writing Run server1$ hexo server More info: Server Generate static files1$ hexo generate More info: Generating Deploy to remote sites1$ hexo deploy More info: Deployment