Skip to content

Commit

Permalink
Change weight assigned to podAntiAffinity to 100
Browse files Browse the repository at this point in the history
The affinity weight ca be between 1 and 100 for each instance of
the preferredDuringSchedulingIgnoredDuringExecution affinity type.
When the scheduler finds nodes that meet all the other scheduling
requirements of the Pod, the scheduler iterates through every
preferred rule that the node satisfies and adds the value of the
weight for that expression to a sum.

To make the pods better spread bump the weight to the max. Still
the anti affinty is "this Pod should not run in an X if that X is
already running one or more Pods that meet rule Y", which means
if there are less nodes, but enough resources, the pods get
scheduled there.

Related: https://issues.redhat.com/browse/OSPRH-8958
  • Loading branch information
stuggi committed Jul 30, 2024
1 parent df36d69 commit 296c465
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion modules/common/affinity/affinity.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func DistributePods(
// https://github.com/kubernetes/api/blob/master/core/v1/well_known_labels.go#L20
TopologyKey: topologyKey,
},
Weight: 1,
Weight: 100,
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion modules/common/affinity/affinity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var affinityObj = &corev1.Affinity{
},
TopologyKey: "ThisTopologyKey",
},
Weight: 1,
Weight: 100,
},
},
},
Expand Down

0 comments on commit 296c465

Please sign in to comment.