diff --git a/ansible/roles/version-aggregator/templates/deployment.yml.j2 b/ansible/roles/version-aggregator/templates/deployment.yml.j2 index cddce03..f869233 100644 --- a/ansible/roles/version-aggregator/templates/deployment.yml.j2 +++ b/ansible/roles/version-aggregator/templates/deployment.yml.j2 @@ -59,3 +59,40 @@ spec: requests: cpu: {{ VERSION_AGGREGATOR__CPU_REQUESTS|default("100m", true) }} memory: {{ VERSION_AGGREGATOR__MEMORY_REQUESTS|default("32Mi", 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: + - version-aggregator + topologyKey: {{ ANIT_AFFINITY_NODEPOOL_TOPOLOGY_KEY }} +{% endif %} + - weight: 20 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: app.kubernetes.io/name + operator: In + values: + - version-aggregator + topologyKey: "topology.kubernetes.io/zone" +{% endif %}