Skip to content

Commit b5436dd

Browse files
committed
Allow pulling password from existing secret
1 parent a9f7366 commit b5436dd

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

charts/pgcat/templates/secret.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,15 @@ stringData:
5959
##
6060
[pools.{{ $pool.name | quote }}.users.{{ $index }}]
6161
username = {{ $user.username | quote }}
62+
{{- if $user.password }}
6263
password = {{ $user.password | quote }}
64+
{{- else if and $user.passwordSecret.name $user.passwordSecret.key }}
65+
{{- $secret := (lookup "v1" "Secret" $.Release.Namespace $user.passwordSecret.name) }}
66+
{{- if $secret }}
67+
{{- $password := index $secret.data $user.passwordSecret.key | b64dec }}
68+
password = {{ $password | quote }}
69+
{{- end }}
70+
{{- end }}
6371
pool_size = {{ $user.pool_size }}
6472
statement_timeout = {{ default 0 $user.statement_timeout }}
6573
min_pool_size = {{ default 3 $user.min_pool_size }}

charts/pgcat/values.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,9 @@ configuration:
310310
# ## Credentials for users that may connect to this cluster
311311
# ## @param users [array]
312312
# ## @param users[0].username Name of the env var (required)
313-
# ## @param users[0].password Value for the env var (required)
313+
# ## @param users[0].password Value for the env var (required) leave empty to use existing secret see passwordSecret.name and passwordSecret.key
314+
# ## @param users[0].passwordSecret.name Name of the secret containing the password
315+
# ## @param users[0].passwordSecret.key Key in the secret containing the password
314316
# ## @param users[0].pool_size Maximum number of server connections that can be established for this user
315317
# ## @param users[0].statement_timeout Maximum query duration. Dangerous, but protects against DBs that died in a non-obvious way.
316318
# users: []

0 commit comments

Comments
 (0)