Skip to content

Commit 6ccb451

Browse files
authored
Optional standalone dbconnector (#204)
* add standalone dbconnector deployment, opt-in * clean up dbconnector template * bump minor * make dbconnector port configurable
1 parent 9a3c6ff commit 6ccb451

9 files changed

+411
-5
lines changed

charts/retool/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: retool
33
description: A Helm chart for Kubernetes
44
type: application
5-
version: 6.3.6
5+
version: 6.4.0
66
maintainers:
77
- name: Retool Engineering
88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dbconnector:
2+
enabled: true

charts/retool/templates/_helpers.tpl

+24
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,23 @@ app.kubernetes.io/name: {{ include "retool.name" . }}
5757
app.kubernetes.io/instance: {{ .Release.Name }}
5858
{{- end }}
5959

60+
{{/*
61+
Selector labels for standalone dbconnector. Note changes here will require manual
62+
deployment recreation and incur downtime, so should be avoided.
63+
*/}}
64+
{{- define "retool.dbconnector.selectorLabels" -}}
65+
retoolService: {{ include "retool.dbconnector.name" . }}
66+
{{- end }}
67+
68+
{{/*
69+
Extra (non-selector) labels for standalone dbconnector.
70+
*/}}
71+
{{- define "retool.dbconnector.labels" -}}
72+
app.kubernetes.io/name: {{ include "retool.dbconnector.name" . }}
73+
app.kubernetes.io/instance: {{ .Release.Name }}
74+
telemetry.retool.com/service-name: dbconnector
75+
{{- end }}
76+
6077
{{/*
6178
Selector labels for workflow backend. Note changes here will require manual
6279
deployment recreation and incur downtime, so should be avoided.
@@ -286,6 +303,13 @@ Set Temporal namespace
286303
{{- end -}}
287304
{{- end -}}
288305

306+
{{/*
307+
Set dbconnector service name
308+
*/}}
309+
{{- define "retool.dbconnector.name" -}}
310+
{{ template "retool.fullname" . }}-dbconnector
311+
{{- end -}}
312+
289313
{{/*
290314
Set workflow backend service name
291315
*/}}

charts/retool/templates/deployment_backend.yaml

+14-1
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,21 @@ spec:
7777
value: {{ template "retool.deploymentTemplateVersion" . }}
7878
- name: NODE_ENV
7979
value: production
80-
{{- $serviceType := list "MAIN_BACKEND" "DB_CONNECTOR" "DB_SSH_CONNECTOR" }}
80+
{{- $serviceType := list "MAIN_BACKEND" }}
8181
{{- /*
8282
JAVA_DBCONNECTOR in the service type only applies before the version of Retool that changes it to opt-out (3.93.0-edge),
8383
and only if the Java dbconnector is enabled in values.yaml.
8484
*/}}
8585
{{- if and ( not ( include "retool_version_with_java_dbconnector_opt_out" . ) ) ( $.Values.dbconnector.java.enabled ) }}
8686
{{- $serviceType = append $serviceType "JAVA_DBCONNECTOR" }}
8787
{{- end }}
88+
{{- /*
89+
The dbconnector.enabled setting is to enable a standalone dbconnector deployment.
90+
If it is not enabled (default), the main backend acts as its own dbconnector.
91+
*/ -}}
92+
{{- if not $.Values.dbconnector.enabled -}}
93+
{{- $serviceType = concat $serviceType (list "DB_CONNECTOR" "DB_SSH_CONNECTOR") -}}
94+
{{- end }}
8895
{{- /*
8996
It may seem counterintuitive to add the JOBS_RUNNER service type only without a jobs runner.
9097
The reason for this is that the backend needs to act as a jobs runner, if the jobs runner is not enabled.
@@ -112,6 +119,12 @@ spec:
112119
value: {{ template "retool.postgresql.user" . }}
113120
- name: POSTGRES_SSL_ENABLED
114121
value: {{ template "retool.postgresql.ssl_enabled" . }}
122+
{{- if .Values.dbconnector.enabled }}
123+
- name: DB_CONNECTOR_HOST
124+
value: http://{{ template "retool.fullname" . }}-dbconnector
125+
- name: DB_CONNECTOR_PORT
126+
value: {{ .Values.dbconnector.port | quote }}
127+
{{- end }}
115128
{{- if .Values.config.dbConnectorTimeout }}
116129
- name: DBCONNECTOR_QUERY_TIMEOUT_MS
117130
value: {{ .Values.config.dbConnectorTimeout | quote }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,270 @@
1+
{{- if .Values.dbconnector.enabled }}
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: {{ include "retool.dbconnector.name" . }}
6+
labels:
7+
{{- include "retool.dbconnector.selectorLabels" . | nindent 4 }}
8+
{{- include "retool.dbconnector.labels" . | nindent 4 }}
9+
{{- include "retool.labels" . | nindent 4 }}
10+
{{- if .Values.deployment.annotations }}
11+
annotations:
12+
{{- toYaml .Values.deployment.annotations | nindent 4 }}
13+
{{- end }}
14+
spec:
15+
replicas: {{ .Values.dbconnector.replicas }}
16+
selector:
17+
matchLabels:
18+
{{- include "retool.dbconnector.selectorLabels" . | nindent 6 }}
19+
template:
20+
metadata:
21+
annotations:
22+
{{- if .Values.podAnnotations }}
23+
{{ toYaml .Values.podAnnotations | indent 8 }}
24+
{{- end }}
25+
{{- if .Values.backend.annotations }}
26+
{{ toYaml .Values.backend.annotations | indent 8 }}
27+
{{- end }}
28+
labels:
29+
{{- include "retool.dbconnector.selectorLabels" . | nindent 8 }}
30+
{{- include "retool.dbconnector.labels" . | nindent 8 }}
31+
{{- include "retool.labels" . | nindent 8 }}
32+
spec:
33+
{{- if .Values.dbconnector.terminationGracePeriodSeconds }}
34+
terminationGracePeriodSeconds: {{ .Values.dbconnector.terminationGracePeriodSeconds }}
35+
{{- end }}
36+
containers:
37+
- args:
38+
- bash
39+
- -c
40+
- chmod -R +x ./docker_scripts; sync; ./docker_scripts/start_api.sh
41+
image: "{{ .Values.image.repository }}:{{ required "Please set a value for .Values.image.tag" .Values.image.tag }}"
42+
name: {{ include "retool.dbconnector.name" . }}
43+
readinessProbe:
44+
httpGet:
45+
path: {{ .Values.readinessProbe.path }}
46+
port: {{ .Values.dbconnector.port }}
47+
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
48+
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
49+
successThreshold: {{ .Values.readinessProbe.successThreshold }}
50+
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
51+
livenessProbe:
52+
httpGet:
53+
path: {{ .Values.livenessProbe.path }}
54+
port: {{ .Values.dbconnector.port }}
55+
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
56+
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
57+
failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
58+
resources:
59+
{{- if .Values.dbconnector.resources }}
60+
{{- toYaml .Values.dbconnector.resources | nindent 10 }}
61+
{{- else }}
62+
{{- toYaml .Values.resources | nindent 10 }}
63+
{{- end }}
64+
env:
65+
{{- if $.Values.dbconnector.java.enabled }}
66+
- name: SERVICE_TYPE
67+
value: DB_CONNECTOR,DB_SSH_CONNECTOR,JAVA_DBCONNECTOR
68+
{{- else }}
69+
- name: SERVICE_TYPE
70+
value: DB_CONNECTOR,DB_SSH_CONNECTOR
71+
{{- end }}
72+
- name: DEPLOYMENT_TEMPLATE_TYPE
73+
value: {{ template "retool.deploymentTemplateType" . }}
74+
- name: DEPLOYMENT_TEMPLATE_VERSION
75+
value: {{ template "retool.deploymentTemplateVersion" . }}
76+
- name: NODE_ENV
77+
value: production
78+
- name: NODE_OPTIONS
79+
value: {{ .Values.dbconnector.config.nodeOptions }}
80+
- name: DBCONNECTOR_HTTP_AGENT_MAX_SOCKETS
81+
value: {{ .Values.dbconnector.config.httpAgentMaxSockets | quote }}
82+
- name: DBCONNECTOR_POSTGRES_POOL_MAX_SIZE
83+
value: {{ .Values.dbconnector.config.postgresPoolMaxSize | quote }}
84+
- name: DISABLE_DATABASE_MIGRATIONS
85+
value: "true"
86+
- name: WORKFLOW_BACKEND_HOST
87+
value: http://{{ template "retool.fullname" . }}-workflow-backend
88+
- name: CLIENT_ID
89+
value: {{ default "" .Values.config.auth.google.clientId }}
90+
- name: COOKIE_INSECURE
91+
value: {{ .Values.config.useInsecureCookies | quote }}
92+
{{- if and (not .Values.externalSecrets.enabled) (not .Values.externalSecrets.externalSecretsOperator.enabled) }}
93+
- name: LICENSE_KEY
94+
valueFrom:
95+
secretKeyRef:
96+
{{- if .Values.config.licenseKeySecretName }}
97+
name: {{ .Values.config.licenseKeySecretName }}
98+
key: {{ .Values.config.licenseKeySecretKey | default "license-key" }}
99+
{{- else }}
100+
name: {{ template "retool.fullname" . }}
101+
key: license-key
102+
{{- end }}
103+
- name: JWT_SECRET
104+
valueFrom:
105+
secretKeyRef:
106+
{{- if .Values.config.jwtSecretSecretName }}
107+
name: {{ .Values.config.jwtSecretSecretName }}
108+
key: {{ .Values.config.jwtSecretSecretKey | default "jwt-secret" }}
109+
{{- else }}
110+
name: {{ template "retool.fullname" . }}
111+
key: jwt-secret
112+
{{- end }}
113+
- name: ENCRYPTION_KEY
114+
valueFrom:
115+
secretKeyRef:
116+
{{- if .Values.config.encryptionKeySecretName }}
117+
name: {{ .Values.config.encryptionKeySecretName }}
118+
key: {{ .Values.config.encryptionKeySecretKey | default "encryption-key" }}
119+
{{- else }}
120+
name: {{ template "retool.fullname" . }}
121+
key: encryption-key
122+
{{- end }}
123+
- name: POSTGRES_PASSWORD
124+
valueFrom:
125+
secretKeyRef:
126+
{{- if .Values.postgresql.enabled }}
127+
name: {{ template "retool.postgresql.fullname" . }}
128+
# `postgres` is the default admin username for postgres in the subchart we use, so it needs the admin password
129+
# if a different username is picked, then it needs the custom password instead.
130+
{{- if eq .Values.postgresql.auth.username "postgres" }}
131+
key: postgres-password
132+
{{- else }}
133+
key: password
134+
{{- end }}
135+
{{- else }}
136+
{{- if .Values.config.postgresql.passwordSecretName }}
137+
name: {{ .Values.config.postgresql.passwordSecretName }}
138+
key: {{ .Values.config.postgresql.passwordSecretKey | default "postgresql-password" }}
139+
{{- else }}
140+
name: {{ template "retool.fullname" . }}
141+
key: postgresql-password
142+
{{- end }}
143+
{{- end }}
144+
- name: CLIENT_SECRET
145+
valueFrom:
146+
secretKeyRef:
147+
{{- if .Values.config.auth.google.clientSecretSecretName }}
148+
name: {{ .Values.config.auth.google.clientSecretSecretName }}
149+
key: {{ .Values.config.auth.google.clientSecretSecretKey | default "google-client-secret" }}
150+
{{- else }}
151+
name: {{ template "retool.fullname" . }}
152+
key: google-client-secret
153+
{{- end }}
154+
{{- end }}
155+
{{- range $key, $value := .Values.env }}
156+
- name: "{{ $key }}"
157+
value: "{{ $value }}"
158+
{{- end }}
159+
{{- range .Values.environmentSecrets }}
160+
- name: {{ .name }}
161+
valueFrom:
162+
secretKeyRef:
163+
name: {{ .secretKeyRef.name }}
164+
key: {{ .secretKeyRef.key }}
165+
{{- end }}
166+
{{- with .Values.environmentVariables }}
167+
{{ toYaml . | indent 10 }}
168+
{{- end }}
169+
{{- if .Values.externalSecrets.enabled }}
170+
envFrom:
171+
- secretRef:
172+
name: {{ .Values.externalSecrets.name }}
173+
{{- range .Values.externalSecrets.secrets }}
174+
- secretRef:
175+
name: {{ .name }}
176+
{{- end }}
177+
{{- end }}
178+
{{- if .Values.externalSecrets.externalSecretsOperator.enabled }}
179+
envFrom:
180+
{{- range .Values.externalSecrets.externalSecretsOperator.secretRef }}
181+
- secretRef:
182+
name: {{ .name }}
183+
{{- end }}
184+
{{- end }}
185+
volumeMounts:
186+
{{- range $configFile := (keys .Values.files) }}
187+
- name: {{ template "retool.name" $ }}
188+
mountPath: "/usr/share/retool/config/{{ $configFile }}"
189+
subPath: {{ $configFile }}
190+
{{- end }}
191+
{{- if and .Values.persistentVolumeClaim.enabled .Values.persistentVolumeClaim.mountPath }}
192+
- name: retool-pv
193+
mountPath: {{ .Values.persistentVolumeClaim.mountPath }}
194+
{{- end }}
195+
{{- if .Values.extraVolumeMounts }}
196+
{{- toYaml .Values.extraVolumeMounts | nindent 8 }}
197+
{{- end }}
198+
{{- with .Values.extraContainers }}
199+
{{- tpl . $ | indent 8 }}
200+
{{- end }}
201+
{{- range .Values.extraConfigMapMounts }}
202+
- name: {{ .name }}
203+
mountPath: {{ .mountPath }}
204+
subPath: {{ .subPath }}
205+
{{- end }}
206+
{{- if .Values.image.pullSecrets }}
207+
imagePullSecrets:
208+
{{- toYaml .Values.image.pullSecrets | nindent 8 }}
209+
{{- end }}
210+
{{- if .Values.affinity }}
211+
affinity:
212+
{{- toYaml .Values.affinity | nindent 8 }}
213+
{{- end }}
214+
{{- if .Values.nodeSelector }}
215+
nodeSelector:
216+
{{- toYaml .Values.nodeSelector | nindent 8 }}
217+
{{- end }}
218+
tolerations:
219+
{{- toYaml .Values.tolerations | nindent 8 }}
220+
{{- if .Values.securityContext.enabled }}
221+
securityContext:
222+
runAsUser: {{ .Values.securityContext.runAsUser }}
223+
fsGroup: {{ .Values.securityContext.fsGroup }}
224+
{{- end }}
225+
volumes:
226+
{{- range .Values.extraConfigMapMounts }}
227+
- name: {{ .name }}
228+
configMap:
229+
name: {{ .configMap }}
230+
{{- end }}
231+
{{- if .Values.persistentVolumeClaim.enabled }}
232+
- name: retool-pv
233+
persistentVolumeClaim:
234+
claimName: {{ default (include "retool.fullname" .) .Values.persistentVolumeClaim.existingClaim }}
235+
{{- end }}
236+
{{- if .Values.extraVolumes }}
237+
{{- toYaml .Values.extraVolumes | nindent 8 }}
238+
{{- end }}
239+
---
240+
241+
{{- if .Values.podDisruptionBudget }}
242+
{{- if semverCompare ">=1.21-0" .Capabilities.KubeVersion.Version -}}
243+
apiVersion: policy/v1
244+
{{- else -}}
245+
apiVersion: policy/v1beta1
246+
{{- end }}
247+
kind: PodDisruptionBudget
248+
metadata:
249+
name: {{ include "retool.dbconnector.name" . }}
250+
spec:
251+
{{ toYaml .Values.podDisruptionBudget }}
252+
selector:
253+
matchLabels:
254+
{{- include "retool.dbconnector.selectorLabels" . | nindent 6 }}
255+
---
256+
{{- end }}
257+
258+
apiVersion: v1
259+
kind: Service
260+
metadata:
261+
name: {{ include "retool.dbconnector.name" . }}
262+
spec:
263+
selector:
264+
retoolService: {{ include "retool.dbconnector.name" . }}
265+
ports:
266+
- protocol: TCP
267+
name: http-server
268+
port: {{ .Values.dbconnector.port }}
269+
targetPort: {{ .Values.dbconnector.port }}
270+
{{- end }}

charts/retool/templates/deployment_workflows.yaml

+14-1
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,29 @@ spec:
6666
value: {{ template "retool.deploymentTemplateVersion" . }}
6767
- name: NODE_ENV
6868
value: production
69-
{{- $serviceType := list "WORKFLOW_BACKEND" "DB_CONNECTOR" "DB_SSH_CONNECTOR" }}
69+
{{- $serviceType := list "WORKFLOW_BACKEND" }}
7070
{{- /*
7171
JAVA_DBCONNECTOR in the service type only applies before the version of Retool that changes it to opt-out (3.93.0-edge),
7272
and only if the Java dbconnector is enabled in values.yaml.
7373
*/}}
7474
{{- if and ( not ( include "retool_version_with_java_dbconnector_opt_out" . ) ) ( $.Values.dbconnector.java.enabled ) }}
7575
{{- $serviceType = append $serviceType "JAVA_DBCONNECTOR" }}
7676
{{- end }}
77+
{{- /*
78+
The dbconnector.enabled setting is to enable a standalone dbconnector deployment.
79+
If it is not enabled (default), the main backend acts as its own dbconnector.
80+
*/ -}}
81+
{{- if not $.Values.dbconnector.enabled -}}
82+
{{- $serviceType = concat $serviceType (list "DB_CONNECTOR" "DB_SSH_CONNECTOR") -}}
83+
{{- end }}
7784
- name: SERVICE_TYPE
7885
value: {{ join "," $serviceType }}
86+
{{- if $.Values.dbconnector.enabled }}
87+
- name: DB_CONNECTOR_HOST
88+
value: http://{{ template "retool.fullname" . }}-dbconnector
89+
- name: DB_CONNECTOR_PORT
90+
value: {{ .Values.dbconnector.port | quote }}
91+
{{- end }}
7992
{{ if and ( include "retool_version_with_java_dbconnector_opt_out" . ) ( not $.Values.dbconnector.java.enabled ) }}
8093
- name: DISABLE_JAVA_DBCONNECTOR
8194
value: "true"

0 commit comments

Comments
 (0)