Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat(helm-chart): add service account option (#18809)

lexomis2f3323f5a4fb
diff --git a/helm-charts/bytebase/templates/_helpers.tpl b/helm-charts/bytebase/templates/_helpers.tpl
index 51989a3560..1912efb7de 100644
--- a/helm-charts/bytebase/templates/_helpers.tpl
+++ b/helm-charts/bytebase/templates/_helpers.tpl
@@ -23,4 +23,15 @@ Selector labels
*/}}
{{- define "bytebase.selectorLabels" -}}
app: bytebase
-{{- end }}
\ No newline at end of file
+{{- end }}
+
+{{/*
+Create the name of the general service account
+*/}}
+{{- define "bytebase.serviceAccountName" -}}
+{{- if .Values.serviceAccount.create -}}
+ {{ default ("bytebase") .Values.serviceAccount.name }}
+{{- else -}}
+ {{ default "default" .Values.serviceAccount.name }}
+{{- end -}}
+{{- end -}}
\ No newline at end of file
diff --git a/helm-charts/bytebase/templates/serviceaccount.yaml b/helm-charts/bytebase/templates/serviceaccount.yaml
new file mode 100644
index 0000000000..f3fcd72066
--- /dev/null
+++ b/helm-charts/bytebase/templates/serviceaccount.yaml
@@ -0,0 +1,14 @@
+{{- if .Values.serviceAccount.create }}
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+ name: {{ template "bytebase.serviceAccountName" . }}
+ labels:
+ {{- include "bytebase.labels" . | nindent 4}}
+ {{- with .Values.serviceAccount.labels }}
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+ annotations:
+ {{- toYaml .Values.serviceAccount.annotations | nindent 4 }}
+ namespace: {{ .Release.Namespace | quote }}
+{{- end }}
\ No newline at end of file
diff --git a/helm-charts/bytebase/templates/statefulset.yaml b/helm-charts/bytebase/templates/statefulset.yaml
index 66b0df86e8..ef8fba33a5 100644
--- a/helm-charts/bytebase/templates/statefulset.yaml
+++ b/helm-charts/bytebase/templates/statefulset.yaml
@@ -45,6 +45,7 @@ spec:
labels:
app: bytebase
spec:
+ serviceAccountName: {{ template "bytebase.serviceAccountName" . }}
{{- if $externalPgEscapePgPassword }}
# If user specify the externalPgEscapePgPassword, we should escape the password in the PG_URL in the shell,
# because the password may comes from a secret, which is invisible in helm.
diff --git a/helm-charts/bytebase/values.yaml b/helm-charts/bytebase/values.yaml
index c1ebb918e5..05ce45bdec 100644
--- a/helm-charts/bytebase/values.yaml
+++ b/helm-charts/bytebase/values.yaml
@@ -93,3 +93,13 @@ bytebase:
# operator: "Equal"
# value: "value"
# effect: "NoSchedule"
+
+# Service account configuration
+# ref: https://kubernetes.io/docs/concepts/security/service-accounts/
+serviceAccount:
+ # -- Whether to create a service account or not. In case 'create' is false, do set 'name' to an existing service account name.
+ create: true
+ # -- Override for the generated service account name.
+ name:
+ annotations: {}
+ labels: {}