diff --git a/ansible/group_vars/all/affinity.yml b/ansible/group_vars/all/affinity.yml index 9cb5c16e1..a4b6d2c37 100644 --- a/ansible/group_vars/all/affinity.yml +++ b/ansible/group_vars/all/affinity.yml @@ -1,3 +1,7 @@ AFFINITY_ENABLE: true +AFFINITY_MONGO_TOPOLOGY_KEY: kubernetes.io/hostname +AFFINITY_POSTGRES_TOPOLOGY_KEY: kubernetes.io/hostname +AFFINITY_REDIS_TOPOLOGY_KEY: kubernetes.io/hostname +AFFINITY_STORAGE_TOPOLOGY_KEY: kubernetes.io/hostname ANIT_AFFINITY_NODEPOOL_ENABLE: true ANIT_AFFINITY_NODEPOOL_TOPOLOGY_KEY: "cloud.ionos.com/nodepool-name" diff --git a/ansible/group_vars/develop/affinity.yml b/ansible/group_vars/develop/affinity.yml new file mode 100644 index 000000000..ef2ad23f1 --- /dev/null +++ b/ansible/group_vars/develop/affinity.yml @@ -0,0 +1,4 @@ +AFFINITY_MONGO_TOPOLOGY_KEY: kubernetes.io/os +AFFINITY_POSTGRES_TOPOLOGY_KEY: kubernetes.io/os +AFFINITY_REDIS_TOPOLOGY_KEY: kubernetes.io/os +AFFINITY_STORAGE_TOPOLOGY_KEY: kubernetes.io/os diff --git a/ansible/roles/dof_mongo/tasks/main.yml b/ansible/roles/dof_mongo/tasks/main.yml index 61db5bf02..a94760955 100644 --- a/ansible/roles/dof_mongo/tasks/main.yml +++ b/ansible/roles/dof_mongo/tasks/main.yml @@ -71,6 +71,7 @@ kubeconfig: ~/.kube/config namespace: "{{ NAMESPACE }}" template: deployment.yml.j2 + apply: yes when: WITH_DATABASES - name: remove Deployment diff --git a/ansible/roles/dof_mongo/templates/deployment.yml.j2 b/ansible/roles/dof_mongo/templates/deployment.yml.j2 index 537b93b99..0e8bff404 100644 --- a/ansible/roles/dof_mongo/templates/deployment.yml.j2 +++ b/ansible/roles/dof_mongo/templates/deployment.yml.j2 @@ -87,7 +87,7 @@ spec: affinity: podAffinity: preferredDuringSchedulingIgnoredDuringExecution: - - weight: 100 + - weight: 9 podAffinityTerm: labelSelector: matchExpressions: @@ -95,6 +95,6 @@ spec: operator: In values: - schulcloud-verbund - topologyKey: "kubernetes.io/hostname" + topologyKey: {{ AFFINITY_MONGO_TOPOLOGY_KEY }} namespaceSelector: {} {% endif %} diff --git a/ansible/roles/dof_postgresql/tasks/main.yml b/ansible/roles/dof_postgresql/tasks/main.yml index 369ba07f3..9c9694e0d 100644 --- a/ansible/roles/dof_postgresql/tasks/main.yml +++ b/ansible/roles/dof_postgresql/tasks/main.yml @@ -90,6 +90,7 @@ kubeconfig: ~/.kube/config namespace: "{{ NAMESPACE }}" template: deployment.yml.j2 + apply: yes when: WITH_DATABASES - name: remove Deployment diff --git a/ansible/roles/dof_postgresql/templates/deployment.yml.j2 b/ansible/roles/dof_postgresql/templates/deployment.yml.j2 index 26250db7e..d0af501c9 100644 --- a/ansible/roles/dof_postgresql/templates/deployment.yml.j2 +++ b/ansible/roles/dof_postgresql/templates/deployment.yml.j2 @@ -79,6 +79,6 @@ spec: operator: In values: - schulcloud-verbund - topologyKey: "kubernetes.io/hostname" + topologyKey: {{ AFFINITY_POSTGRES_TOPOLOGY_KEY }} namespaceSelector: {} {% endif %} diff --git a/ansible/roles/storage/tasks/main.yml b/ansible/roles/storage/tasks/main.yml index 250fa1484..399173429 100644 --- a/ansible/roles/storage/tasks/main.yml +++ b/ansible/roles/storage/tasks/main.yml @@ -22,6 +22,7 @@ kubeconfig: ~/.kube/config namespace: "{{ NAMESPACE }}" template: deployment.yml.j2 + apply: yes - name: Ingress environment: diff --git a/ansible/roles/storage/templates/deployment.yml.j2 b/ansible/roles/storage/templates/deployment.yml.j2 index dc3e18437..3ca83ae5f 100644 --- a/ansible/roles/storage/templates/deployment.yml.j2 +++ b/ansible/roles/storage/templates/deployment.yml.j2 @@ -78,7 +78,7 @@ spec: operator: In values: - schulcloud-verbund - topologyKey: "kubernetes.io/hostname" + topologyKey: {{ AFFINITY_STORAGE_TOPOLOGY_KEY }} namespaceSelector: {} podAntiAffinity: preferredDuringSchedulingIgnoredDuringExecution: