终极指南:如何使用StreamCap轻松录制40+平台直播内容
2026/5/24 10:29:24
适用人群:SRE / DevOps / 运维工程师
适用场景:Kubernetes 生产环境排障、网络/进程/资源问题快速定位
在实际生产环境中,我们常见的业务镜像往往具备以下特点:
alpine/debian-slim/distroless常见问题包括:
ps: command not foundss / netstat / top / free不存在生产镜像应该极简,但排障能力不能没有。
因此,一个Debug 专用镜像是 Kubernetes 运维体系中的必备组件。
一个合格的 Debug 镜像应满足:
工具齐全:
pstopssnetstattcpdumpfreeuptimevmstatcurlwgetbash系统稳定:
镜像可控:
仅用于排障,不承载业务
推荐使用:
debian:11ubuntu:22.04本文以Debian 11为例。
FROM debian:11 LABEL maintainer="sre@company.com" LABEL description="Kubernetes Debug Image" # 替换为大陆镜像源(阿里云) RUN sed -i 's@deb.debian.org@mirrors.aliyun.com@g' /etc/apt/sources.list \ && sed -i 's@security.debian.org@mirrors.aliyun.com/debian-security@g' /etc/apt/sources.list # 安装常用运维调试工具 RUN apt-get update && apt-get install -y \ procps \ iproute2 \ net-tools \ tcpdump \ curl \ wget \ vim \ less \ lsof \ strace \ bash \ && rm -rf /var/lib/apt/lists/* CMD ["bash"]| 分类 | 工具 | 用途 |
|---|---|---|
| 进程 | ps / top | 查看进程、CPU、内存 |
| 网络 | ss / netstat | 查看端口、连接状态 |
| 抓包 | tcpdump | 网络问题定位 |
| 系统 | free / uptime | 资源使用情况 |
| 文件 | lsof | 端口与进程映射 |
| 调试 | strace | 系统调用分析 |
docker build -t registry.example.com/ops/k8s-debug:debian11.docker push registry.example.com/ops/k8s-debug:debian11建议:
debian11/v1.0)kubectl debug pod/mx-devops-frontend\-it\--image=registry.example.com/ops/k8s-debug:debian11\--target=frontend特点:
apiVersion:v1kind:Podmetadata:name:debug-toolsspec:containers:-name:debugimage:registry.example.com/ops/k8s-debug:debian11command:["sleep","36000"]适合:
psauxwwss -lntplsof-i :3000tcpdump -i any port80成熟团队一定有 Debug 镜像,没有只是时间问题。
ps不存在 ≠ 系统有问题平时不用,但出事时必须能拿出来。
吐槽一下:
说好AI能更好效率工作,释放运维的工作,但是有些公司已经把非运维主要工作硬硬塞进来,已经成为了一个四不像了。