Skip to content

Commit aa70b65

Browse files
authored
Allow more granular control for secrets (#15)
As it is, it's somewhat annoying to use some secrets and not others since the current mechanism to use external secrets is all-or-nothing with a whole block of env vars. This allows you to optionally use: - config.licenseKeySecretName instead of config.licenseKey - config.jwtSecretSecretName instead of config.jwtSecret - config.encryptionKeySecretName instead of config.encryptionKey - config.auth.google.clientSecretSecretName instead of config.auth.google.clientSecret - config.postgresql.passwordSecretName instead of config.postgresql.password In all of these instances, the alternative <x>SecretName allows you to specify the name of the k8s secret as an alternative to hardcoding the secrets into values and having the chart put them in secrets.
1 parent ac0fcfe commit aa70b65

File tree

4 files changed

+79
-7
lines changed

4 files changed

+79
-7
lines changed

templates/deployment_backend.yaml

+28-2
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,33 @@ spec:
6767
- name: LICENSE_KEY
6868
valueFrom:
6969
secretKeyRef:
70+
{{- if .Values.config.licenseKeySecretName }}
71+
name: {{ .Values.config.licenseKeySecretName }}
72+
key: {{ .Values.config.licenseKeySecretKey | default "license-key" }}
73+
{{- else }}
7074
name: {{ template "retool.fullname" . }}
7175
key: license-key
76+
{{- end }}
7277
- name: JWT_SECRET
7378
valueFrom:
7479
secretKeyRef:
80+
{{- if .Values.config.jwtSecretName }}
81+
name: {{ .Values.config.jwtSecretName }}
82+
key: {{ .Values.config.jwtSecretKey | default "jwt-secret" }}
83+
{{- else }}
7584
name: {{ template "retool.fullname" . }}
7685
key: jwt-secret
86+
{{- end }}
7787
- name: ENCRYPTION_KEY
7888
valueFrom:
7989
secretKeyRef:
90+
{{- if .Values.config.encryptionKeySecretName }}
91+
name: {{ .Values.config.encryptionKeySecretName }}
92+
key: {{ .Values.config.encryptionKeySecretKey | default "encryption-key" }}
93+
{{- else }}
8094
name: {{ template "retool.fullname" . }}
8195
key: encryption-key
96+
{{- end }}
8297
- name: POSTGRES_USER
8398
value: {{ template "retool.postgresql.user" . }}
8499
- name: POSTGRES_SSL_ENABLED
@@ -88,17 +103,28 @@ spec:
88103
secretKeyRef:
89104
{{- if .Values.postgresql.enabled }}
90105
name: {{ template "retool.postgresql.fullname" . }}
91-
{{- else }}
106+
key: postgresql-password
107+
{{- else }}
108+
{{- if .Values.config.postgresql.passwordSecretName }}
109+
name: {{ .Values.config.postgresql.passwordSecretName }}
110+
key: {{ .Values.config.postgresql.passwordSecretKey | default "postgresql-password" }}
111+
{{- else }}
92112
name: {{ template "retool.fullname" . }}
93-
{{- end }}
94113
key: postgresql-password
114+
{{- end }}
115+
{{- end }}
95116
- name: CLIENT_ID
96117
value: {{ default "" .Values.config.auth.google.clientId }}
97118
- name: CLIENT_SECRET
98119
valueFrom:
99120
secretKeyRef:
121+
{{- if .Values.config.auth.google.clientSecretSecretName }}
122+
name: {{ .Values.config.auth.google.clientSecretSecretName }}
123+
key: {{ .Values.config.auth.google.clientSecretSecretKey | default "google-client-secret" }}
124+
{{- else }}
100125
name: {{ template "retool.fullname" . }}
101126
key: google-client-secret
127+
{{- end }}
102128
- name: RESTRICTED_DOMAIN
103129
value: {{ default "" .Values.config.auth.google.domain }}
104130
{{- end }}

templates/deployment_jobs.yaml

+28-2
Original file line numberDiff line numberDiff line change
@@ -68,36 +68,62 @@ spec:
6868
- name: LICENSE_KEY
6969
valueFrom:
7070
secretKeyRef:
71+
{{- if .Values.config.licenseKeySecretName }}
72+
name: {{ .Values.config.licenseKeySecretName }}
73+
key: {{ .Values.config.licenseKeySecretKey | default "license-key" }}
74+
{{- else }}
7175
name: {{ template "retool.fullname" . }}
7276
key: license-key
77+
{{- end }}
7378
- name: JWT_SECRET
7479
valueFrom:
7580
secretKeyRef:
81+
{{- if .Values.config.jwtSecretName }}
82+
name: {{ .Values.config.jwtSecretName }}
83+
key: {{ .Values.config.jwtSecretKey | default "jwt-secret" }}
84+
{{- else }}
7685
name: {{ template "retool.fullname" . }}
7786
key: jwt-secret
87+
{{- end }}
7888
- name: ENCRYPTION_KEY
7989
valueFrom:
8090
secretKeyRef:
91+
{{- if .Values.config.encryptionKeySecretName }}
92+
name: {{ .Values.config.encryptionKeySecretName }}
93+
key: {{ .Values.config.encryptionKeySecretKey | default "encryption-key" }}
94+
{{- else }}
8195
name: {{ template "retool.fullname" . }}
8296
key: encryption-key
97+
{{- end }}
8398
- name: POSTGRES_USER
8499
value: {{ template "retool.postgresql.user" . }}
85100
- name: POSTGRES_PASSWORD
86101
valueFrom:
87102
secretKeyRef:
88103
{{- if .Values.postgresql.enabled }}
89104
name: {{ template "retool.postgresql.fullname" . }}
90-
{{- else }}
105+
key: postgresql-password
106+
{{- else }}
107+
{{- if .Values.config.postgresql.passwordSecretName }}
108+
name: {{ .Values.config.postgresql.passwordSecretName }}
109+
key: {{ .Values.config.postgresql.passwordSecretKey | default "postgresql-password" }}
110+
{{- else }}
91111
name: {{ template "retool.fullname" . }}
92-
{{- end }}
93112
key: postgresql-password
113+
{{- end }}
114+
{{- end }}
94115
- name: CLIENT_ID
95116
value: {{ default "" .Values.config.auth.google.clientId }}
96117
- name: CLIENT_SECRET
97118
valueFrom:
98119
secretKeyRef:
120+
{{- if .Values.config.auth.google.clientSecretSecretName }}
121+
name: {{ .Values.config.auth.google.clientSecretSecretName }}
122+
key: {{ .Values.config.auth.google.clientSecretSecretKey | default "google-client-secret" }}
123+
{{- else }}
99124
name: {{ template "retool.fullname" . }}
100125
key: google-client-secret
126+
{{- end }}
101127
- name: RESTRICTED_DOMAIN
102128
value: {{ default "" .Values.config.auth.google.domain }}
103129
{{- end }}

templates/secret.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ metadata:
1111
{{- end }}
1212
type: Opaque
1313
data:
14-
license-key: {{ .Values.config.licenseKey | b64enc | quote }}
14+
license-key: {{ .Values.config.licenseKey | default "" | b64enc | quote }}
1515

1616
{{ if .Values.config.jwtSecret }}
1717
jwt-secret: {{ .Values.config.jwtSecret | b64enc | quote }}
@@ -26,9 +26,9 @@ data:
2626
{{ end }}
2727

2828
{{ if .Values.config.auth.google.clientSecret }}
29-
google-client-secret: {{ .Values.config.auth.google.clientSecret | b64enc |quote }}
29+
google-client-secret: {{ .Values.config.auth.google.clientSecret | b64enc | quote }}
3030
{{ else }}
31-
google-client-secret: ""
31+
google-client-secret: ""
3232
{{ end }}
3333

3434
{{ if not .Values.postgresql.enabled }}

values.yaml

+20
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,30 @@
33

44
config:
55
licenseKey: "EXPIRED-LICENSE-KEY-TRIAL"
6+
# licenseKeySecretName is the name of the secret where the Retool license key is stored (can be used instead of licenseKey)
7+
# licenseKeySecretName:
8+
# licenseKeySecretKey is the key in the k8s secret, default: license-key
9+
# licenseKeySecretKey:
610
useInsecureCookies: true
711
auth:
812
google:
913
clientId:
1014
clientSecret:
15+
# clientSecretSecretName is the name of the secret where the google client secret is stored (can be used instead of clientSecret)
16+
# clientSecretSecretName:
17+
# clientSecretSecretKey is the key in the k8s secret, default: google-client-secret
18+
# clientSecretSecretKey:
1119
domain:
1220
encryptionKey:
21+
# encryptionKeySecretName is the name of the secret where the encryption key is stored (can be used instead of encryptionKey)
22+
# encryptionKeySecretName:
23+
# encryptionKeySecretKey is the key in the k8s secret, default: encryption-key
24+
# encryptionKeySecretKey:
1325
jwtSecret:
26+
# jwtSecretSecretName is the name of the secret where the jwt secret is stored (can be used instead of jwtSecret)
27+
# jwtSecretSecretName:
28+
# jwtSecretSecretKey is the key in the k8s secret, default: jwt-secret
29+
# jwtSecretSecretKey:
1430

1531
postgresql: {}
1632
# Specify if postgresql subchart is disabled
@@ -19,6 +35,10 @@ config:
1935
# db:
2036
# user:
2137
# password:
38+
# passwordSecretName is the name of the secret where the pg password is stored (can be used instead of password)
39+
# passwordSecretName:
40+
# passwordSecretKey is the key in the k8s secret, default: postgresql-password
41+
# passwordSecretKey:
2242

2343
image:
2444
repository: "tryretool/backend"

0 commit comments

Comments
 (0)