Adding podAntiAffinity (#15578)

This commit is contained in:
Justin Downie
2024-10-08 15:29:57 -05:00
committed by GitHub
parent 579c2b7229
commit 825a02c86a
2 changed files with 23 additions and 1 deletions

View File

@@ -28,6 +28,7 @@ def get_default_execution_environment():
def get_default_pod_spec():
job_label: str = settings.AWX_CONTAINER_GROUP_DEFAULT_JOB_LABEL
ee = get_default_execution_environment()
if ee is None:
raise RuntimeError("Unable to find an execution environment.")
@@ -35,10 +36,30 @@ def get_default_pod_spec():
return {
"apiVersion": "v1",
"kind": "Pod",
"metadata": {"namespace": settings.AWX_CONTAINER_GROUP_DEFAULT_NAMESPACE},
"metadata": {"namespace": settings.AWX_CONTAINER_GROUP_DEFAULT_NAMESPACE, "labels": {job_label: ""}},
"spec": {
"serviceAccountName": "default",
"automountServiceAccountToken": False,
"affinity": {
"podAntiAffinity": {
"preferredDuringSchedulingIgnoredDuringExecution": [
{
"weight": 100,
"podAffinityTerm": {
"labelSelector": {
"matchExpressions": [
{
"key": job_label,
"operator": "Exists",
}
]
},
"topologyKey": "kubernetes.io/hostname",
},
}
]
}
},
"containers": [
{
"image": ee.image,