调度失败(0/N nodes are available)的定位与修复
Pod 一直 Pending,kubectl describe pod 的 Events 出现类似 0/5 nodes are available: 1 node(s) had untolerated taint, 3 Insufficient cpu, 1 node(s) didn't match Pod's node affinity/selector 的信息。这表示调度器逐个节点执行过滤插件后,没有任何节点通过全部条件。
事件里的数字不是“节点总数减可用数”,而是一个节点可能同时不满足多个条件,所以各项计数之和可以大于 N。后面的 preemption: 0/5 nodes are available 是抢占尝试的独立结果,表示即使驱逐低优先级 Pod 也找不到可行节点。若事件出现 pod has unbound immediate PersistentVolumeClaims,说明存储绑定也参与了过滤,不能只按资源不足处理。
先读完整事件,不要只看第一行:
kubectl describe pod <pod> -n <ns> | sed -n '/Events/,$p'
kubectl get events -n <ns> --sort-by=.lastTimestamp | tail -30
kubectl get pod <pod> -n <ns> -o yaml
查看节点状态、污点和可分配资源:
kubectl get nodes -o wide
kubectl describe node <node> | sed -n '/Taints/,/Events/p'
kubectl describe node <node> | sed -n '/Allocated resources/,/Events/p'
kubectl get nodes -o custom-columns=NAME:.metadata.name,TAINTS:.spec.taints
检查存储和调度器:
kubectl get pvc -n <ns>
kubectl get pv
kubectl -n kube-system logs <scheduler-pod> --tail=100
再对照 Pod 的调度约束:
kubectl get pod <pod> -n <ns> \
-o jsonpath='{.spec.nodeSelector}{"\n"}{.spec.affinity}{"\n"}{.spec.tolerations}{"\n"}{.spec.topologySpreadConstraints}{"\n"}'
kubectl get pod <pod> -n <ns> \
-o jsonpath='{range .status.conditions[*]}{.type}{"="}{.status}{" "}{.reason}{"\n"}{end}'
PodScheduled=False 的 reason 和 message 会直接给出调度失败摘要,适合快速确认是否只有存储或亲和性一个原因。
Insufficient cpu 看的是 requests 与节点 allocatable 的差值,不是节点当前的实际使用率;Allocated resources 展示的也是已分配 requests。排查时不要被监控里的低 CPU 使用率误导。事件中的 reason 通常来自调度过滤插件,但同一插件可能产生多个 reason(如 Insufficient cpu 与 Insufficient memory),逐项核对比凭经验猜测更快。
NoSchedule 污点,例如控制面专用、GPU 专用或维护中的节点,Pod 没有对应 toleration。nodeSelector、nodeAffinity 或 requiredDuringScheduling 规则与节点标签不匹配。maxPods 上限。maxPods 不足时评估提高上限或增加节点。合上页面,先回答,再展开对照。
0/5 nodes are available 后面的各项计数应该怎么读?Insufficient cpu?
小程序版
微信扫码,随时查命令