From 09006aafb6f85931078a5af3e5ea36e46c5e960c Mon Sep 17 00:00:00 2001 From: Kulib Date: Thu, 3 Oct 2024 21:40:20 +0300 Subject: [PATCH 1/2] 1st commit --- .infrastructure/app/deployment.yml | 21 ++++++++++++++++++++- .infrastructure/mysql/statefulSet.yml | 23 +++++++++++++++++++++++ README.md | 10 ++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/.infrastructure/app/deployment.yml b/.infrastructure/app/deployment.yml index f93ff6e..c1b0b5d 100644 --- a/.infrastructure/app/deployment.yml +++ b/.infrastructure/app/deployment.yml @@ -90,4 +90,23 @@ spec: secretName: app-secret - name: app-config-volume configMap: - name: app-config \ No newline at end of file + name: app-config + affinity: + nodeAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 1 + preference: + matchExpressions: + - key: app + operator: In + values: + - todoapp + podAntiAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchExpressions: + - key: app + operator: In + values: + - todoapp + topologyKey: "kubernetes.io/hostname" \ No newline at end of file diff --git a/.infrastructure/mysql/statefulSet.yml b/.infrastructure/mysql/statefulSet.yml index 59ea986..a32bc76 100644 --- a/.infrastructure/mysql/statefulSet.yml +++ b/.infrastructure/mysql/statefulSet.yml @@ -64,6 +64,29 @@ spec: - name: config-map configMap: name: mysql + tolerations: + - key: "app" + operator: "Equal" + value: "mysql" + effect: "NoSchedule" + affinity: + podAntiAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchExpressions: + - key: app + operator: In + values: + - mysql + topologyKey: "kubernetes.io/hostname" + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: app + operator: In + values: + - mysql volumeClaimTemplates: - metadata: name: data diff --git a/README.md b/README.md index 69e059e..b710327 100644 --- a/README.md +++ b/README.md @@ -45,3 +45,13 @@ Create a kubernetes manifest for a pod which will containa ToDo app container: 1. `bootstrap.sh` should containe all the commands to deploy all the required resources in the cluster 1. `README.md` should have instructuions on how to validate the changes 1. Create PR with your changes and attach it for validation on a platform. + +To validate the changes use next command: + + kubectl get pods -o wide -n mysql + +in result you can see that pod mysql run in nodes with mysql label, each in different nodes. + + kubectl get pods -o wide -n todoapp + +and also just for pods todoapp \ No newline at end of file From a879d6a5fa4a31bd7f218723526f5ac126fb0866 Mon Sep 17 00:00:00 2001 From: Kulib Date: Thu, 3 Oct 2024 21:41:18 +0300 Subject: [PATCH 2/2] 2nd --- .infrastructure/app/deployment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.infrastructure/app/deployment.yml b/.infrastructure/app/deployment.yml index c1b0b5d..75893c3 100644 --- a/.infrastructure/app/deployment.yml +++ b/.infrastructure/app/deployment.yml @@ -109,4 +109,4 @@ spec: operator: In values: - todoapp - topologyKey: "kubernetes.io/hostname" \ No newline at end of file + topologyKey: "kubernetes.io/hostname"