From 971c30fccb3efbf9171362262c7d0e31db178168 Mon Sep 17 00:00:00 2001 From: MaesterZ <22374424+MaesterZ@users.noreply.github.com> Date: Thu, 27 Jun 2024 12:29:50 +0200 Subject: [PATCH 1/2] Add pod affinity, nodeSelector, schedulerName, tolerations & topologySpreadConstraints --- charts/community-operator/Chart.yaml | 2 +- .../templates/operator.yaml | 64 ++++++++++--------- charts/community-operator/values.yaml | 20 ++++++ 3 files changed, 55 insertions(+), 31 deletions(-) diff --git a/charts/community-operator/Chart.yaml b/charts/community-operator/Chart.yaml index 638bf5aa..7c225b6a 100644 --- a/charts/community-operator/Chart.yaml +++ b/charts/community-operator/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v2 name: community-operator description: MongoDB Kubernetes Community Operator -version: 0.10.0 +version: 0.11.0 type: application appVersion: 0.10.0 kubeVersion: '>=1.16-0' diff --git a/charts/community-operator/templates/operator.yaml b/charts/community-operator/templates/operator.yaml index 55a30986..873689f2 100644 --- a/charts/community-operator/templates/operator.yaml +++ b/charts/community-operator/templates/operator.yaml @@ -9,7 +9,7 @@ metadata: name: {{ .Values.operator.name }} namespace: {{ .Release.Namespace }} spec: - replicas: {{ .Values.operator.replicas }} + replicas: {{ int .Values.operator.replicas }} selector: matchLabels: name: {{ .Values.operator.name }} @@ -22,35 +22,24 @@ spec: labels: name: {{ .Values.operator.name }} spec: - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} + {{- with .Values.operator.affinity }} + affinity: {{- toYaml . | nindent 8 }} {{- end }} - affinity: - podAntiAffinity: - requiredDuringSchedulingIgnoredDuringExecution: - - labelSelector: - matchExpressions: - - key: name - operator: In - values: - - {{ .Values.operator.name }} - topologyKey: kubernetes.io/hostname containers: - command: - /usr/local/bin/entrypoint env: -{{- if .Values.operator.extraEnvs }} - {{ toYaml .Values.operator.extraEnvs | nindent 12 }} -{{- end }} + {{- with .Values.operator.extraEnvs }} + {{ toYaml . | nindent 12 }} + {{- end }} - name: WATCH_NAMESPACE -{{- if .Values.operator.watchNamespace}} + {{- if .Values.operator.watchNamespace}} value: "{{ .Values.operator.watchNamespace }}" -{{- else }} + {{- else }} valueFrom: fieldRef: fieldPath: metadata.namespace -{{- end }} + {{- end }} - name: POD_NAME valueFrom: fieldRef: @@ -70,17 +59,32 @@ spec: image: {{ .Values.registry.operator }}/{{ .Values.operator.operatorImageName }}:{{ .Values.operator.version }} imagePullPolicy: {{ .Values.registry.pullPolicy}} name: {{ .Values.operator.deploymentName }} - resources: - {{- toYaml .Values.operator.resources | nindent 12 }} - {{- if .Values.operator.securityContext }} - securityContext: - {{- toYaml .Values.operator.securityContext | nindent 12 }} + {{- with .Values.operator.resources }} + resources: {{- toYaml . | nindent 12 }} {{- end }} - {{- if .Values.operator.priorityClassName }} - priorityClassName: {{ .Values.operator.priorityClassName }} + {{- with .Values.operator.securityContext }} + securityContext: {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.operator.nodeSelector }} + nodeSelector: {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.operator.priorityClassName }} + priorityClassName: {{ . | quote }} {{- end }} - {{- if .Values.operator.podSecurityContext }} - securityContext: - {{- toYaml .Values.operator.podSecurityContext | nindent 8 }} + {{- with .Values.operator.schedulerName }} + schedulerName: {{ . | quote }} + {{- end }} + {{- with .Values.operator.podSecurityContext }} + securityContext: {{- toYaml . | nindent 8 }} {{- end }} serviceAccountName: {{ .Values.operator.name }} + {{- with .Values.operator.tolerations }} + tolerations: {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.operator.topologySpreadConstraints }} + topologySpreadConstraints: {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/community-operator/values.yaml b/charts/community-operator/values.yaml index 2a9d36db..15bafb86 100644 --- a/charts/community-operator/values.yaml +++ b/charts/community-operator/values.yaml @@ -48,6 +48,26 @@ operator: securityContext: {} + affinity: + podAntiAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchExpressions: + - key: name + operator: In + values: + - mongodb-kubernetes-operator + topologyKey: kubernetes.io/hostname + + nodeSelector: {} + + schedulerName: "" + + tolerations: [] + + topologySpreadConstraints: [] + + ## Operator's database database: name: mongodb-database From 505cd9acbf480aa0e3fded5394d70fb038e33934 Mon Sep 17 00:00:00 2001 From: MaesterZ <22374424+MaesterZ@users.noreply.github.com> Date: Thu, 27 Jun 2024 12:57:52 +0200 Subject: [PATCH 2/2] Spacing --- charts/community-operator/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/community-operator/values.yaml b/charts/community-operator/values.yaml index 15bafb86..d7df611b 100644 --- a/charts/community-operator/values.yaml +++ b/charts/community-operator/values.yaml @@ -2,6 +2,7 @@ ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ imagePullSecrets: [] # - name: "image-pull-secret" + ## Operator operator: # Name that will be assigned to most of internal Kubernetes objects like @@ -67,7 +68,6 @@ operator: topologySpreadConstraints: [] - ## Operator's database database: name: mongodb-database