diff --git a/ansible/roles/nuxt-client-core/templates/deployment.yml.j2 b/ansible/roles/nuxt-client-core/templates/deployment.yml.j2 index fd30a5ff50..1c8b24f152 100644 --- a/ansible/roles/nuxt-client-core/templates/deployment.yml.j2 +++ b/ansible/roles/nuxt-client-core/templates/deployment.yml.j2 @@ -87,6 +87,43 @@ spec: requests: cpu: {{ NUXTCLIENT_CPU_REQUESTS|default("100m", true) }} memory: {{ NUXTCLIENT_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: + - nuxtclient + topologyKey: {{ ANIT_AFFINITY_NODEPOOL_TOPOLOGY_KEY }} +{% endif %} + - weight: 20 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: app.kubernetes.io/name + operator: In + values: + - nuxtclient + topologyKey: "topology.kubernetes.io/zone" +{% endif %} volumes: - name: pid-dir emptyDir: {}