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 →
- Add
topologySpreadConstraintswithtopologyKey: topology.kubernetes.io/zoneandmaxSkew: 1 - Add a second constraint on
kubernetes.io/hostname - Choose
whenUnsatisfiable: ScheduleAnywayfor soft,DoNotSchedulefor hard - Verify with
kubectl get pods -o wide - 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.
More on Deployments and rollouts
You applied a new image tag and the rollout seems stuck at "1 out of 3 new replicas have been updated". What do you check first?BeginnerHow do you roll back a bad release and verify you are back on the previous version?BeginnerA rollout must never reduce capacity below current replicas. How do you configure the strategy?IntermediateYou need a blue/green deployment without a service mesh. How do you do it with plain Kubernetes?IntermediateHow would you do a canary release with only Deployments and a Service?IntermediateWhat is the difference between Recreate and RollingUpdate strategies and when would you pick Recreate?Beginner