1) Inspect the cluster
First, set a short alias forkubectl and inspect nodes, deployments, and pods. Use the wide pod view to see which node each pod is running on.
blue deployment are scheduled on node01. This is important to note before attempting maintenance.
2) Take node01 out of service for maintenance
To prepare a node for maintenance, usekubectl drain. drain performs two key actions: it cordons the node (marks it unschedulable) and evicts controller-managed pods so workloads can be recreated on other nodes.
Attempt to drain node01:
--ignore-daemonsets to continue the drain and skip node-local DaemonSet pods.
blue pods are running on the controlplane node.
During a drain, controller-managed pods (Deployments, ReplicaSets, StatefulSets, Jobs, etc.) are evicted safely because their controllers will recreate them on other nodes. DaemonSet pods are node-local and skipped by default.
SchedulingDisabled). To allow scheduling again, use kubectl uncordon node01:
controlplane).
To confirm why controlplane accepted the relocated pods, inspect its description — here it has no taints that would prevent normal workloads:
controlplane has no taints, it accepted the relocated application pods.
3) Next maintenance window — drain fails due to an unmanaged pod
On a subsequent attempt to drainnode01, you may see a different error:
hr-app pod is a plain Pod (not managed by a controller). kubectl drain will not delete such pods by default because deleting them would permanently remove that Pod and any local state.
Using
--force with kubectl drain deletes pods that are not managed by controllers. This can permanently remove local data or cause downtime. Use --force only after confirming the impact.hr-app is critical, deleting it was not acceptable in this scenario. The recommended solution is to run critical workloads under controllers so they can be safely evicted and recreated elsewhere.
4) Redeploy hr-app as a Deployment and protect the node
Redeployhr-app as a Deployment so it becomes controller-managed and can be relocated safely during drains:
hr-app is now a controller-managed pod running on node01:
node01 (for example, to reserve it for the running critical hr-app instance), use kubectl cordon to mark the node unschedulable while leaving existing pods running:
node01, while the existing hr-app pod continues to run.
Commands & flags quick reference:
Summary / best practices:
- Use
kubectl drainto prepare a node for maintenance; it cordons and evicts controller-managed workloads. - Add
--ignore-daemonsetsto skip node-local DaemonSet pods. - If unmanaged pods block a drain, do not use
--forcelightly — forced deletion permanently removes those pods and any local state. - Run critical workloads under controllers (Deployments, ReplicaSets, StatefulSets) so they can be safely rescheduled.
- Use
kubectl cordonwhen you want to prevent new scheduling on a node without evicting the running workloads.