# How to drain a node and restart it?

**URL:** <https://discuss.kubernetes.io/t/how-to-drain-a-node-and-restart-it/16331>\
**Category:** General Discussions\
**Created:** [June 11, 2021, 7:44pm UTC](https://discuss.kubernetes.io/t/how-to-drain-a-node-and-restart-it/16331 "2021-06-11T19:44:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![spring84](https://avatars.discourse-cdn.com/v4/letter/s/ed8c4c/32.png) [@spring84](https://discuss.kubernetes.io/u/spring84)\
**Post date:** [June 11, 2021, 7:44pm UTC](https://discuss.kubernetes.io/t/how-to-drain-a-node-and-restart-it/16331/1 "2021-06-11T19:44:52Z")

</div>

Newbie question, say, I have a cluster named “myCluster” and Rancher (UI) informs that 2 nodes are having issues, so, I’m thinking of draining them and restart them.  
Is there a way to drain each of them and restart each with kuberctl?  
If so, how?

Update:  
Did quick research,

```auto
kubectl drain <node name>

```

but how and why does cordon and uncordon come into play here?

Thanks.

---

<div class="post-metadata">

**Author:** ![inbox.amitraj](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/inbox.amitraj/32/7646_2.png) [@inbox.amitraj](https://discuss.kubernetes.io/u/inbox.amitraj)\
**Post date:** [June 11, 2021, 11:36pm UTC](https://discuss.kubernetes.io/t/how-to-drain-a-node-and-restart-it/16331/2 "2021-06-11T23:36:03Z")

</div>

when you say -  
kubectl drain

kubernetes cordons that node, meaning there will no new/existing pods scheduled on that node.  
existing pods get evicted and move to other nodes.

$ **k drain worker02 --ignore-daemonsets**

node/worker02 already cordoned

WARNING: ignoring DaemonSet-managed Pods: kube-system/kube-proxy-x6trg, kube-system/weave-net-s2cg9

evicting pod default/testd-96769dccb-fqhxh

evicting pod default/testd-96769dccb-bg6p7

pod/testd-96769dccb-bg6p7 evicted

$ **k get nodes**  
NAME STATUS ROLES AGE VERSION  
master01 Ready control-plane,master 30d v1.21.0  
worker01 Ready 29d v1.21.0  
worker02 Ready, **SchedulingDisabled** 29d v1.21.0  
$

pod/testd-96769dccb-fqhxh evicted

node/worker02 evicted

$  
**$ k uncordon worker02**

you can run k uncordon command to bring back the node. In one way cordon and uncordon are stop and start or restart of your node because everything running on the cordoned node gets evicted and created newly on other nodes.

$ which k

k: aliased to kubectl

hope this helps.

---

<div class="post-metadata">

**Author:** ![spring84](https://avatars.discourse-cdn.com/v4/letter/s/ed8c4c/32.png) [@spring84](https://discuss.kubernetes.io/u/spring84)\
**Post date:** [June 12, 2021, 7:05pm UTC](https://discuss.kubernetes.io/t/how-to-drain-a-node-and-restart-it/16331/3 "2021-06-12T19:05:24Z")

</div>

Awesome, perfect answer, thank you very much.

Could you also take a look at my other question about increasing quota for namespace?

---

<div class="post-metadata">

**Author:** ![inbox.amitraj](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/inbox.amitraj/32/7646_2.png) [@inbox.amitraj](https://discuss.kubernetes.io/u/inbox.amitraj)\
**Post date:** [June 13, 2021, 12:01am UTC](https://discuss.kubernetes.io/t/how-to-drain-a-node-and-restart-it/16331/4 "2021-06-13T00:01:09Z")

</div>

you are welcome. replied
