30 Days of DevOps· day 21 of 30
DAY 21Kubernetes

Affinity, Anti-Affinity, and Topology Spread — Telling the Scheduler What 'Spread Out' Means

Two webapp replicas on the same node is one node failure away from an outage — and the scheduler will happily do that to you, because nothing told it not to. Day 21 covers the three tools that tell it: nodeAffinity (which nodes a Pod prefers or requires), podAntiAffinity (keep replicas apart), and topologySpreadConstraints (the modern '±1 Pod per node' contract). Each one demoed live, including the two failure modes that bite hardest: hard anti-affinity strangling the HPA, and topology spread silently counting the tainted control-plane as a domain.

Jun 10, 2026 29 min read5.7k words

This lesson is for members

The first 7 days of 30 Days of DevOps are free. Unlock the full curriculum — every day of every series, current and future — with one membership.

Monthly

₹399

per month

Annual

₹2,999

per year

Lifetime

₹6,999

one-time

  • Every series, all days — including future series
  • Verified, project-based, no fluff
  • Progress synced across all your devices