K8
k8s-debug
Kubernetes 應用程式除錯流程 (Pod Status, Logs, Events, Exec)
Install
mkdir -p .claude/skills/k8s-debug-vincent119 && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/14217" && unzip -o skill.zip -d .claude/skills/k8s-debug-vincent119 && rm skill.zipInstalls to .claude/skills/k8s-debug-vincent119
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Kubernetes 應用程式除錯流程 (Pod Status, Logs, Events, Exec)52 charsno explicit “when” trigger
About this skill
此工作流程將引導您排查與修復 Kubernetes 上的應用程式問題。
-
檢查 Pod 狀態 (Pod Status)
首先確認 Pod 是否正常運作,或處於錯誤狀態 (如 CrashLoopBackOff, ImagePullBackOff)。
kubectl get pods -o wide若發現問題 Pod,查看詳細資訊:
kubectl describe pod <POD_NAME> -
查看應用程式日誌 (Logs)
檢查容器輸出的標準日誌,尋找錯誤訊息或堆疊追蹤 (Stack Trace)。
kubectl logs <POD_NAME> # 若 Pod 包含多個容器,需指定容器名稱 # kubectl logs <POD_NAME> -c <CONTAINER_NAME>若 Pod 不斷重啟,查看上一輪的崩潰日誌:
kubectl logs <POD_NAME> --previous -
檢查叢集事件 (Events)
查看 Namespace 中的事件,了解排程、掛載或健康檢查失敗的原因。
kubectl get events --sort-by=.lastTimestamp -
進入容器除錯 (Exec)
若需檢查檔案系統、環境變數或網路連線,可直接進入容器。
kubectl exec -it <POD_NAME> -- sh # 或 kubectl exec -it <POD_NAME> -- bash- 檢查環境變數:
env - 檢查網路連線:
curl localhost:8080或nc -zv <HOST> <PORT>
- 檢查環境變數:
-
本地端口轉發 (Port Forwarding)
將 Pod 端口轉發到本地,以便使用瀏覽器或 Postman 進行測試。
kubectl port-forward <POD_NAME> 8080:8080 -
資源使用量監控 (Top)
檢查 Pod 是否因 OOM (Out of Memory) 或 CPU 節流而導致效能問題。
kubectl top pod <POD_NAME>