Skip to content

Commit

Permalink
allow to provide the users password in an existing secret
Browse files Browse the repository at this point in the history
  • Loading branch information
glehmann committed Sep 30, 2022
1 parent e684210 commit 2087a4e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
12 changes: 12 additions & 0 deletions build/templates/values.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
nameOverride:
fullNameOverride:

image:
repository: cockroachdb/cockroach
tag: v{{ .AppVersion }}
Expand Down Expand Up @@ -314,6 +317,9 @@ ingress:
# - hosts: [cockroachlabs.com]
# secretName: cockroachlabs-tls

prometheus:
enabled: true

# CockroachDB's Prometheus operator ServiceMonitor support
serviceMonitor:
enabled: false
Expand Down Expand Up @@ -403,11 +409,17 @@ init:
# password:
# # https://www.cockroachlabs.com/docs/stable/create-user.html#parameters
# options: [LOGIN]
# # existing secret name containing the password. Ignored in password is defined.
# passwordSecretName:
# # password secret key. Defaults to $name-password. Ignored in password is defined.
# passwordSecretKey:
databases: []
# - name:
# # https://www.cockroachlabs.com/docs/stable/create-database.html#parameters
# options: [encoding='utf-8']
# owners: []
# # Backup schedules are not idemponent for now and will fail on next run
# # https://github.com/cockroachdb/cockroach/issues/57892
# backup:
# into: s3://
# # Enterprise-only option (revision_history)
Expand Down
8 changes: 7 additions & 1 deletion cockroachdb/templates/job.init.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ spec:
{{- range $user := .Values.init.provisioning.users }}
CREATE USER IF NOT EXISTS {{ $user.name }} WITH
{{- if $user.password }}
{{- if or $user.password $user.passwordSecretName }}
PASSWORD '${{ $user.name }}_PASSWORD'
{{- else }}
PASSWORD null
Expand Down Expand Up @@ -211,6 +211,12 @@ spec:
secretKeyRef:
name: {{ $secretName }}
key: {{ $user.name }}-password
{{- else if $user.passwordSecretName }}
- name: {{ $user.name }}_PASSWORD
valueFrom:
secretKeyRef:
name: {{ tpl $user.passwordSecretName $ }}
key: {{ $user.passwordSecretKey | default (printf "%s-password" $user.name) }}
{{- end }}
{{- end }}
{{- range $clusterSetting, $clusterSettingValue := .Values.init.provisioning.clusterSettings }}
Expand Down

0 comments on commit 2087a4e

Please sign in to comment.