kube_clusterSourceKubeClusterMiddlewarePodAntiAffinity

class PodAntiAffinity

Injects soft pod anti-affinity on pod-bearing resources so that pods prefer to spread across nodes.

The anti-affinity uses the resource's own +matchLabels+ from +spec.selector.matchLabels+ as the label selector, and +kubernetes.io/hostname+ as the topology key.

Resources that already have +spec.template.spec.affinity+ set are left untouched.

stack do use Middleware::PodAntiAffinity use Middleware::PodAntiAffinity, topology_key: "topology.kubernetes.io/zone" end