Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BC-5423 - Add POD affinity and anti-affinity #723

Merged
merged 5 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ansible/group_vars/all/affinity.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
AFFINITY_ENABLE: true
ANIT_AFFINITY_NODEPOOL_ENABLE: true
ANIT_AFFINITY_NODEPOOL_TOPOLOGY_KEY: "cloud.ionos.com/nodepool-name"
37 changes: 37 additions & 0 deletions ansible/roles/clamav/templates/deployment.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,40 @@ spec:
requests:
cpu: {{ CLAMAV_CPU_MIN|default("100m", true) }}
memory: {{ CLAMAV_MEMORY_MIN|default("1Gi", 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:
- clamav
topologyKey: {{ ANIT_AFFINITY_NODEPOOL_TOPOLOGY_KEY }}
{% endif %}
- weight: 20
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/name
operator: In
values:
- clamav
topologyKey: "topology.kubernetes.io/zone"
{% endif %}
37 changes: 37 additions & 0 deletions ansible/roles/dof_etherpad/templates/deployment.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,40 @@ spec:
items:
- key: ETHERPAD_API_KEY
path: APIKEY.txt
{% 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:
- etherpad
topologyKey: {{ ANIT_AFFINITY_NODEPOOL_TOPOLOGY_KEY }}
{% endif %}
- weight: 20
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/name
operator: In
values:
- etherpad
topologyKey: "topology.kubernetes.io/zone"
{% endif %}
37 changes: 37 additions & 0 deletions ansible/roles/dof_etherpad_nginx/templates/deployment.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,40 @@ spec:
items:
- key: default.conf
path: default.conf
{% 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:
- etherpad-nginx
topologyKey: {{ ANIT_AFFINITY_NODEPOOL_TOPOLOGY_KEY }}
{% endif %}
- weight: 20
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/name
operator: In
values:
- etherpad-nginx
topologyKey: "topology.kubernetes.io/zone"
{% endif %}
15 changes: 15 additions & 0 deletions ansible/roles/dof_mailcatcher/templates/deployment.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,18 @@ spec:
requests:
cpu: {{ MAILCATCHER_CPU_REQUESTS|default("100m", true) }}
memory: {{ MAILCATCHER_MEMORY_REQUESTS|default("256Mi", true) }}
{% if AFFINITY_ENABLE is defined and AFFINITY_ENABLE|bool %}
affinity:
podAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/part-of
operator: In
values:
- schulcloud-verbund
topologyKey: "kubernetes.io/hostname"
namespaceSelector: {}
{% endif %}
15 changes: 15 additions & 0 deletions ansible/roles/dof_mongo/templates/deployment.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,18 @@ spec:
- name: mongodb-data-pv
persistentVolumeClaim:
claimName: mongo-pvc
{% if AFFINITY_ENABLE is defined and AFFINITY_ENABLE|bool %}
affinity:
podAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/part-of
operator: In
values:
- schulcloud-verbund
topologyKey: "kubernetes.io/hostname"
namespaceSelector: {}
{% endif %}
15 changes: 15 additions & 0 deletions ansible/roles/dof_postgresql/templates/deployment.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,18 @@ spec:
items:
- key: 01_erwinidm.sql
path: 01_erwinidm.sql
{% if AFFINITY_ENABLE is defined and AFFINITY_ENABLE|bool %}
affinity:
podAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/part-of
operator: In
values:
- schulcloud-verbund
topologyKey: "kubernetes.io/hostname"
namespaceSelector: {}
{% endif %}
37 changes: 37 additions & 0 deletions ansible/roles/dof_redis/templates/deployment.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,40 @@ spec:
- name: redis-data-pv
persistentVolumeClaim:
claimName: redis-pvc
{% 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:
- redis
topologyKey: {{ ANIT_AFFINITY_NODEPOOL_TOPOLOGY_KEY }}
{% endif %}
- weight: 20
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/name
operator: In
values:
- redis
topologyKey: "topology.kubernetes.io/zone"
{% endif %}
37 changes: 37 additions & 0 deletions ansible/roles/erwin-idm/templates/deployment.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,40 @@ spec:
timeoutSeconds: 4
failureThreshold: 30
periodSeconds: 10
{% 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:
- erwinidm
topologyKey: {{ ANIT_AFFINITY_NODEPOOL_TOPOLOGY_KEY }}
{% endif %}
- weight: 20
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/name
operator: In
values:
- erwinidm
topologyKey: "topology.kubernetes.io/zone"
{% endif %}
37 changes: 37 additions & 0 deletions ansible/roles/hydra/templates/deployment.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,40 @@ spec:
requests:
cpu: "{{ HYDRA_CPU_MIN|default("100m", true) }}"
memory: "{{ HYDRA_MEM_MIN|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:
- hydra
topologyKey: {{ ANIT_AFFINITY_NODEPOOL_TOPOLOGY_KEY }}
{% endif %}
- weight: 20
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/name
operator: In
values:
- hydra
topologyKey: "topology.kubernetes.io/zone"
{% endif %}
15 changes: 15 additions & 0 deletions ansible/roles/maildrop/templates/deployment.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,18 @@ spec:
requests:
cpu: {{ MAILDROP_CPU_REQUESTS|default("100m", true) }}
memory: {{ MAILDROP_MEMORY_REQUESTS|default("128Mi", true) }}
{% if AFFINITY_ENABLE is defined and AFFINITY_ENABLE|bool %}
affinity:
podAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/part-of
operator: In
values:
- schulcloud-verbund
topologyKey: "kubernetes.io/hostname"
namespaceSelector: {}
{% endif %}
15 changes: 15 additions & 0 deletions ansible/roles/oidcmock/templates/deployment.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,18 @@ spec:
path: clientsConfigurationContent.json
- name: config-directory
emptyDir: {}
{% if AFFINITY_ENABLE is defined and AFFINITY_ENABLE|bool %}
affinity:
podAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/part-of
operator: In
values:
- schulcloud-verbund
topologyKey: "kubernetes.io/hostname"
namespaceSelector: {}
{% endif %}
37 changes: 37 additions & 0 deletions ansible/roles/rocketchat/templates/deployment.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,40 @@ spec:
volumes:
- name: rocketchat-uploads-data
emptyDir: {}
{% 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:
- rocketchat
topologyKey: {{ ANIT_AFFINITY_NODEPOOL_TOPOLOGY_KEY }}
{% endif %}
- weight: 20
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/name
operator: In
values:
- rocketchat
topologyKey: "topology.kubernetes.io/zone"
{% endif %}
Loading