免费公开题库原题 #131 · Troubleshooting
Pod 一直 Pending 怎么排查?
Pod 停在 Pending = 调度器无法将其分配到任何节点。
第一步 — 始终先运行:
kubectl describe pod <pod-name>
# 查看底部的 "Events:" 部分 — 它会告诉你确切原因
按事件信息分类的根本原因:
1. CPU/内存资源不足:
Warning FailedScheduling 0/3 nodes are available: 3 Insufficient cpu.
修复:
# 检查节点资源分配情况
kubectl describe nodes | grep -A5 "Allocated resources"
# 方案:降低 request 值、扩容节点或启用集群自动扩缩容
2. NodeSelector / Affinity 不匹配:
0/3 nodes are available: 3 node(s) didn't match Pod's node affinity/selector.
修复:
# 查看节点标签
kubectl get nodes --show-labels
# 移除或调整 Pod spec 中的 nodeSelector/affinity
3. Taint / Toleration 不匹配:
0/3 nodes are available: 3 node(s) had taint {node-role.kubernetes.io/master: ""}, that the pod didn't tolerate.
修复:添加匹配的 toleration 或移除污点:
kubectl taint nodes <node> node-role.kubernetes.io/master- # 移除污点
4. PVC 未绑定:
0/3 nodes are available: 3 pod has unbound immediate PersistentVolumeClaims.
修复:确保 PVC 状态为 Bound(参见 PVC 挂载失败排查)。
5. ResourceQuota 超限:
kubectl describe resourcequota -n <namespace>
6. 无可用节点(集群为空或所有节点 NotReady):
kubectl get nodes
📖 官方文档:https://kubernetes.io/docs/concepts/scheduling-eviction/kube-scheduler/