[STRIMZI] Add podAntiAffinity to kafka deployment 90/136590/2
authorAndreas Geissler <andreas-geissler@telekom.de>
Fri, 17 Nov 2023 10:35:18 +0000 (11:35 +0100)
committerAndreas Geissler <andreas-geissler@telekom.de>
Fri, 17 Nov 2023 12:52:19 +0000 (13:52 +0100)
Add the configuration to add podAntiAffinity rules for Kafka
and zookeeper pods to distribute the pods over multiple
worker nodes

Issue-ID: OOM-3249

Change-Id: Icd2de1711f8bcad09bd49dac643164c83ae7f06e
Signed-off-by: Andreas Geissler <andreas-geissler@telekom.de>
kubernetes/strimzi/templates/strimzi-kafka.yaml
kubernetes/strimzi/values.yaml

index 4071aa0..a808b84 100644 (file)
@@ -72,6 +72,18 @@ spec:
         securityContext:
           runAsUser: 0
           fsGroup: 0
+        {{- if .Values.affinity.podAntiAffinity.enabled }}
+        affinity:
+          podAntiAffinity:
+            requiredDuringSchedulingIgnoredDuringExecution:
+              - labelSelector:
+                  matchExpressions:
+                    - key: strimzi.io/name
+                      operator: In
+                      values:
+                        - {{ include "common.fullname" . }}-kafka
+                topologyKey: "kubernetes.io/hostname"
+        {{- end }}
     config:
       default.replication.factor: {{ .Values.replicaCount }}
       min.insync.replicas: {{ (eq 1.0 (.Values.replicaCount)) | ternary 1 (sub .Values.replicaCount 1) }}
@@ -104,6 +116,18 @@ spec:
         securityContext:
           runAsUser: 0
           fsGroup: 0
+        {{- if .Values.affinity.podAntiAffinity.enabled }}
+        affinity:
+          podAntiAffinity:
+            requiredDuringSchedulingIgnoredDuringExecution:
+              - labelSelector:
+                  matchExpressions:
+                    - key: strimzi.io/name
+                      operator: In
+                      values:
+                        - {{ include "common.fullname" . }}-zookeeper
+                topologyKey: "kubernetes.io/hostname"
+        {{- end }}
     replicas: {{ .Values.replicaCount }}
     config:
       ssl.hostnameVerification: false
index bb22de7..a9eed5d 100644 (file)
@@ -29,6 +29,9 @@ global:
 # Application configuration defaults.
 #################################################################
 replicaCount: 3
+affinity:
+  podAntiAffinity:
+    enabled: true
 config:
   kafkaVersion: 3.4.0
   authType: simple