How does Pod affinity and anti-affinity work, and what is `topologyKey`?
IntermediateConceptScheduling, Resources & Autoscaling
Answer
Pod affinity attracts Pods to nodes (or zones) that already run Pods matching a selector; anti-affinity repels them. topologyKey defines the domain: kubernetes.io/hostname for per-node, topology.kubernetes.io/zone for per-zone. Required anti-affinity is expensive to evaluate at scale; spread constraints are cheaper.