Skip to main content
Cluster operationsLesson 3 of 16

Draining Nodes and Upgrading the Cluster

We are upgrading a 1.33 cluster to 1.34. Three web Pods are spread over three worker nodes, with a promise that "at least 2 web Pods must stay up". Follow how that promise is kept while each node is emptied and upgraded in turn.

Version1.33
Node in progress—
Ready web Pods3
3 worker nodesOperatorkubectlControl planeincl. API server1.33PDBweb min 2worker-11.33worker-21.33worker-31.33web-aworker-1web-bworker-2web-cworker-3web-dworker-2to 1.34
RequestResponse / reportAppears in a later step

What you will learn

  • Why the control plane goes first
  • The difference between cordon and drain
  • Drain deletes and recreates; it does not move
  • How a PDB makes drain wait

Common misconceptions about upgrades​

MisconceptionReality
You can jump straight to the latest versionMinor versions go up one step at a time
Drain moves Pods with zero downtimeIt deletes them and recreates them elsewhere; a single replica means an outage
A PDB protects you against node failureA PDB only applies to voluntary maintenance like drain
If the engine upgrade succeeds, apps are fineDeployments using APIs removed in the new version fail on their next deploy

Try it yourself​

kubectl version # Server (control plane) version
kubectl get nodes # Per-node kubelet VERSION, SchedulingDisabled
kubectl get pdb -A # ALLOWED DISRUPTIONS 0 stalls drain
kubectl get pods -A -o wide --field-selector spec.nodeName=<node> # Pods on that node
kubectl drain <node> --ignore-daemonsets --dry-run=client # Preview evictions, changes nothing

Check yourself

  1. Why is the control plane upgraded before the worker nodes?
  2. You run kubectl drain on a node that runs the only replica of a Deployment. What happens to that Pod?
  3. An upgrade is stuck because drain on one node never finishes. web has 2 replicas and a PDB with minAvailable: 2. What is going on?

Further reading: Safely Drain a Node · Disruptions · Upgrading kubeadm clusters