force pod spread (#130)

Added required pod anti-affinity (kubernetes.io/hostname, pod-uuid Exists) to K8sController.cs so all pods within a test namespace are forced onto distinct nodes (Pending if unsatisfiable) to cover the worst-case pod counts per namespace.

The anti-affinity TopologyKey of "kubernetes.io/hostname" specifies that the domain is the node, along with the "Exists" operator, specifies that "this Pod should not run on this node if this node is already running one or mode pods that have a "pod-uuid" key (they all do).
This commit is contained in:
Eric 2026-06-16 22:17:38 +10:00 committed by GitHub
parent e8b2ad014b
commit d6a9b9239a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -375,6 +375,7 @@ namespace KubernetesWorkflow
PriorityClassName = GetPriorityClassName(containerRecipes),
NodeSelector = CreateNodeSelector(location, containerRecipes),
Tolerations = CreateTolerations(containerRecipes),
Affinity = CreateSpreadAffinity(),
Containers = CreateDeploymentContainers(containerRecipes),
Volumes = CreateVolumes(containerRecipes)
}
@ -422,6 +423,34 @@ namespace KubernetesWorkflow
}).ToList();
}
private V1Affinity CreateSpreadAffinity()
{
return new V1Affinity
{
PodAntiAffinity = new V1PodAntiAffinity
{
RequiredDuringSchedulingIgnoredDuringExecution = new List<V1PodAffinityTerm>
{
new V1PodAffinityTerm
{
TopologyKey = "kubernetes.io/hostname",
LabelSelector = new V1LabelSelector
{
MatchExpressions = new List<V1LabelSelectorRequirement>
{
new V1LabelSelectorRequirement
{
Key = PodLabelKey,
OperatorProperty = "Exists"
}
}
}
}
}
}
};
}
private K8sNodeLabel? GetNodeLabelForLocation(ILocation location)
{
var l = (Location)location;