Skip to content

Commit

Permalink
feat(meta): support existingConfigMap (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
everpcpc authored Jun 6, 2024
1 parent 09470f7 commit 835c02f
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 61 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- Deployment
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install k3d
shell: bash
Expand All @@ -38,7 +38,7 @@ jobs:
k3d cluster create databend
kubectl cluster-info
- uses: azure/setup-helm@v3
- uses: azure/setup-helm@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down
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.7.5
version: 0.8.0

# 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
21 changes: 21 additions & 0 deletions charts/databend-meta/templates/_config.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{- define "common.metaConfig" -}}
admin_api_address = "0.0.0.0:{{ .Values.service.ports.admin }}"
grpc_api_address = "0.0.0.0:{{ .Values.service.ports.grpc }}"

[log]
[log.stderr]
on = true
level = {{ .Values.config.stdLogLevel | quote }}
[log.file]
level = {{ .Values.config.logLevel | quote }}
format = "json"
dir = {{ .Values.config.logDir | quote }}

[raft_config]
cluster_name = {{ .Values.config.clusterName | quote }}
raft_dir = {{ .Values.config.raft.dir | quote }}
raft_listen_host = "0.0.0.0"
raft_api_port = 28004
max_applied_log_to_keep = 102400
install_snapshot_timeout = 60000
{{- end }}
11 changes: 11 additions & 0 deletions charts/databend-meta/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{- if not .Values.existingConfigMaps }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "databend-meta.fullname" . }}
labels:
{{- include "databend-meta.labels" . | nindent 4 }}
data:
meta.yaml: |
{{- include "common.metaConfig" . | nindent 4 }}
{{- end }}
92 changes: 36 additions & 56 deletions charts/databend-meta/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,77 +46,47 @@ spec:
echo "check if my service is running and run commands ";
if [[ $POD_NAME =~ (.*)-([0-9]+)$ ]]
then
NAME=${BASH_REMATCH[1]}
ID=${BASH_REMATCH[2]}
NAME=${BASH_REMATCH[1]}
echo "ID: $ID" "NAME : $NAME"
{{- if $bootstrap }}
case ${BASH_REMATCH[2]} in
0)
echo "initialize leader node";
exec /databend-meta --id ${ID} \
--log-stderr-on \
--log-stderr-level "{{ .Values.config.stdLogLevel }}" \
--log-file-level "{{ .Values.config.logLevel }}" \
--log-file-dir "{{ .Values.config.logDir }}" \
--max-applied-log-to-keep 102400 \
--raft-dir "{{ .Values.config.raft.dir }}" \
--admin-api-address 0.0.0.0:28002 \
--grpc-api-address 0.0.0.0:9191 \
--raft-api-port 28004 \
--raft-listen-host 0.0.0.0 \
--raft-advertise-host ${POD_NAME}.{{ $fullName }}.${POD_NAMESPACE}.svc.cluster.local \
--grpc-api-advertise-host ${POD_NAME}.{{ $fullName }}.${POD_NAMESPACE}.svc.cluster.local \
--config-id ${ID} \
--single
0)
echo "initialize leader node";
exec /databend-meta --id ${ID} --config-id ${ID} \
--single \
--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
;;
*)
echo "initialize follower node";
exec /databend-meta --id ${ID} \
--log-stderr-on \
--log-stderr-level "{{ .Values.config.stdLogLevel }}" \
--log-file-level "{{ .Values.config.logLevel }}" \
--log-file-dir "{{ .Values.config.logDir }}" \
--max-applied-log-to-keep 102400 \
--raft-dir "{{ .Values.config.raft.dir }}" \
--admin-api-address 0.0.0.0:28002 \
--grpc-api-address 0.0.0.0:9191 \
--raft-api-port 28004 \
--raft-listen-host 0.0.0.0 \
--raft-advertise-host ${POD_NAME}.{{ $fullName }}.${POD_NAMESPACE}.svc.cluster.local \
--grpc-api-advertise-host ${POD_NAME}.{{ $fullName }}.${POD_NAMESPACE}.svc.cluster.local \
--config-id ${ID} \
--join ${NAME}-0.{{ $fullName }}.${POD_NAMESPACE}.svc.cluster.local:28004
*)
echo "initialize follower node";
exec /databend-meta --id ${ID} --config-id ${ID} \
--join "${NAME}-0.{{ $fullName }}.${POD_NAMESPACE}.svc.cluster.local:28004" \
--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
;;
esac
{{- else }}
exec /databend-meta --id ${ID} \
--log-stderr-on \
--log-stderr-level "{{ .Values.config.stdLogLevel }}" \
--log-file-level "{{ .Values.config.logLevel }}" \
--log-file-dir "{{ .Values.config.logDir }}" \
--max-applied-log-to-keep 102400 \
--raft-dir "{{ .Values.config.raft.dir }}" \
--admin-api-address 0.0.0.0:28002 \
--grpc-api-address 0.0.0.0:9191 \
--raft-api-port 28004 \
--raft-listen-host 0.0.0.0 \
--raft-advertise-host ${POD_NAME}.{{ $fullName }}.${POD_NAMESPACE}.svc.cluster.local \
--grpc-api-advertise-host ${POD_NAME}.{{ $fullName }}.${POD_NAMESPACE}.svc.cluster.local \
{{- range $i := until $replicaCount }}
--join ${NAME}-{{ $i }}.{{ $fullName }}.${POD_NAMESPACE}.svc.cluster.local:28004 \
{{- end }}
--config-id ${ID}
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 }}
else
echo pod name $POD_NAME is not valid && exit 1
fi
ports:
- name: admin
containerPort: 28002
{{- range $key, $val := .Values.service.ports }}
- name: {{ $key }}
containerPort: {{ $val }}
{{- end }}
- name: raft
containerPort: 28004
- name: grpc
containerPort: 9191
livenessProbe:
httpGet:
path: /v1/health
Expand All @@ -143,6 +113,8 @@ spec:
{{- toYaml . | nindent 12 }}
{{- end }}
volumeMounts:
- name: config
mountPath: /etc/databend
{{- if .Values.persistence.enabled }}
- name: data
mountPath: {{ .Values.persistence.mountPath }}
Expand All @@ -162,6 +134,14 @@ spec:
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: config
configMap:
{{- if .Values.existingConfigMaps }}
name: {{ .Values.existingConfigMap }}
{{- else }}
name: {{ include "databend-meta.fullname" . }}
{{- end }}
{{- if .Values.persistence.enabled }}
volumeClaimTemplates:
- metadata:
Expand Down
5 changes: 4 additions & 1 deletion charts/databend-meta/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,17 @@ serviceMonitor:
enabled: false
port: admin

# would be ignored if `existingConfigMap` is set
config:
clusterName: databend
logDir: /data/databend-meta/log
logLevel: INFO
stdLogLevel: WARN

raft:
dir: /data/databend-meta/raft

existingConfigMap: ""

envs: []

persistence:
Expand Down
2 changes: 1 addition & 1 deletion charts/databend-query/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ version: 0.9.1
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "v1.2.371"
appVersion: "v1.2.453"

dependencies:
- name: common
Expand Down

0 comments on commit 835c02f

Please sign in to comment.