Skip to content

Commit

Permalink
BC-5423 - fix pod affinity rule for pods with pvc on dev (#725)
Browse files Browse the repository at this point in the history
Ansible don't apply Deployments so the Affernity rule are not removed if they deactivated by an flag.
So the solution is to set the affinity rule to kubernetes.io/os then all Worker nodes have the same number again.
  • Loading branch information
mamutmk5 authored Dec 5, 2023
1 parent 026f773 commit 43c88dd
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 4 deletions.
4 changes: 4 additions & 0 deletions ansible/group_vars/all/affinity.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
AFFINITY_ENABLE: true
AFFINITY_MONGO_TOPOLOGY_KEY: kubernetes.io/hostname
AFFINITY_POSTGRES_TOPOLOGY_KEY: kubernetes.io/hostname
AFFINITY_REDIS_TOPOLOGY_KEY: kubernetes.io/hostname
AFFINITY_STORAGE_TOPOLOGY_KEY: kubernetes.io/hostname
ANIT_AFFINITY_NODEPOOL_ENABLE: true
ANIT_AFFINITY_NODEPOOL_TOPOLOGY_KEY: "cloud.ionos.com/nodepool-name"
4 changes: 4 additions & 0 deletions ansible/group_vars/develop/affinity.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
AFFINITY_MONGO_TOPOLOGY_KEY: kubernetes.io/os
AFFINITY_POSTGRES_TOPOLOGY_KEY: kubernetes.io/os
AFFINITY_REDIS_TOPOLOGY_KEY: kubernetes.io/os
AFFINITY_STORAGE_TOPOLOGY_KEY: kubernetes.io/os
1 change: 1 addition & 0 deletions ansible/roles/dof_mongo/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
kubeconfig: ~/.kube/config
namespace: "{{ NAMESPACE }}"
template: deployment.yml.j2
apply: yes
when: WITH_DATABASES

- name: remove Deployment
Expand Down
4 changes: 2 additions & 2 deletions ansible/roles/dof_mongo/templates/deployment.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ spec:
affinity:
podAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
- weight: 9
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/part-of
operator: In
values:
- schulcloud-verbund
topologyKey: "kubernetes.io/hostname"
topologyKey: {{ AFFINITY_MONGO_TOPOLOGY_KEY }}
namespaceSelector: {}
{% endif %}
1 change: 1 addition & 0 deletions ansible/roles/dof_postgresql/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
kubeconfig: ~/.kube/config
namespace: "{{ NAMESPACE }}"
template: deployment.yml.j2
apply: yes
when: WITH_DATABASES

- name: remove Deployment
Expand Down
2 changes: 1 addition & 1 deletion ansible/roles/dof_postgresql/templates/deployment.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,6 @@ spec:
operator: In
values:
- schulcloud-verbund
topologyKey: "kubernetes.io/hostname"
topologyKey: {{ AFFINITY_POSTGRES_TOPOLOGY_KEY }}
namespaceSelector: {}
{% endif %}
1 change: 1 addition & 0 deletions ansible/roles/storage/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
kubeconfig: ~/.kube/config
namespace: "{{ NAMESPACE }}"
template: deployment.yml.j2
apply: yes

- name: Ingress
environment:
Expand Down
2 changes: 1 addition & 1 deletion ansible/roles/storage/templates/deployment.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ spec:
operator: In
values:
- schulcloud-verbund
topologyKey: "kubernetes.io/hostname"
topologyKey: {{ AFFINITY_STORAGE_TOPOLOGY_KEY }}
namespaceSelector: {}
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
Expand Down

0 comments on commit 43c88dd

Please sign in to comment.