重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
kubectl-debugging by laurigates/claude-plugins
npx skills add https://github.com/laurigates/claude-plugins --skill kubectl-debugging使用 kubectl debug 调试 Kubernetes 资源的专业知识 - 临时容器、Pod 副本和节点访问。
kubectl debug 自动化常见的调试任务:
务必在每个 kubectl 命令中明确指定 --context:
# 正确:明确指定上下文
kubectl --context=prod-cluster debug mypod -it --image=busybox
# 错误:依赖当前上下文
kubectl debug mypod -it --image=busybox # 是哪个集群?
# 使用 busybox 进行交互式调试
kubectl --context=my-context debug mypod -it --image=busybox
# 目标指向特定容器的进程命名空间
kubectl --context=my-context debug mypod -it --image=busybox --target=mycontainer
# 使用特定的调试配置文件
kubectl --context=my-context debug mypod -it --image=busybox --profile=netadmin
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
# 创建调试副本
kubectl --context=my-context debug mypod -it --copy-to=mypod-debug --image=busybox
# 复制并更改容器镜像
kubectl --context=my-context debug mypod --copy-to=mypod-debug --set-image=app=busybox
# 复制并修改命令
kubectl --context=my-context debug mypod -it --copy-to=mypod-debug --container=myapp -- sh
# 在同一节点上复制
kubectl --context=my-context debug mypod -it --copy-to=mypod-debug --same-node --image=busybox
# 交互式节点调试(主机命名空间,文件系统位于 /host)
kubectl --context=my-context debug node/mynode -it --image=busybox
# 使用 sysadmin 配置文件以获得完整能力
kubectl --context=my-context debug node/mynode -it --image=ubuntu --profile=sysadmin
| 配置文件 | 使用场景 | 能力 |
|---|---|---|
legacy | 默认,无限制 | 完全访问(向后兼容) |
general | 通用目的 | 中等限制 |
baseline | 最小限制 | Pod 安全基线 |
netadmin | 网络故障排除 | NET_ADMIN 能力 |
restricted | 高安全环境 | 最严格的限制 |
sysadmin | 系统管理 | SYS_PTRACE, SYS_ADMIN |
# 网络调试(tcpdump, netstat, ss)
kubectl --context=my-context debug mypod -it --image=nicolaka/netshoot --profile=netadmin
# 系统调试(strace, perf)
kubectl --context=my-context debug mypod -it --image=ubuntu --profile=sysadmin
| 镜像 | 大小 | 使用场景 |
|---|---|---|
busybox | ~1MB | 基础 shell,常用工具 |
alpine | ~5MB | 带有 apk 包管理器的 shell |
ubuntu | ~77MB | 带有 apt 的完整 Linux |
nicolaka/netshoot | ~350MB | 网络调试(tcpdump, dig, curl, netstat) |
gcr.io/k8s-debug/debug | 可变 | 官方 Kubernetes 调试镜像 |
# 添加 netshoot 容器进行网络调试
kubectl --context=my-context debug mypod -it \
--image=nicolaka/netshoot \
--profile=netadmin
# 在容器内:
# - tcpdump -i any port 80
# - dig kubernetes.default
# - curl -v http://service:port
# - ss -tlnp
# - netstat -an
# 复制 Pod 并使用不同的入口点进行检查
kubectl --context=my-context debug mypod -it \
--copy-to=mypod-debug \
--container=app \
-- sh
# 内部:检查文件系统、环境变量、配置文件
# 目标容器的进程命名空间
kubectl --context=my-context debug mypod -it \
--image=busybox \
--target=mycontainer
# 内部:ps aux, /proc 检查
# 调试具有主机访问权限的节点
kubectl --context=my-context debug node/worker-1 -it \
--image=ubuntu \
--profile=sysadmin
# 内部:
# - 主机文件系统位于 /host
# - chroot /host 以获得完全访问权限
# - journalctl, systemctl, dmesg
# 创建副本,保持原始 Pod 运行
kubectl --context=my-context debug mypod -it \
--copy-to=mypod-debug \
--same-node \
--share-processes \
--image=busybox
# 原始 Pod 继续处理流量
# 如果在同一节点上,调试副本共享存储
| 选项 | 描述 |
|---|---|
-it | 交互式 TTY(shell 访问必需) |
--image | 调试容器镜像 |
--container | 调试容器的名称 |
--target | 与此容器共享进程命名空间 |
--copy-to | 创建副本而非临时容器 |
--same-node | 在同一节点上调度副本(与 --copy-to 一起使用) |
--set-image | 更改副本中的容器镜像 |
--profile | 安全配置文件(legacy, netadmin, sysadmin 等) |
--share-processes | 启用进程命名空间共享(默认:与 --copy-to 一起使用时为 true) |
--replace | 创建副本时删除原始 Pod |
--copy-to - 保留原始 Pod--same-node - 用于访问共享存储/网络条件# 列出调试 Pod 副本
kubectl --context=my-context get pods | grep -E "debug|copy"
# 删除调试 Pod
kubectl --context=my-context delete pod mypod-debug
有关详细选项参考、示例和故障排除模式,请参阅 REFERENCE.md。
每周安装次数
67
仓库
GitHub 星标数
23
首次出现
2026年1月29日
安全审计
已安装于
opencode65
gemini-cli63
codex63
github-copilot63
kimi-cli62
amp62
Expert knowledge for debugging Kubernetes resources using kubectl debug - ephemeral containers, pod copies, and node access.
kubectl debug automates common debugging tasks:
Always specify--context explicitly in every kubectl command:
# CORRECT: Explicit context
kubectl --context=prod-cluster debug mypod -it --image=busybox
# WRONG: Relying on current context
kubectl debug mypod -it --image=busybox # Which cluster?
# Interactive debugging with busybox
kubectl --context=my-context debug mypod -it --image=busybox
# Target specific container's process namespace
kubectl --context=my-context debug mypod -it --image=busybox --target=mycontainer
# Use a specific debug profile
kubectl --context=my-context debug mypod -it --image=busybox --profile=netadmin
# Create debug copy
kubectl --context=my-context debug mypod -it --copy-to=mypod-debug --image=busybox
# Copy and change container image
kubectl --context=my-context debug mypod --copy-to=mypod-debug --set-image=app=busybox
# Copy and modify command
kubectl --context=my-context debug mypod -it --copy-to=mypod-debug --container=myapp -- sh
# Copy on same node
kubectl --context=my-context debug mypod -it --copy-to=mypod-debug --same-node --image=busybox
# Interactive node debugging (host namespaces, filesystem at /host)
kubectl --context=my-context debug node/mynode -it --image=busybox
# With sysadmin profile for full capabilities
kubectl --context=my-context debug node/mynode -it --image=ubuntu --profile=sysadmin
| Profile | Use Case | Capabilities |
|---|---|---|
legacy | Default, unrestricted | Full access (backwards compatible) |
general | General purpose | Moderate restrictions |
baseline | Minimal restrictions | Pod security baseline |
netadmin | Network troubleshooting | NET_ADMIN capability |
restricted | High security environments |
# Network debugging (tcpdump, netstat, ss)
kubectl --context=my-context debug mypod -it --image=nicolaka/netshoot --profile=netadmin
# System debugging (strace, perf)
kubectl --context=my-context debug mypod -it --image=ubuntu --profile=sysadmin
| Image | Size | Use Case |
|---|---|---|
busybox | ~1MB | Basic shell, common utilities |
alpine | ~5MB | Shell with apk package manager |
ubuntu | ~77MB | Full Linux with apt |
nicolaka/netshoot | ~350MB | Network debugging (tcpdump, dig, curl, netstat) |
gcr.io/k8s-debug/debug | Varies |
# Add netshoot container for network debugging
kubectl --context=my-context debug mypod -it \
--image=nicolaka/netshoot \
--profile=netadmin
# Inside container:
# - tcpdump -i any port 80
# - dig kubernetes.default
# - curl -v http://service:port
# - ss -tlnp
# - netstat -an
# Copy pod with different entrypoint to inspect
kubectl --context=my-context debug mypod -it \
--copy-to=mypod-debug \
--container=app \
-- sh
# Inside: check filesystem, env vars, config files
# Target container's process namespace
kubectl --context=my-context debug mypod -it \
--image=busybox \
--target=mycontainer
# Inside: ps aux, /proc inspection
# Debug node with host access
kubectl --context=my-context debug node/worker-1 -it \
--image=ubuntu \
--profile=sysadmin
# Inside:
# - Host filesystem at /host
# - chroot /host for full access
# - journalctl, systemctl, dmesg
# Create copy, keeping original running
kubectl --context=my-context debug mypod -it \
--copy-to=mypod-debug \
--same-node \
--share-processes \
--image=busybox
# Original pod continues serving traffic
# Debug copy shares storage if on same node
| Option | Description |
|---|---|
-it | Interactive TTY (required for shell access) |
--image | Debug container image |
--container | Name for the debug container |
--target | Share process namespace with this container |
--copy-to | Create a copy instead of ephemeral container |
--same-node | Schedule copy on same node (with ) |
--copy-to for invasive debugging - Preserve original pod--same-node - For accessing shared storage/network conditions# List debug pod copies
kubectl --context=my-context get pods | grep -E "debug|copy"
# Delete debug pods
kubectl --context=my-context delete pod mypod-debug
For detailed option reference, examples, and troubleshooting patterns, see REFERENCE.md.
Weekly Installs
67
Repository
GitHub Stars
23
First Seen
Jan 29, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
opencode65
gemini-cli63
codex63
github-copilot63
kimi-cli62
amp62
Azure 升级评估与自动化工具 - 轻松迁移 Functions 计划、托管层级和 SKU
111,700 周安装
Go防御性编程模式指南:验证接口、复制切片、defer清理与枚举规范
323 周安装
Claude Code 上下文压缩恢复工具 - 自动恢复工作状态,加载知识库,总结工作进度
317 周安装
ts-agent-sdk:为AI代理生成类型化TypeScript SDK,简化MCP服务器交互
317 周安装
后端开发模式与架构设计:RESTful API、仓储模式、服务层与中间件最佳实践
317 周安装
现代Web开发全栈指南:TypeScript、Next.js 14、React、Supabase实战
318 周安装
Go控制流详解:if、for、switch语句与最佳实践
321 周安装
| Strictest restrictions |
sysadmin | System administration | SYS_PTRACE, SYS_ADMIN |
| Official Kubernetes debug image |
--copy-to--set-image | Change container images in copy |
--profile | Security profile (legacy, netadmin, sysadmin, etc.) |
--share-processes | Enable process namespace sharing (default: true with --copy-to) |
--replace | Delete original pod when creating copy |