TopologySpreadConstraints

TopologySpreadConstraints An architecture diagram generated by Archify. TopologySpreadConstraints · spread rule in the pod spec · TopologySpreadConstraints settings TopologySpreadConstraints spread rule in the pod spec maxSkew · max allowed difference · TopologySpreadConstraints settings maxSkew max allowed difference topologyKey · topology domain key · TopologySpreadConstraints settings topologyKey topology domain key whenUnsatisfiable · action when unsatisfied · TopologySpreadConstraints settings whenUnsatisfiable action when unsatisfied labelSelector · selects target pods · TopologySpreadConstraints settings labelSelector selects target pods DoNotSchedule · refuse to schedule · whenUnsatisfiable options DoNotSchedule refuse to schedule ScheduleAnyway · best-effort placement · whenUnsatisfiable options ScheduleAnyway best-effort placement New pod · pending scheduling · EKS availability zone spread example New pod pending scheduling ap-northeast-2a · 3 pods · EKS availability zone spread example ap-northeast-2a 3 pods ap-northeast-2b · 2 pods → 3 pods · EKS availability zone spread example ap-northeast-2b 2 pods → 3 pods ap-northeast-2c · 3 pods · EKS availability zone spread example ap-northeast-2c 3 pods maxSkew=1 TopologySpreadConstraints settings whenUnsatisfiable options EKS availability zone spread example Legend whenUnsatisfiable options Required fields Availability zone Constraint New pod

Optional fields

  • • minDomains: minimum number of topology domains
  • • matchLabelKeys: pod label keys to match for spread calculation
  • • nodeAffinityPolicy / nodeTaintsPolicy: whether node affinity and taints are considered (Honor / Ignore)

whenUnsatisfiable

  • • DoNotSchedule: hard constraint - the pod is not scheduled if the constraint cannot be satisfied
  • • ScheduleAnyway: soft constraint - the pod is still scheduled, preferring nodes that minimize skew

Availability zone spread example

  • • A new pod is scheduled while ap-northeast-2a holds 3 pods, 2b holds 2, and 2c holds 3
  • • With maxSkew=1 it is placed in 2b so no two domains differ by more than 1 (2 → 3 pods)