Hot For Coding

kubectl drain Cannot evict pod as it would violate the pod's disruption budget 错误

kubernetes

最近在升级Kubernetes时遇到一个驱逐pods的错误,具体情况是这样的,我参照官方文档的升级说明,其中有一个步骤需要执行kubectl drain <worker-node-name> --ignore-daemonsets --delete-local-data命令,此命令将会腾空相应的节点。腾空是指驱逐节点现有的pods,忽略DaemonSet,并且不再接受新pods分配。命令如下,worker-node-name替换为实际节点名称

kubectl drain <worker-node-name> --ignore-daemonsets --delete-local-data

可是在执行此命令时,遇到如下错误

error when evicting pod "mongodb-arbiter-0" (will retry after 5s): Cannot evict pod as it would violate the pod's disruption budget.

这个错误是因为我在装mongodb时使用helm安装的,而在helm的mongodb文档里看到了这么一个配置

...
replicaSet.replicas.arbiter = 1
replicaSet.pdb.enabled = true
replicaSet.pdb.minAvailable.arbiter = 1
...

以上配置pdb部分是开启的,然后总裁节点(arbiter)至少为1,难怪要驱逐mongodb-arbiter-0时一直失败。

解决的方案有两种,第一种关闭pdb,第二种增加arbiter的replica,如

...
replicaSet.replicas.arbiter = 2
replicaSet.pdb.enabled = true
replicaSet.pdb.minAvailable.arbiter = 1
...

改完以上配置之后,需要重新执行helm升级一下

helm upgrade mongodb -f values.yaml stable/mongodb

mongodb-arbiter-1 running之后,mongodb-arbiter-0就可以被驱逐了

分享

TITLE: kubectl drain Cannot evict pod as it would violate the pod's disruption budget 错误

LINK: https://www.qttc.net/513-k8s-cannot-evict-pod-as-it-would-violate-the-pods-disruption-budget.html

NOTE: 原创内容,转载请注明出自琼台博客