Skip to main content
This lesson demonstrates common cluster maintenance tasks: inspecting cluster state, taking a node out of service for maintenance, diagnosing and resolving drain failures, and marking a node unschedulable without disrupting critical workloads. Follow the steps in order — they build on one another.

1) Inspect the cluster

First, set a short alias for kubectl and inspect nodes, deployments, and pods. Use the wide pod view to see which node each pod is running on.
Observation: all application pods for the 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, use kubectl 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:
DaemonSet-managed pods (for example, Flannel or kube-proxy) are not evicted by default. Add --ignore-daemonsets to continue the drain and skip node-local DaemonSet pods.
After successful eviction, confirm the pods have been recreated on a different node:
Now the 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.
Check node status — a drained node is cordoned (SchedulingDisabled). To allow scheduling again, use kubectl uncordon node01:
Note: pods evicted during a drain do not automatically return to their original node after it is uncordoned. They are recreated where the scheduler placed them at creation time (in this example, on controlplane). To confirm why controlplane accepted the relocated pods, inspect its description — here it has no taints that would prevent normal workloads:
Because 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 drain node01, you may see a different error:
Inspect pods to find the unmanaged Pod:
The 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.
If you proceed with a forced drain, the unmanaged pod will be deleted and will not be recreated elsewhere:
Because 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

Redeploy hr-app as a Deployment so it becomes controller-managed and can be relocated safely during drains:
Verify pods — hr-app is now a controller-managed pod running on node01:
If you want to prevent any new pods from being scheduled on 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:
Cordon ensures new pods are not scheduled on node01, while the existing hr-app pod continues to run.
Commands & flags quick reference: Summary / best practices:
  • Use kubectl drain to prepare a node for maintenance; it cordons and evicts controller-managed workloads.
  • Add --ignore-daemonsets to skip node-local DaemonSet pods.
  • If unmanaged pods block a drain, do not use --force lightly — 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 cordon when you want to prevent new scheduling on a node without evicting the running workloads.
Links and references:

Watch Video