kubernetes daemonset如何设置成0,临时删除pod呢?

猴子洋 发表于: 2021-11-04   最后更新时间: 2021-11-04 22:52:38   2,746 游览

不同与deployment,可以通过设置副本为0来实现临时删除pod,daemonset如何暂停和恢复呢?

在线,4分钟前登录
发表于 2021-11-04
添加评论

如果你不想删除daemonset,一个可能的变通方法是使用不存在的临时标签nodeSelector,比如说:

kubectl -n <namespace> patch daemonset <name-of-daemon-set> -p '{"spec": {"template": {"spec": {"nodeSelector": {"non-existing": "true"}}}}}'

缩减daemonset的规模为0。

删除临时nodeSelector来恢复:

kubectl -n <namespace> patch daemonset <name-of-daemon-set> --type json -p='[{"op": "remove", "path": "/spec/template/spec/nodeSelector/non-existing"}]'

这样就恢复原来的规模了。

命令可参考:Kubernetes定向调度nodeSelector

你的答案

查看kubernetes相关的其他问题或提一个您自己的问题