pod-pending

Kubernetes Pod 一直 Pending 的定位与修复

现象

kubectl get pod 显示 Pending,容器没有启动。可能是调度器找不到合适节点,也可能是 PVC、配额或节点状态阻止了调度。

快速定位

kubectl describe pod <pod> -n <ns>
kubectl get events -n <ns> --sort-by=.lastTimestamp | tail -20
kubectl get nodes
kubectl describe node <node> | sed -n '/Allocated resources/,/Events/p'
kubectl get pvc -n <ns>
kubectl get resourcequota,limitrange -n <ns>

常见根因

  1. 节点资源不足,Pod 的 requests 无法满足。
  2. nodeSelector、affinity、anti-affinity 或 taints/tolerations 不匹配。
  3. PVC 未绑定,Pod 等待存储。
  4. 命名空间配额(ResourceQuota)已满。
  5. 所有节点 NotReady,或调度器/控制器异常。
  6. 镜像太大或节点磁盘不足,卡在后续阶段(此时通常已调度)。

修复

相关命令

读完自测

合上页面,先回答,再展开对照。

  1. Pod 一直 Pending,第一手原因应该去哪里看?
  2. PVC 未绑定会让 Pod 停在 Pending 吗?
  3. 节点资源不足导致 Pending 时可以怎么处理?
答案
  1. 先看 kubectl describe pod 的 Events,Pending 原因通常写得很明确。再结合节点状态和事件继续排查。
  2. 会。Pod 会等待存储绑定,需先修 StorageClass 或存储供应器。用 kubectl get pvc 确认绑定状态。
  3. 降低 requests、扩容节点或清理占用。可用 describe node 的 Allocated resources 判断剩余资源。