From 5a9545170392f117a094494f67f0efe31e7aad24 Mon Sep 17 00:00:00 2001 From: mamutmk5 <3045922+mamutmk5@users.noreply.github.com> Date: Thu, 30 Nov 2023 12:17:05 +0100 Subject: [PATCH] BC-5423 - add pod affinity ruls to deployments --- .../templates/scanfile-deployment.yml.j2 | 33 +++++++++++++++++++ .../templates/web-deployment.yml.j2 | 33 +++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/ansible/roles/antivirus_check_service/templates/scanfile-deployment.yml.j2 b/ansible/roles/antivirus_check_service/templates/scanfile-deployment.yml.j2 index 1ee780b..afc4e19 100644 --- a/ansible/roles/antivirus_check_service/templates/scanfile-deployment.yml.j2 +++ b/ansible/roles/antivirus_check_service/templates/scanfile-deployment.yml.j2 @@ -66,3 +66,36 @@ spec: volumes: - name: shared emptyDir: {} + affinity: + podAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: app.kubernetes.io/part-of + operator: In + values: + - schulcloud-verbund + topologyKey: "kubernetes.io/hostname" + namespaceSelector: {} + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 10 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: app.kubernetes.io/name + operator: In + values: + - scanfile + topologyKey: "cloud.ionos.com/nodepool-name" + - weight: 10 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: app.kubernetes.io/name + operator: In + values: + - scanfile + topologyKey: "topology.kubernetes.io/zone" diff --git a/ansible/roles/antivirus_check_service/templates/web-deployment.yml.j2 b/ansible/roles/antivirus_check_service/templates/web-deployment.yml.j2 index 8c3f602..0d672b4 100644 --- a/ansible/roles/antivirus_check_service/templates/web-deployment.yml.j2 +++ b/ansible/roles/antivirus_check_service/templates/web-deployment.yml.j2 @@ -63,3 +63,36 @@ spec: requests: cpu: {{ ANTIVIRUS_WEBSERVER_CPU_REQUESTS|default("100m", true) }} memory: {{ ANTIVIRUS_WEBSERVER_MEMORY_REQUESTS|default("128Mi", true) }} + affinity: + podAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: app.kubernetes.io/part-of + operator: In + values: + - schulcloud-verbund + topologyKey: "kubernetes.io/hostname" + namespaceSelector: {} + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 10 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: app.kubernetes.io/name + operator: In + values: + - webserver + topologyKey: "cloud.ionos.com/nodepool-name" + - weight: 10 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: app.kubernetes.io/name + operator: In + values: + - webserver + topologyKey: "topology.kubernetes.io/zone"