Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
$ als gewone gebruiker# als root (of met sudo)
The quick answer
Step by step
- Before you start: enough free capacity on the other nodes for the moved Pods, and apps with 2+ replicas (a single-replica app has a short outage).
- Drain (quick answer). The options:
| Option | Why |
|---|---|
--ignore-daemonsets | DaemonSet Pods (CNI, log agents) stay — they belong on every node. |
--delete-emptydir-data | Pods with emptyDir volumes may be moved (that temp data is lost). |
--timeout=10m | Do not wait forever. |
--pod-selector | Drain only some Pods. |
- PodDisruptionBudgets — drain waits while evicting a Pod would break a PDB (for example
minAvailable: 2with only 2 ready). You see repeated messages likeCannot evict pod as it would violate the pod's disruption budget. Wait for replacement Pods, or scale up first. - Do the maintenance — patch, reboot, hardware. Then check the node is
Ready:
kubectl get node worker2
NAME STATUS ROLES AGE VERSION
worker2 Ready,SchedulingDisabled <none> 212d v1.33.1- Uncordon — the node accepts Pods again. Existing Pods are not moved back automatically; new Pods and later rollouts will use it.
- Many nodes — one by one, waiting until all Pods are
Runningagain before the next. Managed clusters (EKS/AKS/GKE) do the same for node-pool upgrades.
Check that it worked
Common problems
| Problem | Cause | Fix |
|---|---|---|
cannot delete DaemonSet-managed Pods | DaemonSets can not move. | --ignore-daemonsets. |
cannot delete Pods with local storage | emptyDir volumes. | --delete-emptydir-data (the temp data is lost). |
cannot delete Pods not managed by a controller | Bare Pods (no Deployment). | --force deletes them for good — check first. |
| Drain hangs on a PDB | Not enough ready replicas elsewhere. | Scale up or wait; fix PDBs that allow 0 disruptions. |
Pods stay Pending after the drain | No capacity on the other nodes. | Add a node first, or lower requests. |
Node stays SchedulingDisabled | Forgot to uncordon. | kubectl uncordon NODE. |
Go further
- Command pages: kubectl.
- Next how-tos: Upgrade a kubeadm cluster, Scale a deployment, Patch a server with security updates.
- Learn it: CKA — Drain, CKA — Troubleshoot nodes.
1What is the difference between cordon and drain?
Cordon only stops new Pods on the node; drain also evicts the running Pods.
2Why does a drain sometimes wait for a long time?
A PodDisruptionBudget would be broken; drain waits until enough replicas are ready elsewhere.