Skip to content

Commit

Permalink
feat(meta): add startup script and new volume features (#107)
Browse files Browse the repository at this point in the history
* adds custom startup script capability

* Add blank values for new features
  • Loading branch information
kkapper authored Sep 18, 2024
1 parent 38cb5eb commit 0817974
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion charts/databend-meta/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 17 additions & 3 deletions charts/databend-meta/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,17 @@ 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]+)$ ]]
then
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";
Expand All @@ -71,18 +74,19 @@ 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" \
{{- end }}
--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 }}
Expand Down Expand Up @@ -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 }}
Expand All @@ -137,6 +144,10 @@ spec:
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.topologySpreadConstraints }}
topologySpreadConstraints:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: config
configMap:
Expand All @@ -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:
Expand Down
9 changes: 9 additions & 0 deletions charts/databend-meta/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
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

extraVolumes: []
extraVolumeMounts: []

topologySpreadConstraints: []

image:
repository: datafuselabs/databend-meta
pullPolicy: IfNotPresent
Expand Down

0 comments on commit 0817974

Please sign in to comment.