Draining nodes
You might want to remove/evict all pods from a node that is going to be deleted, upgraded, or rebooted, for example. There is a command, drain
, for that. Its output is quite long, so only some of the output will be shown:
$ kubectl drain –help
We get the following output from the preceding command:
As you can see from the output, there are a few flags you need to pass to properly drain the node: --ignore-daemonsets
and –force
.
Note
A DaemonSet ensures that all specified Kubernetes nodes run a copy of the same pod specified in the DaemonSet. A DaemonSet cannot be deleted from the Kubernetes node, so the --ignore-daemonsets
flag must be used to force draining the node.
Let's drain the gke-kubectl-lab-default-pool-b3c7050d-8jhj
node using the following command:
$ kubectl drain gke-kubectl-lab-default-pool-b3c7050d-8jhj --ignore-daemonsets –...