Introduction
Sometimes you want certain pods to run close together or far apart on your cluster nodes. Pod affinity and anti-affinity help control where pods are placed based on other pods' locations to improve performance or reliability.
When you want two related services to run on the same node for faster communication.
When you want to spread replicas of a service across different nodes to avoid all going down at once.
When you want to avoid running pods that use a lot of resources on the same node to prevent overload.
When you want to ensure pods that share data are scheduled near each other to reduce network latency.
When you want to keep pods of the same type apart to improve fault tolerance.