k8s 报错: node(s) didn't match Pod's node affinity.
前言
k8s集群中,有pod出现了 Affinity ,使用 kubectl describe pod 命令,发现了报错 2 node(s) didn't match Pod's node affinity.
Warning FailedScheduling <unknown> default-scheduler 0/2 nodes are available: 1 node(s) didn't match node selector, 1 node(s) had taints that the pod didn't tolerate.
这是因为节点被打上了污点,导致了pod没有节点可以起来
解决
kubectl get nodes -o json | jq '.items[].spec'
or
kubectl get nodes -o yaml
找到污点相关信息,例如:
{
"taints": [
{
"effect": "NoSchedule",
"key": "node.kubernetes.io/disk-pressure",
"timeAdded": "2021-03-06T14:15:27Z"
}
]
}
可以看到,节点被打上了污点,并且是 NoSchedule ,不可调度
进行如下操作,取消所有节点的 node.kubernetes.io/disk-pressure
这个名称的污点
kubectl taint nodes --all node.kubernetes.io/disk-pressure-
成功解决!!