Hands-on Lab·Certified Kubernetes Administrator
Draining a Node for Maintenance
kubectl drain refuses twice before it works, and each refusal names the flag it wants: DaemonSet pods, then pods with no controller. Cordon on its own moves nothing - the four pods already there stay put.
Scheduling and Placement Guide 44 of 103 Intermediate
- Kubernetes1.36.4
- Cluster2 nodes
- Runtimecontainerd 2.2.6
- CNICalico v3.32.1
- TimeAbout 16 min
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| CKA3001 | 192.168.0.185 | Ubuntu 26.04 LTS | Control Plane Node | 2 Core | 4 GB | 50 GB |
| CKA3001-NODE01 | 192.168.0.186 | Ubuntu 26.04 LTS | Worker Node (the one being drained) | 2 Core | 4 GB | 50 GB |
This guide includes
Use this before taking a node out for maintenance. This matters because kubectl drain refuses twice before it works, and each refusal names the flag it wants - DaemonSet Pods and local data are both things it will not decide for you.
- cordoning first, and seeing that it stops new work while moving nothing
- running a bare
drainand reading the refusal instead of reaching for--force - supplying
--ignore-daemonsetsand--delete-emptydir-data, the two flags it asked for - meeting the third case - a Pod with no controller, which nothing will recreate
Before you start
- guide 39 for how pods land on nodes in the first place.
- A cluster with at least one worker you are willing to empty.
-
Cordon stops new work and moves nothing
-
Drain refuses, and says why
-
The two flags it asked for
-
A pod with no controller is different again