跳到正文
Skillpedia
部署与云(DevOps)5.1k · #15047

k8s-debug-gpu-pod

它能做什么

它检查某个命名空间中的每个异常 Pod,并根据事件、调度、资源、镜像拉取和崩溃情况找出原因。适合在 Kubernetes 上运行 Pod 的人,包括 GPU Pod。

适用场景

  • ✓当某个 Kubernetes Pod 卡在 Pending 状态时。
  • ✓当某个 Pod 不断出现 CrashLoopBackOff 时。
  • ✓当某个 Pod 无法拉取镜像并显示 ImagePullBackOff 时。

技能链接

https://github.com/Project-HAMi/HAMi/blob/master/skill/k8s-debug-gpu-pod/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/Project-HAMi/HAMi/blob/master/skill/k8s-debug-gpu-pod/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“我的 gpu 命名空间里有些 Pod 卡在 Pending。请查明原因,并告诉我该怎么修。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会询问命名空间和集群上下文,查看所有 Pod 的状态,然后检查每个异常 Pod 的事件和详情,并报告每个 Pod 的根本原因。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Interaction

Collect the following from the user in a single exchange before starting diagnosis:

Input Required Default
Namespace Yes —
Kubeconfig file path No ~/.kube/config
Context name No current-context in the kubeconfig

If the user provides a cluster name instead of a context, fuzzy-match it against available contexts in the kubeconfig and confirm the match.

The skill automatically discovers and diagnoses all unhealthy pods (Pending, CrashLoopBackOff, ImagePullBackOff, Error) in the namespace. No pod name is needed.

Command Convention

All kubectl commands use shorthand below. Actual execution must always include explicit flags:

kubectl --kubeconfig=<kubeconfig> --context=<context> ...

Never rely on default kubeconfig or current-context.

Diagnostic Workflow

Step 1: Global Pod Overview

Get a full picture of all pod states in one command:

kubectl get pods -n <namespace> -o wide

Categorize pods into:

  • ✅ Running/Completed — healthy, skip
  • 🟡 Pending — go to Step 3
  • 🔴 CrashLoopBackOff/Error — go to Step 4
  • 🔴 ImagePullBackOff/ErrImagePull — go to Step 5
  • ⚠️ Other abnormal states — note for report

All unhealthy pods are diagnosed. No manual pod selection needed.

Step 2: Event Triage

Quick scan of recent warning events for immediate signal:

kubectl get events -n <namespace> --field-selector type=Warning --sort-by=.lastTimestamp | tail -50

Use events to guide which deep-dive steps are most relevant. Common event→action mapping:

Event Reason Points to
FailedScheduling Step 3 (Pending)
CrashLoopBackOff / BackOff Step 4 (Crash)
ImagePullBackOff / ErrImagePull Step 5 (Image)
OOMKilled Step 4 (Crash)
FailedAttachVolume / FailedMount PVC issue — note in report
Unhealthy Probe misconfiguration — note in report
Evicted Node pressure — note in report
NodeNotReady Infrastructure issue — note in report

Short-circuit rule: If events clearly point to a single root cause (e.g., all events are FailedScheduling with the same message), mark it as the confirmed primary cause but still scan remaining steps at reduced depth for additional findings.

Step 3: Pending Pod Root Cause Analysis

For each Pending pod:

kubectl describe pod <pod-name> -n <namespace>

Parse the Events and Conditions sections. Common causes:

Event Message Pattern Root Cause Remediation
Insufficient cpu / Insufficient memory Resource exhaustion Reduce requests, scale cluster, or check quota (→ Step 6)
0/N nodes are available + taint Taint/toleration mismatch Add toleration or untaint node
0/N nodes are available + node selector No matching nodes Fix nodeSelector or add matching nodes
0/N nodes are available + affinity Affinity rule unsatisfiable Relax affinity rules
persistentvolumeclaim "X" not found Missing PVC Create PVC or fix claim name
pod has unbound immediate PersistentVolumeClaims PVC not bound Check StorageClass and PV availability
exceeded quota Quota limit hit → Step 6

Step 4: CrashLoopBackOff / Error Diagnosis

Only execute if Step 1 found pods in CrashLoopBackOff or Error state.

A. Termination reason:

kubectl get pod <pod-name> -n <namespace> -o jsonpath='{.status.containerStatuses[*].lastState.terminated}'
Termination Reason Root Cause Remediation
OOMKilled Memory limit exceeded Increase memory limits, profile usage
exitCode 1 Application failure Check logs, configs, secrets, dependencies
exitCode 137 SIGKILL / OOM Check node pressure and memory
exitCode 139 Segfault Debug binary compatibility
exitCode 143 SIGTERM not handled Review graceful shutdown

B. Logs (current + previous):

kubectl logs <pod-name> -n <namespace> --tail=100
kubectl logs <pod-name> -n <namespace> --previous --tail=100

C. Resource config:

kubectl get pod <pod-name> -n <namespace> -o jsonpath='{.spec.containers[*].resources}' | jq .

D. Restart count:

kubectl get pod <pod-name> -n <namespace> -o jsonpath='{.status.containerStatuses[*].restartCount}'

High restart count (>5) combined with short uptime indicates persistent failure — check probes, dependencies, and startup ordering.

常见问题

我需要指定 Pod 名称吗?

不需要。该技能会自行找出命名空间中所有异常的 Pod。

它使用哪个集群?

使用你提供的 kubeconfig 和上下文;如果你都不提供,则使用 kubeconfig 中的默认设置。

它涵盖镜像拉取错误吗?

涵盖。它有专门处理 ImagePullBackOff 和 ErrImagePull 错误的步骤。

详情

作者的原始描述

Use when pods are stuck in Pending, CrashLoopBackOff, or ImagePullBackOff state. Performs event-driven triage to quickly identify root cause, then deep-dives into scheduling failures, resource exhaustion, image pull errors, and crash loops.

repo: Project-HAMi/HAMi

热度

GitHub 星标
5.1k
排名
#15047
许可证
Apache-2.0
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能