From 08ec13c675c6bef35a32aba83d9282f1916d1329 Mon Sep 17 00:00:00 2001 From: khushimalhoz Date: Mon, 29 Jul 2024 11:26:51 +0000 Subject: [PATCH 01/16] pod Affinity --- charts/microservice/Chart.yaml | 1 + .../microservice/examples/deploy-nginx.yaml | 5 ++-- charts/microservice/values.yaml | 25 ++++++++++++++++--- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/charts/microservice/Chart.yaml b/charts/microservice/Chart.yaml index 381b6b8d..7a552dde 100644 --- a/charts/microservice/Chart.yaml +++ b/charts/microservice/Chart.yaml @@ -7,4 +7,5 @@ appVersion: "0.1.2" maintainers: - name: Ashwani Singh email: ashwani.singh@opstree.com + - name: Khushi Malhotra - name: Shikha Tripathi diff --git a/charts/microservice/examples/deploy-nginx.yaml b/charts/microservice/examples/deploy-nginx.yaml index 20311c45..313e52c0 100644 --- a/charts/microservice/examples/deploy-nginx.yaml +++ b/charts/microservice/examples/deploy-nginx.yaml @@ -1,5 +1,6 @@ global: - namespace: "demo-dev" + namespace: "default" +# replicaCount: 5 fullnameOverride: "webapp" deployment: @@ -30,4 +31,4 @@ deployment: data: index.html: | Hello! Opstree - \ No newline at end of file + diff --git a/charts/microservice/values.yaml b/charts/microservice/values.yaml index e3da4f73..1db68bf0 100644 --- a/charts/microservice/values.yaml +++ b/charts/microservice/values.yaml @@ -1,7 +1,7 @@ # -- global variables global: namespace: "default" - replicaCount: 1 +# replicaCount: 5 nameOverride: "" fullnameOverride: "" imagePullSecrets: [] @@ -112,12 +112,29 @@ deployment: tolerations: [] - affinity: {} + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + podAffinityTerm: + labelSelector: + matchLabels: + app: "my-microservice" + topologyKey: topology.kubernetes.io/zone + + topologySpreadConstraints: + - maxSkew: 1 + topologyKey: "topology.kubernetes.io/zone" # Ensure this key is valid + whenUnsatisfiable: "DoNotSchedule" + labelSelector: + matchLabels: + app: "my-microservice" + minDomains: 2 hpa: enabled: true - minReplicas: 1 - maxReplicas: 1 + minReplicas: 5 + maxReplicas: 6 targetCPU: 80 targetMemory: 80 From 49f1a390740220e26ad25922b151c20426d24284 Mon Sep 17 00:00:00 2001 From: Khushi Malhotra <156056460+khushimalhoz@users.noreply.github.com> Date: Mon, 29 Jul 2024 17:07:22 +0530 Subject: [PATCH 02/16] Update Chart.yaml --- charts/microservice/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/microservice/Chart.yaml b/charts/microservice/Chart.yaml index 7a552dde..728a2de4 100644 --- a/charts/microservice/Chart.yaml +++ b/charts/microservice/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: microservice description: Basic helm chart for deploying microservices on kubernetes with best practices type: application -version: 0.1.3 +version: 0.1.4 appVersion: "0.1.2" maintainers: - name: Ashwani Singh From d77014dcecd6d99dd03211836364ab0852da0ad0 Mon Sep 17 00:00:00 2001 From: Khushi Malhotra <156056460+khushimalhoz@users.noreply.github.com> Date: Mon, 29 Jul 2024 17:18:44 +0530 Subject: [PATCH 03/16] Update Chart.yaml --- charts/microservice/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/microservice/Chart.yaml b/charts/microservice/Chart.yaml index 728a2de4..7a552dde 100644 --- a/charts/microservice/Chart.yaml +++ b/charts/microservice/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: microservice description: Basic helm chart for deploying microservices on kubernetes with best practices type: application -version: 0.1.4 +version: 0.1.3 appVersion: "0.1.2" maintainers: - name: Ashwani Singh From 0c7a1548559202170d4f9bb854a3afec349d8bc6 Mon Sep 17 00:00:00 2001 From: Khushi Malhotra <156056460+khushimalhoz@users.noreply.github.com> Date: Mon, 29 Jul 2024 22:59:21 +0530 Subject: [PATCH 04/16] Update deployment.yaml --- charts/microservice/templates/deployment.yaml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/charts/microservice/templates/deployment.yaml b/charts/microservice/templates/deployment.yaml index 9bf469a8..ee526cdc 100644 --- a/charts/microservice/templates/deployment.yaml +++ b/charts/microservice/templates/deployment.yaml @@ -91,9 +91,6 @@ spec: {{- end }} {{- with .Values.deployment.affinity }} affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.deployment.tolerations }} + {{- toYaml (merge .Values.deployment.affinity (default dict .Values.deployment.affinity)) | nindent 8 }} tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} \ No newline at end of file + {{- toYaml (merge .Values.deployment.tolerations (default dict .Values.deployment.tolerations)) | nindent 8 }} From aadab3e16ed76a9454c47778a49cd7078b89cbec Mon Sep 17 00:00:00 2001 From: Khushi Malhotra <156056460+khushimalhoz@users.noreply.github.com> Date: Mon, 29 Jul 2024 23:02:36 +0530 Subject: [PATCH 05/16] Create affinity.yaml --- charts/microservice/examples/affinity.yaml | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 charts/microservice/examples/affinity.yaml diff --git a/charts/microservice/examples/affinity.yaml b/charts/microservice/examples/affinity.yaml new file mode 100644 index 00000000..069cde85 --- /dev/null +++ b/charts/microservice/examples/affinity.yaml @@ -0,0 +1,34 @@ +global: + namespace: "default" + # replicacount: 5 + fullnameOverride: "webapp" + +deployment: + image: + name: nginx + tag: latest + pullPolicy: IfNotPresent + livenessProbe: + httpGet: + path: "/" + port: http + readinessProbe: + httpGet: + path: "/" + port: http + resources: + requests: + memory: 100Mi + cpu: 100m + limits: + memory: 500Mi + cpu: 500m + volumes: + enabled: true + configMaps: + - name: index + mountPath: /usr/share/nginx/html + data: + index.html: | + Hello! Opstree + From 6a5be982a6099bb5c0206bfeebc34a4a7a40b7ba Mon Sep 17 00:00:00 2001 From: Khushi Malhotra <156056460+khushimalhoz@users.noreply.github.com> Date: Mon, 29 Jul 2024 23:26:00 +0530 Subject: [PATCH 06/16] Update deploy-nginx.yaml --- charts/microservice/examples/deploy-nginx.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/charts/microservice/examples/deploy-nginx.yaml b/charts/microservice/examples/deploy-nginx.yaml index 313e52c0..e8d84844 100644 --- a/charts/microservice/examples/deploy-nginx.yaml +++ b/charts/microservice/examples/deploy-nginx.yaml @@ -1,6 +1,5 @@ global: - namespace: "default" -# replicaCount: 5 + namespace: "demo-dev" fullnameOverride: "webapp" deployment: From 920b62f963a19542463924c9e6accca5f25b8640 Mon Sep 17 00:00:00 2001 From: Khushi Malhotra <156056460+khushimalhoz@users.noreply.github.com> Date: Mon, 29 Jul 2024 23:26:32 +0530 Subject: [PATCH 07/16] Update deploy-nginx.yaml --- charts/microservice/examples/deploy-nginx.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/microservice/examples/deploy-nginx.yaml b/charts/microservice/examples/deploy-nginx.yaml index e8d84844..d7ddd3e3 100644 --- a/charts/microservice/examples/deploy-nginx.yaml +++ b/charts/microservice/examples/deploy-nginx.yaml @@ -30,4 +30,4 @@ deployment: data: index.html: | Hello! Opstree - + From 6f7e680c9da7574dea130c90385fc93427ad42de Mon Sep 17 00:00:00 2001 From: Khushi Malhotra <156056460+khushimalhoz@users.noreply.github.com> Date: Mon, 29 Jul 2024 23:36:47 +0530 Subject: [PATCH 08/16] Update Chart.yaml --- charts/microservice/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/microservice/Chart.yaml b/charts/microservice/Chart.yaml index 7a552dde..728a2de4 100644 --- a/charts/microservice/Chart.yaml +++ b/charts/microservice/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: microservice description: Basic helm chart for deploying microservices on kubernetes with best practices type: application -version: 0.1.3 +version: 0.1.4 appVersion: "0.1.2" maintainers: - name: Ashwani Singh From 8b03544aba112c35e9d713c49ba894dbc2f42d00 Mon Sep 17 00:00:00 2001 From: Khushi Malhotra <156056460+khushimalhoz@users.noreply.github.com> Date: Mon, 29 Jul 2024 23:45:22 +0530 Subject: [PATCH 09/16] Update deploy-nginx.yaml --- charts/microservice/examples/deploy-nginx.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/charts/microservice/examples/deploy-nginx.yaml b/charts/microservice/examples/deploy-nginx.yaml index d7ddd3e3..26bda319 100644 --- a/charts/microservice/examples/deploy-nginx.yaml +++ b/charts/microservice/examples/deploy-nginx.yaml @@ -30,4 +30,3 @@ deployment: data: index.html: | Hello! Opstree - From 3df39a755f52d4674f307118f6c497dbb448e57b Mon Sep 17 00:00:00 2001 From: Khushi Malhotra <156056460+khushimalhoz@users.noreply.github.com> Date: Tue, 30 Jul 2024 13:03:45 +0530 Subject: [PATCH 10/16] Update deployment.yaml --- charts/microservice/templates/deployment.yaml | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/charts/microservice/templates/deployment.yaml b/charts/microservice/templates/deployment.yaml index bc7e4d0c..f95a2a1d 100644 --- a/charts/microservice/templates/deployment.yaml +++ b/charts/microservice/templates/deployment.yaml @@ -102,7 +102,25 @@ spec: {{- end }} {{- with .Values.deployment.affinity }} affinity: - {{- toYaml (merge .Values.deployment.affinity (default dict .Values.deployment.affinity)) | nindent 8 }} - tolerations: - {{- toYaml (merge .Values.deployment.tolerations (default dict .Values.deployment.tolerations)) | nindent 8 }} + {{- if .Values.deployment.affinity.enabled }} + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + podAffinityTerm: + labelSelector: + matchLabels: + app: {{ include "microservice.fullname" . }}-app + topologyKey: topology.kubernetes.io/zone + {{- end }} + {{- if .Values.deployment.topologySpreadConstraints.enabled }} + topologySpreadConstraints: + - maxSkew: 1 + topologyKey: "topology.kubernetes.io/zone" + whenUnsatisfiable: "DoNotSchedule" + labelSelector: + matchLabels: + app: {{ include "microservice.fullname" . }}-app + minDomains: 2 + {{- end }} {{- end }} + From 61a0e3c3b1ecabc72c1e7394b7e5869e57c6e5ce Mon Sep 17 00:00:00 2001 From: Khushi Malhotra <156056460+khushimalhoz@users.noreply.github.com> Date: Tue, 30 Jul 2024 13:20:40 +0530 Subject: [PATCH 11/16] Update values.yaml --- charts/microservice/values.yaml | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/charts/microservice/values.yaml b/charts/microservice/values.yaml index 98c3aa29..18b9a578 100644 --- a/charts/microservice/values.yaml +++ b/charts/microservice/values.yaml @@ -121,23 +121,10 @@ deployment: tolerations: [] affinity: - podAntiAffinity: - preferredDuringSchedulingIgnoredDuringExecution: - - weight: 100 - podAffinityTerm: - labelSelector: - matchLabels: - app: "my-microservice" - topologyKey: topology.kubernetes.io/zone + enabled: true topologySpreadConstraints: - - maxSkew: 1 - topologyKey: "topology.kubernetes.io/zone" # Ensure this key is valid - whenUnsatisfiable: "DoNotSchedule" - labelSelector: - matchLabels: - app: "my-microservice" - minDomains: 2 + enabled: true hpa: enabled: true From 19f93c6e2def6ab799cff6c4d90a792ed5c21e77 Mon Sep 17 00:00:00 2001 From: Khushi Malhotra <156056460+khushimalhoz@users.noreply.github.com> Date: Tue, 30 Jul 2024 13:21:54 +0530 Subject: [PATCH 12/16] Update affinity.yaml --- charts/microservice/examples/affinity.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/charts/microservice/examples/affinity.yaml b/charts/microservice/examples/affinity.yaml index 069cde85..314772e0 100644 --- a/charts/microservice/examples/affinity.yaml +++ b/charts/microservice/examples/affinity.yaml @@ -23,6 +23,10 @@ deployment: limits: memory: 500Mi cpu: 500m + affinity: + enabled: true # Set to false to disable podAntiAffinity + topologySpreadConstraints: + enabled: true # Set to false to disable topologySpreadConstraints volumes: enabled: true configMaps: From ac1e1e0a156e566dca251d2344a5ea45c6e2ea62 Mon Sep 17 00:00:00 2001 From: Khushi Malhotra <156056460+khushimalhoz@users.noreply.github.com> Date: Tue, 30 Jul 2024 14:46:46 +0530 Subject: [PATCH 13/16] Update affinity.yaml --- charts/microservice/examples/affinity.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/microservice/examples/affinity.yaml b/charts/microservice/examples/affinity.yaml index 314772e0..5c71eaea 100644 --- a/charts/microservice/examples/affinity.yaml +++ b/charts/microservice/examples/affinity.yaml @@ -24,9 +24,9 @@ deployment: memory: 500Mi cpu: 500m affinity: - enabled: true # Set to false to disable podAntiAffinity + enabled: false # Set to false to disable podAntiAffinity topologySpreadConstraints: - enabled: true # Set to false to disable topologySpreadConstraints + enabled: false # Set to false to disable topologySpreadConstraints volumes: enabled: true configMaps: From 0d99723706271f2903105bc61ed2f03ce9c80a2a Mon Sep 17 00:00:00 2001 From: Khushi Malhotra <156056460+khushimalhoz@users.noreply.github.com> Date: Tue, 30 Jul 2024 14:49:35 +0530 Subject: [PATCH 14/16] Update values.yaml --- charts/microservice/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/microservice/values.yaml b/charts/microservice/values.yaml index 18b9a578..e552c4a3 100644 --- a/charts/microservice/values.yaml +++ b/charts/microservice/values.yaml @@ -1,7 +1,7 @@ # -- global variables global: namespace: "default" -# replicaCount: 5 + replicaCount: 1 nameOverride: "" fullnameOverride: "" imagePullSecrets: [] From 2deb7fbac467436e2dba27719636565017c999f2 Mon Sep 17 00:00:00 2001 From: Khushi Malhotra <156056460+khushimalhoz@users.noreply.github.com> Date: Tue, 30 Jul 2024 14:52:04 +0530 Subject: [PATCH 15/16] Update Chart.yaml --- charts/microservice/Chart.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/charts/microservice/Chart.yaml b/charts/microservice/Chart.yaml index 1d78c62a..77b6919d 100644 --- a/charts/microservice/Chart.yaml +++ b/charts/microservice/Chart.yaml @@ -9,3 +9,4 @@ maintainers: - name: tripathishikha1 - name: khushimalhoz + From 59ca5dee5c12adaedd2039cc6f796e027da7c878 Mon Sep 17 00:00:00 2001 From: Khushi Malhotra <156056460+khushimalhoz@users.noreply.github.com> Date: Fri, 2 Aug 2024 13:24:14 +0530 Subject: [PATCH 16/16] Update deployment.yaml --- charts/microservice/templates/deployment.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/microservice/templates/deployment.yaml b/charts/microservice/templates/deployment.yaml index f95a2a1d..021dcf38 100644 --- a/charts/microservice/templates/deployment.yaml +++ b/charts/microservice/templates/deployment.yaml @@ -109,7 +109,7 @@ spec: podAffinityTerm: labelSelector: matchLabels: - app: {{ include "microservice.fullname" . }}-app + app: {{ include "microservice.fullname" . }} topologyKey: topology.kubernetes.io/zone {{- end }} {{- if .Values.deployment.topologySpreadConstraints.enabled }} @@ -119,7 +119,7 @@ spec: whenUnsatisfiable: "DoNotSchedule" labelSelector: matchLabels: - app: {{ include "microservice.fullname" . }}-app + app: {{ include "microservice.fullname" . }} minDomains: 2 {{- end }} {{- end }}