MCPInstall

troubleshooting

Kubernetes 故障排查

Installs
62
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/chaterm/terminal-skills --skill troubleshooting
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads troubleshooting automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

Kubernetes 故障排查

概述

故障诊断、事件分析、资源调试等技能。

集群状态检查

节点状态

# 查看节点
kubectl get nodes
kubectl get nodes -o wide

# 节点详情
kubectl describe node node-name

# 节点资源使用
kubectl top nodes

# 节点条件
kubectl get nodes -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.conditions[?(@.type=="Ready")].status}{"\n"}{end}'

组件状态

# 查看组件状态
kubectl get componentstatuses
kubectl get cs

# 查看系统 Pod
kubectl get pods -n kube-system

# API Server 健康检查
kubectl get --raw='/healthz'
kubectl get --raw='/readyz'

Pod 故障排查

Pod 状态分析

# 查看 Pod 状态
kubectl get pods -o wide
kubectl get pods --field-selector status.phase!=Running

# Pod 详情
kubectl describe pod pod-name

# 查看事件
kubectl get events --sort-by='.lastTimestamp'
kubectl get events --field-selector involvedObject.name=pod-name

常见 Pod 状态

Pending

# 原因:资源不足、调度问题、PVC 未绑定

# 排查步骤
kubectl describe pod pod-name | grep -A 10 Events
kubectl describe pod pod-name | grep -A 5 "Conditions"

# 检查节点资源
kubectl describe nodes | grep -A 5 "Allocated resources"

# 检查 PVC
kubectl get pvc
kubectl describe pvc pvc-name

ImagePullBackOff

# 原因:镜像不存在、认证失败、网络问题

# 排查步骤
kubectl describe pod pod-name | grep -A 5 "Events"

# 检查镜像名
kubectl get pod pod-name -o jsonpath='{.spec.containers[*].image}'

# 检查 imagePullSecrets
kubectl get pod pod-name -o jsonpath='{.spec.imagePullSecrets}'

# 手动拉取测试
docker pull image-name

CrashLoopBackOff

# 原因:应用崩溃、配置错误、资源不足

# 查看日志
kubectl logs pod-name
kubectl logs pod-name --previous

# 查看退出码
kubectl describe pod pod-name | grep -A 5 "Last State"

# 检查资源限制
kubectl describe pod pod-name | grep -A 10 "Limits"

# 进入容器调试
kubectl exec -it pod-name -- sh

OOMKilled

# 原因:内存超限

# 查看退出原因
kubectl describe pod pod-name | grep -i oom

# 查看资源使用
kubectl top pod pod-name

# 增加内存限制
kubectl set resources deployment/deploy-name --limits=memory=512Mi

网络故障排查

Service 连通性

# 检查 Service
kubectl get svc service-name
kubectl describe svc service-name

# 检查 Endpoints
kubectl get endpoints service-name

# 测试连通性
kubectl run test --rm -it --image=busybox -- sh
wget -qO- http://service-name:port
nslookup service-name

DNS 排查

# 检查 CoreDNS
kubectl get pods -n kube-system -l k8s-app=kube-dns
kubectl logs -n kube-system -l k8s-app=kube-dns

# DNS 测试
kubectl run test --rm -it --image=busybox -- nslookup kubernetes
kubectl run test --rm -it --image=busybox -- nslookup service-name.namespace.svc.cluster.local

网络策略

# 查看网络策略
kubectl get networkpolicy
kubectl describe networkpolicy policy-name

# 测试网络连通
kubectl run test --rm -it --image=nicolaka/netshoot -- bash
curl -v http://service-name:port

存储故障排查

PV/PVC 问题

# 查看 PV/PVC
kubectl get pv
kubectl get pvc
kubectl describe pvc pvc-name

# 常见问题
# - PVC Pending: 没有匹配的 PV
# - PV Released: 需要手动回收或删除

# 检查 StorageClass
kubectl get storageclass
kubectl describe storageclass sc-name

挂载问题

# 查看挂载
kubectl describe pod pod-name | grep -A 10 "Volumes"

# 检查 Pod 内挂载
kubectl exec pod-name -- df -h
kubectl exec pod-name -- ls -la /mount/path

资源问题排查

资源配额

# 查看配额
kubectl get resourcequota -n namespace
kubectl describe resourcequota quota-name

# 查看 LimitRange
kubectl get limitrange -n namespace
kubectl describe limitrange limit-name

资源使用

# Pod 资源使用
kubectl top pods
kubectl top pods --containers

# 节点资源使用
kubectl top nodes

# 资源请求/限制
kubectl describe pod pod-name | grep -A 10 "Requests"

日志收集

容器日志

# 当前日志
kubectl logs pod-name
kubectl logs pod-name -c container-name

# 历史日志
kubectl logs pod-name --previous

# 实时日志
kubectl logs -f pod-name --since=1h

# 多 Pod 日志
kubectl logs -l app=nginx --all-containers

系统日志

# kubelet 日志
journalctl -u kubelet -f

# 容器运行时日志
journalctl -u containerd -f
journalctl -u docker -f

# API Server 日志
kubectl logs -n kube-system kube-apiserver-master

调试工具

kubectl debug

# 调试 Pod
kubectl debug pod-name -it --image=busybox --target=container-name

# 复制 Pod 调试
kubectl debug pod-name -it --copy-to=debug-pod --container=debug --image=nicolaka/netshoot

# 节点调试
kubectl debug node/node-name -it --image=busybox

临时调试 Pod

# 网络调试
kubectl run netshoot --rm -it --image=nicolaka/netshoot -- bash

# DNS 调试
kubectl run dnsutils --rm -it --image=gcr.io/kubernetes-e2e-test-images/dnsutils -- sh

# 通用调试
kubectl run debug --rm -it --image=busybox -- sh

常见场景

场景 1:应用无法访问

# 1. 检查 Pod 状态
kubectl get pods -l app=myapp

# 2. 检查 Service
kubectl get svc myapp-service
kubectl get endpoints myapp-service

# 3. 检查 Ingress
kubectl get ingress
kubectl describe ingress myapp-ingress

# 4. 测试连通性
kubectl run test --rm -it --image=busybox -- wget -qO- http://myapp-service

场景 2:Pod 调度失败

# 1. 查看 Pod 事件
kubectl describe pod pod-name | grep -A 20 Events

# 2. 检查节点资源
kubectl describe nodes | grep -A 10 "Allocated resources"

# 3. 检查污点和容忍
kubectl describe nodes | grep Taints
kubectl get pod pod-name -o yaml | grep -A 5 tolerations

# 4. 检查亲和性
kubectl get pod pod-name -o yaml | grep -A 20 affinity

场景 3:集群证书问题

# 检查证书过期
kubeadm certs check-expiration

# 更新证书
kubeadm certs renew all

# 检查 API Server 证书
openssl x509 -in /etc/kubernetes/pki/apiserver.crt -noout -dates

故障排查清单

问题类型排查命令
Pod 状态kubectl describe pod, kubectl logs
网络问题kubectl get svc/ep, DNS 测试
存储问题kubectl get pv/pvc, kubectl describe
资源问题kubectl top, kubectl describe quota
调度问题kubectl describe pod, 检查节点资源
认证问题检查 ServiceAccount, RBAC

FAQ

What does the troubleshooting skill do?

Kubernetes 故障排查

How do I install troubleshooting?

Run npx skills add https://github.com/chaterm/terminal-skills --skill troubleshooting in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/troubleshooting/ (personal) or .claude/skills/troubleshooting/ (project).

Which AI agents can use troubleshooting?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is troubleshooting safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains troubleshooting?

It is published by chaterm in chaterm/terminal-skills. It has 62 recorded installs.

More from chaterm/terminal-skills

View all →

cron

chaterm/terminal-skills

定时任务管理

1.3K installs

system-admin

chaterm/terminal-skills

Linux system administration and monitoring

DevOps & Cloud561 installs

systemd

chaterm/terminal-skills

Open the skill to read its SKILL.md instructions.

253 installs

network-tools

chaterm/terminal-skills

Open the skill to read its SKILL.md instructions.

217 installs

vpn

chaterm/terminal-skills

Open the skill to read its SKILL.md instructions.

193 installs

ssh

chaterm/terminal-skills

SSH 管理与安全

147 installs

Popular devops & cloud skills

View category →

microsoft-foundry

microsoft/azure-skills

Build, deploy, evaluate, optimize, fine-tune, and manage Microsoft Foundry agents, models, and resources end to end. USE FOR: foundry, azd ai agent, azd provision/deploy, hosted agent scaffold/develop/run/deploy/troubleshoot, prompt agent create, managed harness agent create, GitHub Copilot harness agent, create agent, update agent, add tool to agent, invoke agent, agent insights, evaluate agent, batch eval, continuous eval, continuous monitoring, agent CI/CD, optimize prompt, improve prompt, optimize agent instructions, Agent Optimizer scaffold, dataset curation from traces, deploy model, model fine-tuning (SFT/DPO/RFT), Foundry project, RBAC, role assignment, permissions, quota, capacity, region, deployment failure, AI Services, create Foundry resource, knowledge index, customize deployment, onboard, availability, training-data, grader, distillation, large file upload. DO NOT USE FOR: Azure Functions, App Service, general Azure deploy (use azure-deploy), general Azure prep (use azure

OfficialDevOps & Cloud579.1K installs

azure-diagnostics

microsoft/azure-skills

Debug Azure production issues on Azure using AppLens, Azure Monitor, resource health, and safe triage. WHEN: debug production issues, troubleshoot app service, app service high CPU, app service deployment failure, troubleshoot container apps, container app 503 or target port mismatch, troubleshoot functions, function telemetry missing or stopped after a config/connection-string change, troubleshoot AKS, VM RDP, Linux SSH, VM black screen, can't connect to VM, reset VM password, NSG or firewall blocking, kubectl cannot connect, kube-system/CoreDNS failures, pod pending, crashloop, node not ready, upgrade failures, analyze logs, KQL, insights, image pull failures, cold start issues, health probe failures, resource health, root cause of errors, troubleshoot event hubs, troubleshoot service bus, messaging SDK error, AMQP connection failure, message lock lost, lock renewal during long-running processing, service bus dead letter.

OfficialDevOps & Cloud569.8K installs

azure-prepare

microsoft/azure-skills

Prepare azd-based Azure projects for deployment: generates azure.yaml, infrastructure (Bicep/Terraform), and Dockerfiles for the Azure Developer CLI (azd) workflow. USE ONLY when the user explicitly wants to use azd as the deployment tool, or the project already has an azure.yaml file. DO NOT USE FOR: non-azd deployments, Python App Service code-only deploys (use python-appservice-deploy), or cross-cloud migration (use azure-cloud-migrate). WHEN: prepare app for azd, create azure.yaml, set up azd infrastructure, modernize app for Azure with azd, deploy with azd, function app, timer trigger, service bus trigger, event-driven function, managed identity, generate Bicep, generate Terraform, create and deploy to Azure.

OfficialDevOps & Cloud569K installs

azure-ai

microsoft/azure-skills

Use for Azure AI: Search, Speech, OpenAI, Document Intelligence. Helps with search, vector/hybrid search, speech-to-text, text-to-speech, transcription, OCR. WHEN: AI Search, query search, vector search, hybrid search, semantic search, speech-to-text, text-to-speech, transcribe, OCR, convert text to speech.

OfficialDevOps & Cloud568.8K installs

azure-deploy

microsoft/azure-skills

Execute Azure deployments for ALREADY-PREPARED applications that have existing .azure/deployment-plan.md and infrastructure files. DO NOT use this skill when the user asks to CREATE a new application — use azure-prepare instead. This skill runs azd up, azd deploy, terraform apply, and az deployment commands with built-in error recovery. Requires .azure/deployment-plan.md from azure-prepare and validated status from azure-validate. WHEN: "run azd up", "run azd deploy", "execute deployment", "push to production", "push to cloud", "go live", "ship it", "bicep deploy", "terraform apply", "publish to Azure", "launch on Azure". DO NOT USE WHEN: "create and deploy", "build and deploy", "create a new app", "set up infrastructure", "create and deploy to Azure using Terraform" — use azure-prepare for these.

OfficialDevOps & Cloud568.6K installs

azure-validate

microsoft/azure-skills

Pre-deployment validation for Azure readiness. Run deep checks on configuration, infrastructure (Bicep or Terraform), RBAC role assignments, managed identity permissions, and prerequisites before deploying. WHEN: validate my app, check deployment readiness, run preflight checks, verify configuration, check if ready to deploy, validate azure.yaml, validate Bicep, test before deploying, troubleshoot deployment errors, validate Azure Functions, validate function app, validate serverless deployment, verify RBAC roles, check role assignments, review managed identity permissions, what-if analysis, validate Container Apps deployment.

OfficialDevOps & Cloud568K installs