Interview Prep/Kubernetes/Deployments and rollouts

How do you prevent a Deployment from being scheduled all on one node or one zone?

IntermediateScenarioDeployments and rollouts
Answer

Situation read → All replicas of a critical service landed on a single node and an outage took them out together.

What I'd do →

  1. Add topologySpreadConstraints with topologyKey: topology.kubernetes.io/zone and maxSkew: 1
  2. Add a second constraint on kubernetes.io/hostname
  3. Choose whenUnsatisfiable: ScheduleAnyway for soft, DoNotSchedule for hard
  4. Verify with kubectl get pods -o wide
  5. Alternative is podAntiAffinity

Why → Spread constraints give even distribution across failure domains and scale better than anti-affinity for large replica counts.

Interview tip → Mention that spread is evaluated at scheduling time only; a descheduler can rebalance later.

All Kubernetes questions Roadmap: Kubernetes core

More on Deployments and rollouts