Filters
How to search
  • Plain words find names, texts and examples.
  • "two words" finds the exact phrase.
  • --name or -x finds an option.
  • #word looks only inside commands.
  • @grep finds lessons and labs that use grep.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Put ! before a word to leave it out. OR between words means one of them.
  • ↑ ↓ to move · Enter to open · Esc to close · / to search

Platform operationsMixed 24 series

Draining a node without dropping requests

Draining a node looks like one command. It is a traffic operation that happens to move pods.

Quick reference

Readiness first, eviction second, proof from outside the cluster.

Prepare: Make the pod leave first

  • Check the budget — kubectl get pdb -A shows what may move, and what may not.
  • Fail readiness early — The endpoint leaves before the process stops accepting.
  • Sleep in preStop — Long enough for the load balancer to notice, not longer.

Drain: One node, one at a time

  • Cordon before drain — Nothing new lands while the node is being emptied.
  • Give it a timeout — kubectl drain node-3 --ignore-daemonsets --timeout=300s.
  • Watch evictions — kubectl get events -A --watch shows what the scheduler does.

Prove: Check from outside

  • Curl through the edge — A request from inside the cluster proves nothing about the edge.
  • Count 5xx per minute — Before, during and after, not during alone.
  • Uncordon and record — Write the drain duration into the change record.

In one line: The request does not care about your drain. A drain is a traffic problem before it is a node problem.

See the budget:

kubectl get pdb -A -o wide

Explained

Prepare first. The drain evicts pods, and a pod leaves the endpoint list asynchronously, so a request can arrive at a process that is already shutting down. A readiness probe that fails before the process stops, a preStop hook that sleeps for the propagation window, and a terminationGracePeriodSeconds longer than the slowest request are the three settings that close that gap.

Then drain one node. Cordon first so nothing new lands, drain with a timeout so a stuck pod does not hold the window open, and watch the evictions rather than the logs. If a PodDisruptionBudget says one replica must stay available, the drain will wait, and that wait is the budget doing its job.

Then prove it from outside. Curl through the edge, compare 5xx per minute before, during and after, and uncordon only when the numbers are boring. A request from inside the cluster tells you the service is up, not that customers can reach it.

The honest caveat: a preStop sleep that is too long slows every deploy, and a grace period that is too short still cuts long requests, so measure both against your p99.

Your turn: What is your longest in-flight request, and does your drain wait for it?

More notes: Platform operations

Open in the notes app: search, filters, copy This note on GitHub