新节点池上线,3 个副本有 2 个卡在 Pending。kubeCtl describe pod 最后一行是 0/3 nodes available: 3 node(s) had untolerated taint {dedicated: batch}。
第一反应是资源不够。kubectl top node 看下来 CPU 才 12%,内存也空着一半,排除容量问题。又去看 nodeSelector,写的是 disktype: ssd,节点上的标签却是 disk-type,中间多了一个横线。改完标签,副本起来 1 个,另外 2 个还是 Pending。
这次 Events 换了说法,node(s) didn't match Pod's node affinity。节点池打了污点 dedicated=batch:NoSchedule,Deployment 里只有 nodeSelector,没写 tolerations。调度器不会因为标签对上就忽略污点,这两件事是分开判断的。
补上 tolerations,key 用 dedicated,operator 用 Equal,value 是 batch,effect 写 NoSchedule。四个字段任何一个空着都不匹配,尤其 operator 默认就是 Equal,改成 Exists 之后反而不看 value。
tolerations:
- key: dedicated
operator: Equal
value: batch
effect: NoSchedule
nodeSelector:
disk-type: ssd
改完 kubectl get pod -o wide,3 个副本全落在 batch 节点池,状态 Running。等了 2 分钟没有重启,readiness 探针也过了。
顺手在 CI 里加了一步,发版前把节点的标签和污点导出,和 Deployment 的 nodeSelector 对一遍。这类报错文案很客套,说 available,其实一个节点都不合适。
