Skip to content

Commit

Permalink
feat: support existing secret for etcd auth (#34)
Browse files Browse the repository at this point in the history
* fix & test: enrich test cases and fix bug found

Signed-off-by: arkbriar <[email protected]>

* feat: support existing secret for etcd auth

Signed-off-by: arkbriar <[email protected]>

* feat: support extra volumes and volume mounts

Signed-off-by: arkbriar <[email protected]>

* chore: append new lines to all files

Signed-off-by: arkbriar <[email protected]>

---------

Signed-off-by: arkbriar <[email protected]>
  • Loading branch information
arkbriar authored Mar 7, 2024
1 parent e092b33 commit 2162b82
Show file tree
Hide file tree
Showing 65 changed files with 177 additions and 60 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ jobs:
- name: Run chart-releaser
uses: helm/[email protected]
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ jobs:
- name: Run Unit Tests
run: |
make test
make test
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,4 @@ Temporary Items

.idea
**/.debug
**/__snapshot__
**/__snapshot__
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ test:
$(foreach chart,$(HELM_CHARTS),helm unittest charts/$(chart);)

sync-crds:
./scripts/sync-crds.sh charts/risingwave-operator/crds
./scripts/sync-crds.sh charts/risingwave-operator/crds

sanitize:
@./scripts/sanitize.sh
2 changes: 1 addition & 1 deletion charts/risingwave-operator/.helmignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
.idea/
*.tmproj
.vscode/
tests
tests
2 changes: 1 addition & 1 deletion charts/risingwave-operator/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,4 @@ Create the image name to use.
{{- else -}}
{{- printf "%s%s%s" $repositoryName $separator $termination -}}
{{- end -}}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ spec:
issuerRef:
name: {{ include "risingwave-operator.fullname" . }}
kind: Issuer
secretName: {{ include "risingwave-operator.fullname" . }}
secretName: {{ include "risingwave-operator.fullname" . }}
2 changes: 1 addition & 1 deletion charts/risingwave-operator/templates/certs/issuer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ metadata:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
selfSigned: {}
selfSigned: {}
2 changes: 1 addition & 1 deletion charts/risingwave-operator/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,4 @@ rules:
verbs:
- get
- patch
- update
- update
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ roleRef:
subjects:
- kind: ServiceAccount
name: {{ include "risingwave-operator.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
namespace: {{ .Release.Namespace }}
2 changes: 1 addition & 1 deletion charts/risingwave-operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,4 @@ spec:
{{- if .Values.manager.additionalContainers }}
{{- toYaml .Values.manager.additionalContainers | nindent 6 }}
{{- end }}
{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion charts/risingwave-operator/templates/podmonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ spec:
{{- if .Values.monitor.podMonitor.relabelings }}
{{- include "common.tplvalues.render" (dict "value" .Values.monitor.podMonitor.relabelings "context" $) | nindent 4 }}
{{- end }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ rules:
resources:
- subjectaccessreviews
verbs:
- create
- create
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ roleRef:
subjects:
- kind: ServiceAccount
name: {{ include "risingwave-operator.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
namespace: {{ .Release.Namespace }}
2 changes: 1 addition & 1 deletion charts/risingwave-operator/templates/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ rules:
- events
verbs:
- create
- patch
- patch
2 changes: 1 addition & 1 deletion charts/risingwave-operator/templates/rolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ roleRef:
subjects:
- kind: ServiceAccount
name: {{ include "risingwave-operator.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
namespace: {{ .Release.Namespace }}
2 changes: 1 addition & 1 deletion charts/risingwave-operator/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ spec:
targetPort: metrics
name: metrics
selector:
{{- include "risingwave-operator.selectorLabels" . | nindent 4 }}
{{- include "risingwave-operator.selectorLabels" . | nindent 4 }}
2 changes: 1 addition & 1 deletion charts/risingwave/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ Keep the above command running and open a new terminal window to run the followi
{{- end }}
psql {{ $psqlHostArgs -}} -p {{ $port }} -d {{ $firstDatabase }} -U {{ .Values.auth.rootUser }}

For more advanced applications, refer to our documentation at: https://www.risingwave.dev
For more advanced applications, refer to our documentation at: https://www.risingwave.dev
6 changes: 5 additions & 1 deletion charts/risingwave/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,12 @@ Create the name of the service account to use
Create the name of the etcd credentials Secret to use
*/}}
{{- define "risingwave.etcdCredentialsSecretName" -}}
{{- if .Values.metaStore.etcd.authentication.existingSecretName }}
{{- .Values.metaStore.etcd.authentication.existingSecretName }}
{{- else }}
{{- printf "%s-etcd" (include "risingwave.fullname" .) | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}

{{/*
Create the name of the S3 credentials Secret to use
Expand Down Expand Up @@ -315,4 +319,4 @@ Create the OBS endpoint to use.
*/}}
{{- define "risingwave.obs.endpoint" }}
{{- printf "https://obs.$(OBS_REGION).myhuaweicloud.com" }}
{{- end }}
{{- end }}
6 changes: 6 additions & 0 deletions charts/risingwave/templates/compactor-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ spec:
- name: config
configMap:
name: {{ include "risingwave.configurationConfigMapName" . }}
{{- if .Values.compactorComponent.extraVolumes }}
{{- toYaml .Values.compactorComponent.extraVolumes | nindent 6}}
{{- end }}
restartPolicy: Always
{{- if .Values.compactorComponent.terminationGracePeriodSeconds }}
terminationGracePeriodSeconds: {{ .Values.compactorComponent.terminationGracePeriodSeconds }}
Expand Down Expand Up @@ -221,6 +224,9 @@ spec:
- mountPath: /risingwave/config
name: config
readOnly: true
{{- if .Values.compactorComponent.extraVolumeMounts }}
{{- toYaml .Values.compactorComponent.extraVolumeMounts | nindent 8 }}
{{- end }}
{{- if .Values.compactorComponent.securityContext }}
securityContext: {{ toYaml .Values.compactorComponent.securityContext | nindent 10 }}
{{- end }}
Expand Down
2 changes: 1 addition & 1 deletion charts/risingwave/templates/compute-headless-svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ spec:
port: {{ .Values.ports.frontend.metrics }}
targetPort: f-metrics
{{- end }}
{{- end -}}
{{- end -}}
9 changes: 9 additions & 0 deletions charts/risingwave/templates/compute-sts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ spec:
- name: config
configMap:
name: {{ include "risingwave.configurationConfigMapName" . }}
{{- if .Values.computeComponent.extraVolumes }}
{{- toYaml .Values.computeComponent.extraVolumes | nindent 6}}
{{- end }}
restartPolicy: Always
{{- if .Values.computeComponent.terminationGracePeriodSeconds }}
terminationGracePeriodSeconds: {{ .Values.computeComponent.terminationGracePeriodSeconds }}
Expand Down Expand Up @@ -239,6 +242,9 @@ spec:
- mountPath: /risingwave/config
name: config
readOnly: true
{{- if .Values.computeComponent.extraVolumeMounts }}
{{- toYaml .Values.computeComponent.extraVolumeMounts | nindent 8 }}
{{- end }}
{{- if .Values.computeComponent.securityContext }}
securityContext: {{ toYaml .Values.computeComponent.securityContext | nindent 10 }}
{{- end }}
Expand Down Expand Up @@ -436,6 +442,9 @@ spec:
- mountPath: /risingwave/config
name: config
readOnly: true
{{- if .Values.frontendComponent.extraVolumeMounts }}
{{- toYaml .Values.frontendComponent.extraVolumeMounts | nindent 8 }}
{{- end }}
{{- if .Values.frontendComponent.securityContext }}
securityContext: {{ toYaml .Values.frontendComponent.securityContext | nindent 10 }}
{{- end }}
Expand Down
2 changes: 1 addition & 1 deletion charts/risingwave/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ metadata:
data:
risingwave.toml: |
{{ .Values.configuration | nindent 4 }}
{{- end }}
{{- end }}
2 changes: 2 additions & 0 deletions charts/risingwave/templates/etcd-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ SPDX-License-Identifier: APACHE-2.0
*/}}

{{- if and (not .Values.tags.etcd) .Values.metaStore.etcd.authentication.enabled }}
{{- if not .Values.metaStore.etcd.authentication.existingSecretName }}
apiVersion: v1
kind: Secret
metadata:
Expand All @@ -19,3 +20,4 @@ stringData:
RW_ETCD_USERNAME: {{ .Values.metaStore.etcd.authentication.username | quote }}
RW_ETCD_PASSWORD: {{ .Values.metaStore.etcd.authentication.password | quote }}
{{- end }}
{{- end }}
6 changes: 6 additions & 0 deletions charts/risingwave/templates/frontend-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ spec:
- name: config
configMap:
name: {{ include "risingwave.configurationConfigMapName" . }}
{{- if .Values.frontendComponent.extraVolumes }}
{{- toYaml .Values.frontendComponent.extraVolumes | nindent 6}}
{{- end }}
restartPolicy: Always
{{- if .Values.frontendComponent.terminationGracePeriodSeconds }}
terminationGracePeriodSeconds: {{ .Values.frontendComponent.terminationGracePeriodSeconds }}
Expand Down Expand Up @@ -174,6 +177,9 @@ spec:
- mountPath: /risingwave/config
name: config
readOnly: true
{{- if .Values.frontendComponent.extraVolumeMounts }}
{{- toYaml .Values.frontendComponent.extraVolumeMounts | nindent 8 }}
{{- end }}
{{- if .Values.frontendComponent.securityContext }}
securityContext: {{ toYaml .Values.frontendComponent.securityContext | nindent 10 }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ spec:
{{- end }}
EOSQL
echo "Created databases {{ join "," .Values.databases }}"
{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion charts/risingwave/templates/hooks/post-install-wait.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ spec:
done
echo "RisingWave is ready"
{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion charts/risingwave/templates/meta-headless-svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ spec:
- name: metrics
port: {{ .Values.ports.meta.metrics }}
targetPort: metrics
{{- end -}}
{{- end -}}
21 changes: 20 additions & 1 deletion charts/risingwave/templates/meta-sts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ spec:
- name: config
configMap:
name: {{ include "risingwave.configurationConfigMapName" . }}
{{- if .Values.metaComponent.extraVolumes }}
{{- toYaml .Values.metaComponent.extraVolumes | nindent 6}}
{{- end }}
restartPolicy: Always
{{- if .Values.metaComponent.terminationGracePeriodSeconds }}
terminationGracePeriodSeconds: {{ .Values.metaComponent.terminationGracePeriodSeconds }}
Expand Down Expand Up @@ -130,7 +133,7 @@ spec:
- secretRef:
name: {{ $credentialsSecret }}
{{- end }}
{{- if .Values.metaStore.etcd.authentication.enabled }}
{{- if and .Values.metaStore.etcd.authentication.enabled (not .Values.metaStore.etcd.authentication.existingSecretName) }}
- secretRef:
name: {{ include "risingwave.etcdCredentialsSecretName" . }}
{{- end }}
Expand Down Expand Up @@ -236,6 +239,19 @@ spec:
key: {{ include "etcd.secretPasswordKey" .Subcharts.etcd }}
name: {{ include "etcd.secretName" .Subcharts.etcd }}
{{- end }}
{{- else }}
{{- if and .Values.metaStore.etcd.authentication.enabled .Values.metaStore.etcd.authentication.existingSecretName }}
- name: RW_ETCD_PASSWORD
valueFrom:
secretKeyRef:
key: username
name: {{ include "risingwave.etcdCredentialsSecretName" . }}
- name: RW_ETCD_PASSWORD
valueFrom:
secretKeyRef:
key: password
name: {{ include "risingwave.etcdCredentialsSecretName" . }}
{{- end }}
{{- end }}
{{- range .Values.metaComponent.extraEnvVars }}
- {{ . }}
Expand All @@ -253,6 +269,9 @@ spec:
- mountPath: /risingwave/config
name: config
readOnly: true
{{- if .Values.metaComponent.extraVolumeMounts }}
{{- toYaml .Values.metaComponent.extraVolumeMounts | nindent 8 }}
{{- end }}
{{- if .Values.metaComponent.securityContext }}
securityContext: {{ toYaml .Values.metaComponent.securityContext | nindent 10 }}
{{- end }}
Expand Down
2 changes: 1 addition & 1 deletion charts/risingwave/templates/oss-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ stringData:
OSS_ACCESS_KEY_ID: {{ .Values.stateStore.oss.authentication.accessKey }}
OSS_ACCESS_KEY_SECRET: {{ .Values.stateStore.oss.authentication.secretAccessKey }}
{{- end }}
{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion charts/risingwave/templates/podmonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,4 @@ spec:
{{- end }}
{{- end }}
{{- end }}
{{- end -}}
{{- end -}}
2 changes: 1 addition & 1 deletion charts/risingwave/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ spec:
{{- end }}
{{- if or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer") }}
nodePort: {{ .Values.service.nodePort }}
{{- end }}
{{- end }}
21 changes: 20 additions & 1 deletion charts/risingwave/templates/standalone/standalone-sts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ spec:
- name: config
configMap:
name: {{ include "risingwave.configurationConfigMapName" . }}
{{- if .Values.standalone.extraVolumes }}
{{- toYaml .Values.standalone.extraVolumes | nindent 6}}
{{- end }}
restartPolicy: Always
{{- if .Values.standalone.terminationGracePeriodSeconds }}
terminationGracePeriodSeconds: {{ .Values.standalone.terminationGracePeriodSeconds }}
Expand Down Expand Up @@ -184,7 +187,7 @@ spec:
- secretRef:
name: {{ $credentialsSecret }}
{{- end }}
{{- if .Values.metaStore.etcd.authentication.enabled }}
{{- if and .Values.metaStore.etcd.authentication.enabled (not .Values.metaStore.etcd.authentication.existingSecretName) }}
- secretRef:
name: {{ include "risingwave.etcdCredentialsSecretName" . }}
{{- end }}
Expand Down Expand Up @@ -286,6 +289,19 @@ spec:
key: {{ include "etcd.secretPasswordKey" .Subcharts.etcd }}
name: {{ include "etcd.secretName" .Subcharts.etcd }}
{{- end }}
{{- else }}
{{- if and .Values.metaStore.etcd.authentication.enabled .Values.metaStore.etcd.authentication.existingSecretName }}
- name: RW_ETCD_PASSWORD
valueFrom:
secretKeyRef:
key: username
name: {{ include "risingwave.etcdCredentialsSecretName" . }}
- name: RW_ETCD_PASSWORD
valueFrom:
secretKeyRef:
key: password
name: {{ include "risingwave.etcdCredentialsSecretName" . }}
{{- end }}
{{- end }}
{{- range .Values.standalone.extraEnvVars }}
- {{ . }}
Expand All @@ -303,6 +319,9 @@ spec:
- mountPath: /risingwave/config
name: config
readOnly: true
{{- if .Values.standalone.extraVolumeMounts }}
{{- toYaml .Values.standalone.extraVolumeMounts | nindent 8 }}
{{- end }}
{{- if .Values.standalone.securityContext }}
securityContext: {{ toYaml .Values.standalone.securityContext | nindent 10 }}
{{- end }}
Expand Down
2 changes: 1 addition & 1 deletion charts/risingwave/tests/azblob_secret_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,4 @@ tests:
- isSubset:
path: metadata.annotations
content:
ANNOTATION: ANNOTATION_V
ANNOTATION: ANNOTATION_V
2 changes: 1 addition & 1 deletion charts/risingwave/tests/configmap_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ tests:
- isSubset:
path: metadata.annotations
content:
ANNOTATION: ANNOTATION_V
ANNOTATION: ANNOTATION_V
Loading

0 comments on commit 2162b82

Please sign in to comment.