diff --git a/ansible/roles/h5p-staticfiles-server-core/templates/deployment.yml.j2 b/ansible/roles/h5p-staticfiles-server-core/templates/deployment.yml.j2 index 3f3244b..5607ccb 100644 --- a/ansible/roles/h5p-staticfiles-server-core/templates/deployment.yml.j2 +++ b/ansible/roles/h5p-staticfiles-server-core/templates/deployment.yml.j2 @@ -78,3 +78,40 @@ spec: requests: cpu: {{ H5P_STATICFIILES_SERVER_CPU_REQUESTS|default("100m", true) }} memory: {{ H5P_STATICFIILES_SERVER_MEMORY_REQUESTS|default("128Mi", true) }} +{% if AFFINITY_ENABLE is defined and AFFINITY_ENABLE|bool %} + 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: +{% if ANIT_AFFINITY_NODEPOOL_ENABLE is defined and ANIT_AFFINITY_NODEPOOL_ENABLE|bool %} + - weight: 10 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: app.kubernetes.io/name + operator: In + values: + - h5p-staticfiles-server + topologyKey: {{ ANIT_AFFINITY_NODEPOOL_TOPOLOGY_KEY }} +{% endif %} + - weight: 20 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: app.kubernetes.io/name + operator: In + values: + - h5p-staticfiles-server + topologyKey: "topology.kubernetes.io/zone" +{% endif %}