mirror of
https://github.com/ansible/awx.git
synced 2026-04-14 06:29:25 -02:30
Adding podAntiAffinity (#15578)
This commit is contained in:
@@ -28,6 +28,7 @@ def get_default_execution_environment():
|
|||||||
|
|
||||||
|
|
||||||
def get_default_pod_spec():
|
def get_default_pod_spec():
|
||||||
|
job_label: str = settings.AWX_CONTAINER_GROUP_DEFAULT_JOB_LABEL
|
||||||
ee = get_default_execution_environment()
|
ee = get_default_execution_environment()
|
||||||
if ee is None:
|
if ee is None:
|
||||||
raise RuntimeError("Unable to find an execution environment.")
|
raise RuntimeError("Unable to find an execution environment.")
|
||||||
@@ -35,10 +36,30 @@ def get_default_pod_spec():
|
|||||||
return {
|
return {
|
||||||
"apiVersion": "v1",
|
"apiVersion": "v1",
|
||||||
"kind": "Pod",
|
"kind": "Pod",
|
||||||
"metadata": {"namespace": settings.AWX_CONTAINER_GROUP_DEFAULT_NAMESPACE},
|
"metadata": {"namespace": settings.AWX_CONTAINER_GROUP_DEFAULT_NAMESPACE, "labels": {job_label: ""}},
|
||||||
"spec": {
|
"spec": {
|
||||||
"serviceAccountName": "default",
|
"serviceAccountName": "default",
|
||||||
"automountServiceAccountToken": False,
|
"automountServiceAccountToken": False,
|
||||||
|
"affinity": {
|
||||||
|
"podAntiAffinity": {
|
||||||
|
"preferredDuringSchedulingIgnoredDuringExecution": [
|
||||||
|
{
|
||||||
|
"weight": 100,
|
||||||
|
"podAffinityTerm": {
|
||||||
|
"labelSelector": {
|
||||||
|
"matchExpressions": [
|
||||||
|
{
|
||||||
|
"key": job_label,
|
||||||
|
"operator": "Exists",
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"topologyKey": "kubernetes.io/hostname",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
"containers": [
|
"containers": [
|
||||||
{
|
{
|
||||||
"image": ee.image,
|
"image": ee.image,
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ IS_K8S = False
|
|||||||
|
|
||||||
AWX_CONTAINER_GROUP_K8S_API_TIMEOUT = 10
|
AWX_CONTAINER_GROUP_K8S_API_TIMEOUT = 10
|
||||||
AWX_CONTAINER_GROUP_DEFAULT_NAMESPACE = os.getenv('MY_POD_NAMESPACE', 'default')
|
AWX_CONTAINER_GROUP_DEFAULT_NAMESPACE = os.getenv('MY_POD_NAMESPACE', 'default')
|
||||||
|
AWX_CONTAINER_GROUP_DEFAULT_JOB_LABEL = os.getenv('AWX_CONTAINER_GROUP_DEFAULT_JOB_LABEL', 'ansible_job')
|
||||||
# Timeout when waiting for pod to enter running state. If the pod is still in pending state , it will be terminated. Valid time units are "s", "m", "h". Example : "5m" , "10s".
|
# Timeout when waiting for pod to enter running state. If the pod is still in pending state , it will be terminated. Valid time units are "s", "m", "h". Example : "5m" , "10s".
|
||||||
AWX_CONTAINER_GROUP_POD_PENDING_TIMEOUT = "2h"
|
AWX_CONTAINER_GROUP_POD_PENDING_TIMEOUT = "2h"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user