Remove Daemonset pod from a node

2019-06-21 23:20发布

问题:

I have a running DaemonSet which is running on all nodes. I want to remove it from a node in order to completely drain it, as kubectl drain doesn't get rid of them. Without deleting my DaemonSet, what's a good way to temporarily remove those pods from the node? I've tried draining it and deleting the DaemonSet pods, but the DaemonSet will still reschedule them, disregarding that the node is set as Unschedulable: true.

回答1:

You need to use --ignore-daemonsets key when you drain kubernetes node:

--ignore-daemonsets=false: Ignore DaemonSet-managed pods.

So, in order to drain kubernetes node with DaemonSets in cluster, you need to execute:

kubectl drain <node_name> --ignore-daemonsets

If you need to Remove DaemonSet pod from a node completely, you can specify a .spec.template.spec.nodeSelector in DaemonSet (the DaemonSet controller will create Pods on nodes which match that node selector) and set that label to all nodes except the one you need to completely drain.



标签: kubernetes