From 972727cc87a459c9948f0d57b58efeca12ffbdd6 Mon Sep 17 00:00:00 2001 From: mamutmk5 <3045922+mamutmk5@users.noreply.github.com> Date: Fri, 1 Dec 2023 12:50:25 +0100 Subject: [PATCH 1/3] BC-5423 - fix Labels and add pod affinity --- .../templates/tldraw-client-deployment.yml.j2 | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/ansible/roles/tldraw-client-core/templates/tldraw-client-deployment.yml.j2 b/ansible/roles/tldraw-client-core/templates/tldraw-client-deployment.yml.j2 index 03b61979..79e9ab88 100644 --- a/ansible/roles/tldraw-client-core/templates/tldraw-client-deployment.yml.j2 +++ b/ansible/roles/tldraw-client-core/templates/tldraw-client-deployment.yml.j2 @@ -5,6 +5,13 @@ metadata: namespace: {{ NAMESPACE }} labels: app: tldraw-client + app.kubernetes.io/part-of: schulcloud-verbund + app.kubernetes.io/version: {{ SCHULCLOUD_SERVER_IMAGE_TAG }} + app.kubernetes.io/name: tldraw-client + app.kubernetes.io/component: tldraw + app.kubernetes.io/managed-by: ansible + git.branch: {{ SCHULCLOUD_SERVER_BRANCH_NAME }} + git.repo: {{ SCHULCLOUD_SERVER_REPO_NAME }} spec: replicas: {{ TLDRAW_CLIENT_REPLICAS|default("1", true) }} strategy: @@ -20,7 +27,6 @@ spec: metadata: labels: app: tldraw-client - annotations: app.kubernetes.io/part-of: schulcloud-verbund app.kubernetes.io/version: {{ SCHULCLOUD_SERVER_IMAGE_TAG }} app.kubernetes.io/name: tldraw-client @@ -59,6 +65,39 @@ spec: requests: cpu: {{ TLDRAW_CLIENT_CPU_REQUESTS|default("100m", true) }} memory: {{ TLDRAW_CLIENT_MEMORY_REQUESTS|default("256Mi", true) }} + affinity: + podAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 9 + 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: + - tldraw-client + topologyKey: "cloud.ionos.com/nodepool-name" + - weight: 20 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: app.kubernetes.io/name + operator: In + values: + - tldraw-client + topologyKey: "topology.kubernetes.io/zone" volumes: - name: pid-dir emptyDir: {} From 629ea4011fa02cedca5f35abcd039767267b81ec Mon Sep 17 00:00:00 2001 From: mamutmk5 <3045922+mamutmk5@users.noreply.github.com> Date: Fri, 1 Dec 2023 15:52:49 +0100 Subject: [PATCH 2/3] BC-5423 - Make pod anti affinity rule configurable and optional --- .../templates/tldraw-client-deployment.yml.j2 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ansible/roles/tldraw-client-core/templates/tldraw-client-deployment.yml.j2 b/ansible/roles/tldraw-client-core/templates/tldraw-client-deployment.yml.j2 index 79e9ab88..523e23d7 100644 --- a/ansible/roles/tldraw-client-core/templates/tldraw-client-deployment.yml.j2 +++ b/ansible/roles/tldraw-client-core/templates/tldraw-client-deployment.yml.j2 @@ -80,6 +80,7 @@ spec: namespaceSelector: {} podAntiAffinity: preferredDuringSchedulingIgnoredDuringExecution: +{% if ANIT_AFFINITY_NODEPOOL_ENABLE is defined and ANIT_AFFINITY_NODEPOOL_ENABLE|bool %} - weight: 10 podAffinityTerm: labelSelector: @@ -88,7 +89,8 @@ spec: operator: In values: - tldraw-client - topologyKey: "cloud.ionos.com/nodepool-name" + topologyKey: {{ ANIT_AFFINITY_NODEPOOL_TOPOLOGY_KEY }} +{% endif %} - weight: 20 podAffinityTerm: labelSelector: From 461c1bd3ee34a891f6187813b600bfa304844b7f Mon Sep 17 00:00:00 2001 From: mamutmk5 <3045922+mamutmk5@users.noreply.github.com> Date: Mon, 4 Dec 2023 12:44:20 +0100 Subject: [PATCH 3/3] BC-5423 - make affinity rules optional --- .../templates/tldraw-client-deployment.yml.j2 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ansible/roles/tldraw-client-core/templates/tldraw-client-deployment.yml.j2 b/ansible/roles/tldraw-client-core/templates/tldraw-client-deployment.yml.j2 index 523e23d7..ce407723 100644 --- a/ansible/roles/tldraw-client-core/templates/tldraw-client-deployment.yml.j2 +++ b/ansible/roles/tldraw-client-core/templates/tldraw-client-deployment.yml.j2 @@ -65,6 +65,7 @@ spec: requests: cpu: {{ TLDRAW_CLIENT_CPU_REQUESTS|default("100m", true) }} memory: {{ TLDRAW_CLIENT_MEMORY_REQUESTS|default("256Mi", true) }} +{% if AFFINITY_ENABLE is defined and AFFINITY_ENABLE|bool %} affinity: podAffinity: preferredDuringSchedulingIgnoredDuringExecution: @@ -100,6 +101,7 @@ spec: values: - tldraw-client topologyKey: "topology.kubernetes.io/zone" +{% endif %} volumes: - name: pid-dir emptyDir: {}