From 26e818896bc082ea2a780538dc4c27869f7dde44 Mon Sep 17 00:00:00 2001 From: ericsyh Date: Tue, 26 Nov 2024 13:35:59 +0800 Subject: [PATCH 1/4] fix: support some missting configs Signed-off-by: ericsyh --- .../templates/grafana/grafana-deployment.yaml | 2 ++ .../streamnative-console-initialize.yaml | 3 +++ .../streamnative-console-statefulset.yaml | 2 ++ charts/sn-platform-slim/values.yaml | 16 +++++++++++++++- 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/charts/sn-platform-slim/templates/grafana/grafana-deployment.yaml b/charts/sn-platform-slim/templates/grafana/grafana-deployment.yaml index 33073324..d32bd09f 100644 --- a/charts/sn-platform-slim/templates/grafana/grafana-deployment.yaml +++ b/charts/sn-platform-slim/templates/grafana/grafana-deployment.yaml @@ -50,6 +50,8 @@ spec: tolerations: {{ toYaml .Values.grafana.tolerations | indent 8 }} {{- end }} + affinity: + {{- include "pulsar.antiAffinityRules" (dict "Values" .Values "thisAffinity" .Values.grafana.affinity "Component" .Values.grafana.component "Release" .Release "Chart" .Chart) | indent 8 }} terminationGracePeriodSeconds: {{ .Values.grafana.gracePeriod }} containers: - name: "{{ template "pulsar.fullname" . }}-{{ .Values.grafana.component }}" diff --git a/charts/sn-platform-slim/templates/streamnative-console/streamnative-console-initialize.yaml b/charts/sn-platform-slim/templates/streamnative-console/streamnative-console-initialize.yaml index 70395e61..02970a56 100644 --- a/charts/sn-platform-slim/templates/streamnative-console/streamnative-console-initialize.yaml +++ b/charts/sn-platform-slim/templates/streamnative-console/streamnative-console-initialize.yaml @@ -21,6 +21,9 @@ spec: {{- if .Values.global.imagePullSecrets }} imagePullSecrets: {{- toYaml .Values.global.imagePullSecrets | nindent 8 }} {{- end }} + {{- if .Values.streamnative_console.nodeSelector }} + nodeSelector: {{- toYaml .Values.streamnative_console.nodeSelector | nindent 8 }} + {{- end }} {{- if not .Values.istio.enabled }} initContainers: # This init container will wait for broker to be ready before diff --git a/charts/sn-platform-slim/templates/streamnative-console/streamnative-console-statefulset.yaml b/charts/sn-platform-slim/templates/streamnative-console/streamnative-console-statefulset.yaml index 610b6815..0d32258e 100644 --- a/charts/sn-platform-slim/templates/streamnative-console/streamnative-console-statefulset.yaml +++ b/charts/sn-platform-slim/templates/streamnative-console/streamnative-console-statefulset.yaml @@ -288,6 +288,8 @@ spec: {{- if .Values.streamnative_console.serviceAccount.use }} serviceAccountName: {{ template "pulsar.streamnative_console.serviceAccount" . }} {{- end }} + affinity: + {{- include "pulsar.antiAffinityRules" (dict "Values" .Values "thisAffinity" .Values.streamnative_console.affinity "Component" .Values.streamnative_console.component "Release" .Release "Chart" .Chart) | indent 8 }} {{- if or .Values.streamnative_console.volumes.data.storageClass .Values.streamnative_console.volumes.data.storageClassName }} volumeClaimTemplates: - metadata: diff --git a/charts/sn-platform-slim/values.yaml b/charts/sn-platform-slim/values.yaml index 5bf2d1ce..6015d527 100644 --- a/charts/sn-platform-slim/values.yaml +++ b/charts/sn-platform-slim/values.yaml @@ -1703,7 +1703,6 @@ prometheus: requests: memory: 256Mi cpu: 0.1 - # Definition of the serviceAccount used to run brokers. affinity: anti_affinity: true zone_anti_affinity: true @@ -1711,6 +1710,7 @@ prometheus: # requiredDuringSchedulingIgnoredDuringExecution - rules must be met for pod to be scheduled (hard) requires at least one node per replica # preferredDuringSchedulingIgnoredDuringExecution - scheduler will try to enforce but not guranentee type: preferredDuringSchedulingIgnoredDuringExecution + # Definition of the serviceAccount used to run brokers. serviceAccount: # Specifies whether to use a service account to run this component use: true @@ -1863,6 +1863,13 @@ grafana: requests: memory: 250Mi cpu: 0.1 + affinity: + anti_affinity: true + zone_anti_affinity: true + # Set the anti affinity type. Valid values: + # requiredDuringSchedulingIgnoredDuringExecution - rules must be met for pod to be scheduled (hard) requires at least one node per replica + # preferredDuringSchedulingIgnoredDuringExecution - scheduler will try to enforce but not guranentee + type: preferredDuringSchedulingIgnoredDuringExecution volumes: # use a persistent volume or emptyDir persistence: true @@ -2018,6 +2025,13 @@ streamnative_console: limits: {} # memory: "1Gi" # cpu: "0.4" + affinity: + anti_affinity: true + zone_anti_affinity: true + # Set the anti affinity type. Valid values: + # requiredDuringSchedulingIgnoredDuringExecution - rules must be met for pod to be scheduled (hard) requires at least one node per replica + # preferredDuringSchedulingIgnoredDuringExecution - scheduler will try to enforce but not guranentee + type: preferredDuringSchedulingIgnoredDuringExecution volumes: # use a persistent volume or emptyDir persistence: true From 50cccb65033db271800a91ce9d61a238befc0500 Mon Sep 17 00:00:00 2001 From: ericsyh Date: Tue, 26 Nov 2024 13:41:33 +0800 Subject: [PATCH 2/4] update Signed-off-by: ericsyh --- .../streamnative-console-initialize.yaml | 5 +++++ .../streamnative-console-statefulset.yaml | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/charts/sn-platform-slim/templates/streamnative-console/streamnative-console-initialize.yaml b/charts/sn-platform-slim/templates/streamnative-console/streamnative-console-initialize.yaml index 02970a56..ca9fb8a6 100644 --- a/charts/sn-platform-slim/templates/streamnative-console/streamnative-console-initialize.yaml +++ b/charts/sn-platform-slim/templates/streamnative-console/streamnative-console-initialize.yaml @@ -24,6 +24,11 @@ spec: {{- if .Values.streamnative_console.nodeSelector }} nodeSelector: {{- toYaml .Values.streamnative_console.nodeSelector | nindent 8 }} {{- end }} + {{- if .Values.streamnative_console.tolerations }} + tolerations: {{- toYaml .Values.streamnative_console.tolerations | nindent 8 }} + {{- end }} + affinity: + {{- include "pulsar.antiAffinityRules" (dict "Values" .Values "thisAffinity" .Values.streamnative_console.affinity "Component" .Values.streamnative_console.component "Release" .Release "Chart" .Chart) | indent 8 }} {{- if not .Values.istio.enabled }} initContainers: # This init container will wait for broker to be ready before diff --git a/charts/sn-platform-slim/templates/streamnative-console/streamnative-console-statefulset.yaml b/charts/sn-platform-slim/templates/streamnative-console/streamnative-console-statefulset.yaml index 0d32258e..e1d23068 100644 --- a/charts/sn-platform-slim/templates/streamnative-console/streamnative-console-statefulset.yaml +++ b/charts/sn-platform-slim/templates/streamnative-console/streamnative-console-statefulset.yaml @@ -52,6 +52,8 @@ spec: tolerations: {{ toYaml .Values.streamnative_console.tolerations | indent 8 }} {{- end }} + affinity: + {{- include "pulsar.antiAffinityRules" (dict "Values" .Values "thisAffinity" .Values.streamnative_console.affinity "Component" .Values.streamnative_console.component "Release" .Release "Chart" .Chart) | indent 8 }} terminationGracePeriodSeconds: {{ .Values.streamnative_console.gracePeriod }} {{- if not .Values.istio.enabled }} initContainers: @@ -288,8 +290,6 @@ spec: {{- if .Values.streamnative_console.serviceAccount.use }} serviceAccountName: {{ template "pulsar.streamnative_console.serviceAccount" . }} {{- end }} - affinity: - {{- include "pulsar.antiAffinityRules" (dict "Values" .Values "thisAffinity" .Values.streamnative_console.affinity "Component" .Values.streamnative_console.component "Release" .Release "Chart" .Chart) | indent 8 }} {{- if or .Values.streamnative_console.volumes.data.storageClass .Values.streamnative_console.volumes.data.storageClassName }} volumeClaimTemplates: - metadata: From d559deee53bd4a32129b1a8e2079941c2b3c3e81 Mon Sep 17 00:00:00 2001 From: ericsyh Date: Tue, 26 Nov 2024 13:47:39 +0800 Subject: [PATCH 3/4] apply on sn-platform Signed-off-by: ericsyh --- .../templates/grafana/grafana-statefulset.yaml | 2 ++ .../streamnative-console-initialize.yaml | 9 +++++++++ .../streamnative-console-statefulset.yaml | 2 ++ charts/sn-platform/values.yaml | 16 +++++++++++++++- 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/charts/sn-platform/templates/grafana/grafana-statefulset.yaml b/charts/sn-platform/templates/grafana/grafana-statefulset.yaml index 99683f0c..1856c21c 100644 --- a/charts/sn-platform/templates/grafana/grafana-statefulset.yaml +++ b/charts/sn-platform/templates/grafana/grafana-statefulset.yaml @@ -48,6 +48,8 @@ spec: tolerations: {{ toYaml .Values.grafana.tolerations | indent 8 }} {{- end }} + affinity: + {{- include "pulsar.antiAffinityRules" (dict "Values" .Values "thisAffinity" .Values.grafana.affinity "Component" .Values.grafana.component "Release" .Release "Chart" .Chart) | indent 8 }} terminationGracePeriodSeconds: {{ .Values.grafana.gracePeriod }} {{- if .Values.grafana.volumes.securityContext }} securityContext: diff --git a/charts/sn-platform/templates/streamnative-console/streamnative-console-initialize.yaml b/charts/sn-platform/templates/streamnative-console/streamnative-console-initialize.yaml index 50fe8e38..885c3c4d 100644 --- a/charts/sn-platform/templates/streamnative-console/streamnative-console-initialize.yaml +++ b/charts/sn-platform/templates/streamnative-console/streamnative-console-initialize.yaml @@ -21,6 +21,15 @@ spec: {{- if .Values.global.imagePullSecrets }} imagePullSecrets: {{- toYaml .Values.global.imagePullSecrets | nindent 8 }} {{- end }} + {{- if .Values.streamnative_console.nodeSelector }} + nodeSelector: {{- toYaml .Values.streamnative_console.nodeSelector | nindent 8 }} + {{- end }} + {{- if .Values.streamnative_console.tolerations }} + tolerations: {{- toYaml .Values.streamnative_console.tolerations | nindent 8 }} + {{- end }} + affinity: + {{- include "pulsar.antiAffinityRules" (dict "Values" .Values "thisAffinity" .Values.streamnative_console.affinity "Component" .Values.streamnative_console.component "Release" .Release "Chart" .Chart) | indent 8 }} + {{- if not .Values.istio.enabled }} {{- if not .Values.istio.enabled }} initContainers: # This init container will wait for broker to be ready before diff --git a/charts/sn-platform/templates/streamnative-console/streamnative-console-statefulset.yaml b/charts/sn-platform/templates/streamnative-console/streamnative-console-statefulset.yaml index 8a0fdb33..503af6cb 100644 --- a/charts/sn-platform/templates/streamnative-console/streamnative-console-statefulset.yaml +++ b/charts/sn-platform/templates/streamnative-console/streamnative-console-statefulset.yaml @@ -52,6 +52,8 @@ spec: tolerations: {{ toYaml .Values.streamnative_console.tolerations | indent 8 }} {{- end }} + affinity: + {{- include "pulsar.antiAffinityRules" (dict "Values" .Values "thisAffinity" .Values.streamnative_console.affinity "Component" .Values.streamnative_console.component "Release" .Release "Chart" .Chart) | indent 8 }} terminationGracePeriodSeconds: {{ .Values.streamnative_console.gracePeriod }} {{- if not .Values.istio.enabled }} initContainers: diff --git a/charts/sn-platform/values.yaml b/charts/sn-platform/values.yaml index f1b49c36..92b9e363 100644 --- a/charts/sn-platform/values.yaml +++ b/charts/sn-platform/values.yaml @@ -1784,7 +1784,6 @@ prometheus: requests: memory: 256Mi cpu: 0.1 - # Definition of the serviceAccount used to run brokers. affinity: anti_affinity: true zone_anti_affinity: true @@ -1792,6 +1791,7 @@ prometheus: # requiredDuringSchedulingIgnoredDuringExecution - rules must be met for pod to be scheduled (hard) requires at least one node per replica # preferredDuringSchedulingIgnoredDuringExecution - scheduler will try to enforce but not guranentee type: preferredDuringSchedulingIgnoredDuringExecution + # Definition of the serviceAccount used to run brokers. serviceAccount: # Specifies whether to use a service account to run this component use: true @@ -1944,6 +1944,13 @@ grafana: labels: {} annotations: {} tolerations: [] + affinity: + anti_affinity: true + zone_anti_affinity: true + # Set the anti affinity type. Valid values: + # requiredDuringSchedulingIgnoredDuringExecution - rules must be met for pod to be scheduled (hard) requires at least one node per replica + # preferredDuringSchedulingIgnoredDuringExecution - scheduler will try to enforce but not guranentee + type: preferredDuringSchedulingIgnoredDuringExecution gracePeriod: 0 port: 3000 resources: @@ -2097,6 +2104,13 @@ streamnative_console: podLabels: {} podAnnotations: {} tolerations: [] + affinity: + anti_affinity: true + zone_anti_affinity: true + # Set the anti affinity type. Valid values: + # requiredDuringSchedulingIgnoredDuringExecution - rules must be met for pod to be scheduled (hard) requires at least one node per replica + # preferredDuringSchedulingIgnoredDuringExecution - scheduler will try to enforce but not guranentee + type: preferredDuringSchedulingIgnoredDuringExecution gracePeriod: 0 # Resources requests/limits for both init containers and app containers # See https://kubernetes.io/docs/concepts/workloads/pods/init-containers/#resources From 53402f763c6e583a106a46872d7927712f51a7b4 Mon Sep 17 00:00:00 2001 From: ericsyh Date: Tue, 26 Nov 2024 13:51:36 +0800 Subject: [PATCH 4/4] support vault init jobs Signed-off-by: ericsyh --- .../vault/vault-initialize-public-key.yaml | 13 +++++++++++++ .../templates/vault/vault-initialize.yaml | 10 ++++++++++ 2 files changed, 23 insertions(+) diff --git a/charts/sn-platform/templates/vault/vault-initialize-public-key.yaml b/charts/sn-platform/templates/vault/vault-initialize-public-key.yaml index 4139a306..017b17ac 100644 --- a/charts/sn-platform/templates/vault/vault-initialize-public-key.yaml +++ b/charts/sn-platform/templates/vault/vault-initialize-public-key.yaml @@ -26,6 +26,19 @@ spec: {{- end }} spec: serviceAccountName: {{ template "pulsar.vault.serviceAccount" . }} + {{- if .Values.global.imagePullSecrets }} + imagePullSecrets: {{- toYaml .Values.global.imagePullSecrets | nindent 8 }} + {{- end }} + {{- if .Values.vault.tolerations }} + tolerations: + {{ toYaml .Values.vault.tolerations | indent 8 }} + {{- end }} + {{- if .Values.vault.nodeSelector }} + nodeSelector: + {{ toYaml .Values.vault.nodeSelector | indent 8 }} + {{- end }} + affinity: + {{- include "pulsar.antiAffinityRules" (dict "Values" .Values "thisAffinity" .Values.vault.affinity "Component" .Values.vault.component "Release" .Release "Chart" .Chart) | indent 8 }} containers: - name: "{{ template "pulsar.fullname" . }}-{{ .Values.vault.component }}-init" image: "{{ .Values.images.vault_init.repository }}:{{ .Values.images.vault_init.tag }}" diff --git a/charts/sn-platform/templates/vault/vault-initialize.yaml b/charts/sn-platform/templates/vault/vault-initialize.yaml index 02e6a2f6..6a71986a 100644 --- a/charts/sn-platform/templates/vault/vault-initialize.yaml +++ b/charts/sn-platform/templates/vault/vault-initialize.yaml @@ -29,6 +29,16 @@ spec: {{- if .Values.global.imagePullSecrets }} imagePullSecrets: {{- toYaml .Values.global.imagePullSecrets | nindent 8 }} {{- end }} + {{- if .Values.vault.tolerations }} + tolerations: + {{ toYaml .Values.vault.tolerations | indent 8 }} + {{- end }} + {{- if .Values.vault.nodeSelector }} + nodeSelector: + {{ toYaml .Values.vault.nodeSelector | indent 8 }} + {{- end }} + affinity: + {{- include "pulsar.antiAffinityRules" (dict "Values" .Values "thisAffinity" .Values.vault.affinity "Component" .Values.vault.component "Release" .Release "Chart" .Chart) | indent 8 }} containers: - name: "{{ template "pulsar.fullname" . }}-{{ .Values.vault.component }}-init" image: "{{ .Values.images.vault_init.repository }}:{{ .Values.images.vault_init.tag }}"