From b2d82d7ed9510d51ad534d6042fc32dd3f43e8b1 Mon Sep 17 00:00:00 2001 From: Kellen Kapper Date: Tue, 17 Sep 2024 10:47:41 -0400 Subject: [PATCH] adds custom startup script capability --- charts/databend-meta/Chart.yaml | 2 +- .../databend-meta/templates/statefulset.yaml | 20 ++++++++++++++++--- charts/databend-meta/values.yaml | 4 ++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/charts/databend-meta/Chart.yaml b/charts/databend-meta/Chart.yaml index 68630b3..f79a58c 100644 --- a/charts/databend-meta/Chart.yaml +++ b/charts/databend-meta/Chart.yaml @@ -26,7 +26,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.9.3 +version: 0.9.4 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/databend-meta/templates/statefulset.yaml b/charts/databend-meta/templates/statefulset.yaml index 1e0b59b..f9932c9 100644 --- a/charts/databend-meta/templates/statefulset.yaml +++ b/charts/databend-meta/templates/statefulset.yaml @@ -45,6 +45,9 @@ spec: imagePullPolicy: {{ .Values.image.pullPolicy }} command: ["/bin/bash", "-c"] args: + {{- if .Values.customStartupScript }} + - {{ .Values.customStartupScript }} + {{- else }} - | echo "check if my service is running and run commands "; if [[ $POD_NAME =~ (.*)-([0-9]+)$ ]] @@ -52,7 +55,7 @@ spec: ID=${BASH_REMATCH[2]} NAME=${BASH_REMATCH[1]} echo "ID: $ID" "NAME : $NAME" - {{- if $bootstrap }} + {{- if $bootstrap }} case ${BASH_REMATCH[2]} in 0) echo "initialize leader node"; @@ -71,7 +74,7 @@ spec: --config-file /etc/databend/meta.yaml ;; esac - {{- else }} + {{- else }} exec /databend-meta --id ${ID} --config-id ${ID} \ {{- range $i := until $replicaCount }} --join "${NAME}-{{ $i }}.{{ $fullName }}.${POD_NAMESPACE}.svc.cluster.local:28004" \ @@ -79,10 +82,11 @@ spec: --raft-advertise-host "${POD_NAME}.{{ $fullName }}.${POD_NAMESPACE}.svc.cluster.local" \ --grpc-api-advertise-host "${POD_NAME}.{{ $fullName }}.${POD_NAMESPACE}.svc.cluster.local" \ --config-file /etc/databend/meta.yaml - {{- end }} + {{- end }} else echo pod name $POD_NAME is not valid && exit 1 fi + {{- end }} ports: {{- range $key, $val := .Values.service.ports }} - name: {{ $key }} @@ -122,6 +126,9 @@ spec: - name: data mountPath: {{ .Values.persistence.mountPath }} {{- end }} + {{- if .Values.extraVolumeMounts }} + {{- include "common.tplvalues.render" (dict "value" .Values.extraVolumeMounts "context" $) | nindent 12 }} + {{- end }} {{- if .Values.sidecars }} {{- include "common.tplvalues.render" (dict "value" .Values.sidecars "context" $) | nindent 8 }} {{- end }} @@ -137,6 +144,10 @@ spec: tolerations: {{- toYaml . | nindent 8 }} {{- end }} + {{- with .Values.topologySpreadConstraints }} + topologySpreadConstraints: + {{- toYaml . | nindent 8 }} + {{- end }} volumes: - name: config configMap: @@ -145,6 +156,9 @@ spec: {{- else }} name: {{ include "databend-meta.fullname" . }} {{- end }} + {{- if .Values.extraVolumes }} + {{- include "common.tplvalues.render" (dict "value" .Values.extraVolumes "context" $) | nindent 8 }} + {{- end }} {{- if .Values.persistence.enabled }} volumeClaimTemplates: - metadata: diff --git a/charts/databend-meta/values.yaml b/charts/databend-meta/values.yaml index 7e0ccc0..4958b79 100644 --- a/charts/databend-meta/values.yaml +++ b/charts/databend-meta/values.yaml @@ -5,6 +5,10 @@ bootstrap: false replicaCount: 1 +# This value should be the name of the file containing the statup script for your Databend-meta pods. +# You will still need to mount your script as an extra volumes. +customStartupScript: false + image: repository: datafuselabs/databend-meta pullPolicy: IfNotPresent