简体   繁体   English

Kubernetes:如何优雅地删除 daemonset 中的 Pod?

[英]Kubernetes: How to gracefully delete pods in daemonset?

If there is an update in the docker image, rolling update strategy will update all the pods one by one in a daemonset, similarly is it possible to restart the pods gracefully without any changes the daemonset config or can it be triggered explicitly?如果 docker 镜像有更新,滚动更新策略会一个一个更新 daemonset 中的所有 pod,同样是否可以在不更改 daemonset 配置的情况下优雅地重新启动 pod,或者是否可以明确触发?

Currently, I am doing it manually by目前,我正在手动进行

kubectl delete pod <pod-name> One by one until each pod gets into running state. kubectl delete pod <pod-name>一个一个,直到每个 pod 进入运行状态。

You could try and use Node maintenance operations :您可以尝试使用节点维护操作

Use kubectl drain to gracefully terminate all pods on the node while marking the node as unschedulable (with --ignore-daemonsets , from Konstantin Vustin 's comment ):使用 kubectl drain优雅地终止节点上的所有 pod,同时将节点标记为--ignore-daemonsets (使用--ignore-daemonsets ,来自Konstantin Vustin评论):

kubectl drain $NODENAME --ignore-daemonsets

This keeps new pods from landing on the node while you are trying to get them off.这可以防止新 Pod 在您尝试将其关闭时降落在节点上。

Then:然后:

Make the node schedulable again:使节点再次可调度:

kubectl uncordon $NODENAME

要触发名称空间 [namespace_name] 中由 deamonset 管理的所有 pod 的重启:

 kubectl rollout restart de -n [namespace_name]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM