一键导入
k8s-debug
Kubernetes debugging and troubleshooting workflows
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Kubernetes debugging and troubleshooting workflows
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
GitOps workflows with ArgoCD for Kubernetes deployments
AWS operations, queries, and resource management
Cloud cost analysis and optimization strategies
Docker container operations and debugging
Git workflows, branching strategies, and DevOps practices
Structured incident response and diagnosis workflows
| name | k8s-debug |
| description | Kubernetes debugging and troubleshooting workflows |
| homepage | https://kubernetes.io/docs/tasks/debug/ |
| metadata | {"emoji":"🔍","version":"1.0.0","author":"Gourav Shah","license":"MIT","requires":{"bins":["kubectl"]},"tags":["kubernetes","debugging","sre","troubleshooting"]} |
Expert guidance for diagnosing and resolving Kubernetes issues.
Use this skill when:
# All pods not in Running state
kubectl get pods -A | grep -v Running | grep -v Completed
# Pods in specific namespace
kubectl get pods -n <namespace> -o wide
# Detailed pod info
kubectl describe pod <pod-name> -n <namespace>
# Recent cluster events (sorted by time)
kubectl get events -A --sort-by='.lastTimestamp' | tail -20
# Events for specific pod
kubectl get events --field-selector involvedObject.name=<pod-name>
# Current logs
kubectl logs <pod-name> -n <namespace>
# Previous container logs (after crash)
kubectl logs <pod-name> -n <namespace> --previous
# Logs with timestamps
kubectl logs <pod-name> --timestamps
# Follow logs
kubectl logs <pod-name> -f
# Logs from specific container in multi-container pod
kubectl logs <pod-name> -c <container-name>
Symptoms: Pod repeatedly crashes and restarts.
Diagnosis:
# Check previous logs
kubectl logs <pod-name> --previous
# Check events
kubectl describe pod <pod-name> | grep -A 10 Events
# Check exit code
kubectl get pod <pod-name> -o jsonpath='{.status.containerStatuses[0].lastState.terminated.exitCode}'
Common Causes:
Symptoms: Container image cannot be pulled.
Diagnosis:
# Check image name and events
kubectl describe pod <pod-name> | grep -E "(Image|Events)" -A 5
Common Causes:
Fix:
# Create/update pull secret
kubectl create secret docker-registry regcred \
--docker-server=<registry> \
--docker-username=<user> \
--docker-password=<password>
Symptoms: Pod stays in Pending state.
Diagnosis:
# Check why pod is pending
kubectl describe pod <pod-name> | grep -A 5 "Events"
# Check node resources
kubectl describe nodes | grep -A 5 "Allocated resources"
# Check for taints
kubectl get nodes -o custom-columns=NAME:.metadata.name,TAINTS:.spec.taints
Common Causes:
Symptoms: Container killed due to memory limit.
Diagnosis:
# Check termination reason
kubectl get pod <pod-name> -o jsonpath='{.status.containerStatuses[0].lastState.terminated.reason}'
# Check memory limits vs requests
kubectl get pod <pod-name> -o jsonpath='{.spec.containers[0].resources}'
Fix:
# Node resource usage
kubectl top nodes
# Pod resource usage
kubectl top pods -A --sort-by=memory
# Pod resource usage in namespace
kubectl top pods -n <namespace>
# All pods with resources
kubectl get pods -A -o custom-columns=\
'NAMESPACE:.metadata.namespace,NAME:.metadata.name,CPU_REQ:.spec.containers[*].resources.requests.cpu,MEM_REQ:.spec.containers[*].resources.requests.memory,CPU_LIM:.spec.containers[*].resources.limits.cpu,MEM_LIM:.spec.containers[*].resources.limits.memory'
# Get service endpoints
kubectl get endpoints <service-name>
# Check if service has pods
kubectl get pods -l <service-selector>
# Test from inside cluster
kubectl run debug --rm -it --image=busybox -- wget -qO- http://<service>:<port>
# Test DNS resolution
kubectl run debug --rm -it --image=busybox -- nslookup <service-name>
# Check CoreDNS pods
kubectl get pods -n kube-system -l k8s-app=kube-dns
# Rolling restart (zero downtime)
kubectl rollout restart deployment/<name> -n <namespace>
# Check rollout status
kubectl rollout status deployment/<name> -n <namespace>
# Scale up/down
kubectl scale deployment/<name> --replicas=3 -n <namespace>
# Force delete (use with caution)
kubectl delete pod <pod-name> --grace-period=0 --force
kubectl get podskubectl get events --sort-by='.lastTimestamp'kubectl logs <pod>kubectl describe pod <pod>kubectl top pods