Skip to content

Commit

Permalink
feat: support sql meta backends and local fs state store backend
Browse files Browse the repository at this point in the history
Signed-off-by: arkbriar <[email protected]>
  • Loading branch information
arkbriar committed Mar 14, 2024
1 parent 512b3ad commit 4d782f7
Show file tree
Hide file tree
Showing 24 changed files with 1,430 additions and 131 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test:
@$(foreach chart,$(HELM_CHARTS),helm unittest --strict -f 'tests/**/*_test.yaml' charts/$(chart);)

define test-uncommitted-for-chart
$(eval uncommitted_files := $(shell git diff --name-status head -- charts/$(1)/tests | grep -v '^D' | awk '{print $$2}' | sed -e "s/charts\/$(1)\///g"))
$(eval uncommitted_files := $(shell git diff --name-status head -- charts/$(1)/tests | grep -v '^D' | awk '{print $$NF}' | sed -e "s/charts\/$(1)\///g"))
if [ "$(uncommitted_files)" != "" ]; then \
helm unittest --strict $(addprefix -f ,$(uncommitted_files)) charts/$(1); \
fi
Expand Down
70 changes: 69 additions & 1 deletion charts/risingwave/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ T
{{- end }}

{{/*
Create the name of the etcd credentials Secret to use
Create the name of the etcd credentials Secret to use.
*/}}
{{- define "risingwave.etcdCredentialsSecretName" -}}
{{- if .Values.metaStore.etcd.authentication.existingSecretName }}
Expand All @@ -107,6 +107,29 @@ Create the name of the etcd credentials Secret to use
{{- end }}
{{- end }}


{{/*
Create the name of the PostgreSQL credentials Secret to use.
*/}}
{{- define "risingwave.postgresCredentialsSecretName" -}}
{{- if .Values.metaStore.postgresql.authentication.existingSecretName }}
{{- .Values.metaStore.postgresql.authentication.existingSecretName }}
{{- else }}
{{- printf "%s-postgres" (include "risingwave.fullname" .) | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}

{{/*
Create the name of the MySQL credentials Secret to use.
*/}}
{{- define "risingwave.mysqlCredentialsSecretName" -}}
{{- if .Values.metaStore.mysql.authentication.existingSecretName }}
{{- .Values.metaStore.mysql.authentication.existingSecretName }}
{{- else }}
{{- printf "%s-mysql" (include "risingwave.fullname" .) | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}

{{/*
Create the name of the S3 credentials Secret to use
*/}}
Expand Down Expand Up @@ -200,6 +223,49 @@ Create the meta backend type string to use.
{{- define "risingwave.metaBackend" -}}
{{- if or (include "risingwave.bundle.etcd.enabled" .) .Values.metaStore.etcd.enabled }}
{{- print "etcd" }}
{{- else if or .Values.metaStore.sqlite.enabled .Values.metaStore.postgresql.enabled .Values.metaStore.mysql.enabled }}
{{- print "sql" }}
{{- else }}
{{- print "" }}
{{- end }}
{{- end }}
{{/*
Convert connection options.
*/}}
{{- define "common.convertConnectionOptions" -}}
{{- $list := list -}}
{{- range $k, $v := . -}}
{{- $list = append $list (printf "%s=%s" $k (urlquery $v)) -}}
{{- end -}}
{{ join "&" $list }}
{{- end -}}
{{/*
Create the SQL endpoint string to use.
*/}}
{{- define "risingwave.sqlEndpoint" -}}
{{- if .Values.metaStore.sqlite.enabled }}
{{- printf "sqlite://%s?mode=rwc" .Values.metaStore.sqlite.path }}
{{- else if .Values.metaStore.postgresql.enabled }}
{{- if .Values.metaStore.postgresql.options }}
{{- printf "postgres://$(RW_POSTGRES_USERNAME):$(RW_POSTGRES_PASSWORD)@%s:%d/%s?%s"
.Values.metaStore.postgresql.host (.Values.metaStore.postgresql.port | int) .Values.metaStore.postgresql.database
(include "common.convertConnectionOptions" .Values.metaStore.postgresql.options) }}
{{- else }}
{{- printf "postgres://$(RW_POSTGRES_USERNAME):$(RW_POSTGRES_PASSWORD)@%s:%d/%s"
.Values.metaStore.postgresql.host (.Values.metaStore.postgresql.port | int) .Values.metaStore.postgresql.database }}
{{- end }}
{{- else if .Values.metaStore.mysql.enabled }}
{{- if .Values.metaStore.mysql.options }}
{{- printf "mysql://$(RW_MYSQL_USERNAME):$(RW_MYSQL_PASSWORD)@%s:%d/%s?%s"
.Values.metaStore.mysql.host (.Values.metaStore.mysql.port | int) .Values.metaStore.mysql.database
(include "common.convertConnectionOptions" .Values.metaStore.mysql.options) }}
{{- else }}
{{- printf "mysql://$(RW_MYSQL_USERNAME):$(RW_MYSQL_PASSWORD)@%s:%d/%s"
.Values.metaStore.mysql.host (.Values.metaStore.mysql.port | int) .Values.metaStore.mysql.database }}
{{- end }}
{{- else }}
{{- print "" }}
{{- end }}
Expand Down Expand Up @@ -230,6 +296,8 @@ Create the hummock connection string to use.
{{- printf "hummock+hdfs://%s" .Values.stateStore.hdfs.nameNode }}
{{- else if .Values.stateStore.obs.enabled }}
{{- printf "hummock+obs://%s" .Values.stateStore.obs.bucket }}
{{- else if .Values.stateStore.localFs.enabled }}
{{- printf "hummock+fs://%s" .Values.stateStore.localFs.path }}
{{- else }}
{{- print "" }}
{{- end }}
Expand Down
8 changes: 8 additions & 0 deletions charts/risingwave/templates/compute-sts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ spec:
maxUnavailable: "100%"
podManagementPolicy: Parallel
minReadySeconds: 0
{{- if .Values.computeComponent.volumeClaimTemplates }}
volumeClaimTemplates:
{{- toYaml .Values.computeComponent.volumeClaimTemplates | nindent 2 }}
{{- end }}
{{- if .Values.computeComponent.persistentVolumeClaimRetentionPolicy }}
persistentVolumeClaimRetentionPolicy:
{{- toYaml .Values.computeComponent.persistentVolumeClaimRetentionPolicy | nindent 4 }}
{{- end }}
template:
metadata:
labels:
Expand Down
45 changes: 45 additions & 0 deletions charts/risingwave/templates/meta-sts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ spec:
maxUnavailable: "100%"
podManagementPolicy: Parallel
minReadySeconds: 0
{{- if .Values.metaComponent.volumeClaimTemplates }}
volumeClaimTemplates:
{{- toYaml .Values.metaComponent.volumeClaimTemplates | nindent 2 }}
{{- end }}
{{- if .Values.metaComponent.persistentVolumeClaimRetentionPolicy }}
persistentVolumeClaimRetentionPolicy:
{{- toYaml .Values.metaComponent.persistentVolumeClaimRetentionPolicy | nindent 4 }}
{{- end }}
template:
metadata:
labels:
Expand Down Expand Up @@ -137,6 +145,14 @@ spec:
- secretRef:
name: {{ include "risingwave.etcdCredentialsSecretName" . }}
{{- end }}
{{- if .Values.metaStore.postgresql.enabled }}
- secretRef:
name: {{ include "risingwave.postgresCredentialsSecretName" . }}
{{- end }}
{{- if .Values.metaStore.mysql.enabled }}
- secretRef:
name: {{ include "risingwave.mysqlCredentialsSecretName" . }}
{{- end }}
env:
# Disable auto region loading. Refer to the original source for more information.
# https://github.com/awslabs/aws-sdk-rust/blob/main/sdk/aws-config/src/imds/region.rs
Expand Down Expand Up @@ -254,6 +270,35 @@ spec:
{{- if .Values.metaComponent.extraEnvVars }}
{{- .Values.metaComponent.extraEnvVars | toYaml | nindent 8 }}
{{- end }}
# SQL meta backend.
{{- if and .Values.metaStore.postgresql.enabled .Values.metaStore.postgresql.authentication.existingSecretName }}
- name: RW_POSTGRES_USERNAME
valueFrom:
secretKeyRef:
key: username
name: {{ .Values.metaStore.postgresql.authentication.existingSecretName }}
- name: RW_POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
key: password
name: {{ .Values.metaStore.postgresql.authentication.existingSecretName }}
{{- end }}
{{- if and .Values.metaStore.mysql.enabled .Values.metaStore.mysql.authentication.existingSecretName }}
- name: RW_MYSQL_USERNAME
valueFrom:
secretKeyRef:
key: username
name: {{ .Values.metaStore.mysql.authentication.existingSecretName }}
- name: RW_MYSQL_PASSWORD
valueFrom:
secretKeyRef:
key: password
name: {{ .Values.metaStore.mysql.authentication.existingSecretName }}
{{- end }}
{{- if eq (include "risingwave.metaBackend" . ) "sql" }}
- name: RW_SQL_ENDPOINT
value: {{ include "risingwave.sqlEndpoint" . }}
{{- end }}
resources:
{{- if .Values.metaComponent.resources.limits }}
limits:
Expand Down
23 changes: 23 additions & 0 deletions charts/risingwave/templates/metastore/mysql-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{{/*
Copyright RisingWave Labs
SPDX-License-Identifier: APACHE-2.0
*/}}

{{- if .Values.metaStore.mysql.enabled }}
{{- if not .Values.metaStore.mysql.authentication.existingSecretName }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "risingwave.mysqlCredentialsSecretName" . }}
labels:
{{- include "risingwave.labels" . | nindent 4 }}
{{- $annotations := (include "risingwave.annotations" . ) | trim }}
{{- if $annotations }}
annotations:
{{ nindent 4 $annotations }}
{{- end }}
stringData:
RW_MYSQL_USERNAME: {{ .Values.metaStore.mysql.authentication.username | quote }}
RW_MYSQL_PASSWORD: {{ .Values.metaStore.mysql.authentication.password | quote }}
{{- end }}
{{- end }}
23 changes: 23 additions & 0 deletions charts/risingwave/templates/metastore/postgres-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{{/*
Copyright RisingWave Labs
SPDX-License-Identifier: APACHE-2.0
*/}}

{{- if .Values.metaStore.postgresql.enabled }}
{{- if not .Values.metaStore.postgresql.authentication.existingSecretName }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "risingwave.postgresCredentialsSecretName" . }}
labels:
{{- include "risingwave.labels" . | nindent 4 }}
{{- $annotations := (include "risingwave.annotations" . ) | trim }}
{{- if $annotations }}
annotations:
{{ nindent 4 $annotations }}
{{- end }}
stringData:
RW_POSTGRES_USERNAME: {{ .Values.metaStore.postgresql.authentication.username | quote }}
RW_POSTGRES_PASSWORD: {{ .Values.metaStore.postgresql.authentication.password | quote }}
{{- end }}
{{- end }}
50 changes: 50 additions & 0 deletions charts/risingwave/templates/standalone/standalone-sts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ spec:
maxUnavailable: "100%"
podManagementPolicy: Parallel
minReadySeconds: 0
{{- if .Values.standalone.volumeClaimTemplates }}
volumeClaimTemplates:
{{- toYaml .Values.standalone.volumeClaimTemplates | nindent 2 }}
{{- end }}
{{- if .Values.standalone.persistentVolumeClaimRetentionPolicy }}
persistentVolumeClaimRetentionPolicy:
{{- toYaml .Values.standalone.persistentVolumeClaimRetentionPolicy | nindent 4 }}
{{- end }}
template:
metadata:
labels:
Expand Down Expand Up @@ -115,7 +123,12 @@ spec:
--dashboard-host 0.0.0.0:{{ .Values.ports.meta.dashboard }}
--prometheus-host 0.0.0.0:{{ .Values.ports.meta.metrics }}
--backend $(RW_BACKEND)
{{- if .Values.metaStore.etcd.enabled }}
--etcd-endpoints $(RW_ETCD_ENDPOINTS)
{{- end }}
{{- if eq (include "risingwave.metaBackend" . ) "sql" }}
--sql-endpoint $(RW_SQL_ENDPOINT)
{{- end }}
--state-store $(RW_STATE_STORE)
--data-directory $(RW_DATA_DIRECTORY)
--config-path /risingwave/config/risingwave.toml
Expand Down Expand Up @@ -194,6 +207,14 @@ spec:
- secretRef:
name: {{ include "risingwave.etcdCredentialsSecretName" . }}
{{- end }}
{{- if .Values.metaStore.postgresql.enabled }}
- secretRef:
name: {{ include "risingwave.postgresCredentialsSecretName" . }}
{{- end }}
{{- if .Values.metaStore.mysql.enabled }}
- secretRef:
name: {{ include "risingwave.mysqlCredentialsSecretName" . }}
{{- end }}
env:
# Disable auto region loading. Refer to the original source for more information.
# https://github.com/awslabs/aws-sdk-rust/blob/main/sdk/aws-config/src/imds/region.rs
Expand Down Expand Up @@ -300,6 +321,35 @@ spec:
name: {{ include "risingwave.etcdCredentialsSecretName" . }}
{{- end }}
{{- end }}
# SQL meta backend.
{{- if and .Values.metaStore.postgresql.enabled .Values.metaStore.postgresql.authentication.existingSecretName }}
- name: RW_POSTGRES_USERNAME
valueFrom:
secretKeyRef:
key: username
name: {{ .Values.metaStore.postgresql.authentication.existingSecretName }}
- name: RW_POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
key: password
name: {{ .Values.metaStore.postgresql.authentication.existingSecretName }}
{{- end }}
{{- if and .Values.metaStore.mysql.enabled .Values.metaStore.mysql.authentication.existingSecretName }}
- name: RW_MYSQL_USERNAME
valueFrom:
secretKeyRef:
key: username
name: {{ .Values.metaStore.mysql.authentication.existingSecretName }}
- name: RW_MYSQL_PASSWORD
valueFrom:
secretKeyRef:
key: password
name: {{ .Values.metaStore.mysql.authentication.existingSecretName }}
{{- end }}
{{- if eq (include "risingwave.metaBackend" . ) "sql" }}
- name: RW_SQL_ENDPOINT
value: {{ include "risingwave.sqlEndpoint" . }}
{{- end }}
{{- if .Values.standalone.extraEnvVars }}
{{- .Values.standalone.extraEnvVars | toYaml | nindent 8 }}
{{- end }}
Expand Down
Loading

0 comments on commit 4d782f7

Please sign in to comment.