-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathdeployment_backend.yaml
367 lines (365 loc) · 14.8 KB
/
deployment_backend.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "retool.fullname" . }}
labels:
{{- include "retool.labels" . | nindent 4 }}
{{- include "retool.selectorLabels" . | nindent 4 }}
{{- if .Values.deployment.labels }}
{{ toYaml .Values.deployment.labels | indent 4 }}
{{- end }}
{{- if .Values.deployment.annotations }}
annotations:
{{ toYaml .Values.deployment.annotations | indent 4 }}
{{- end }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "retool.selectorLabels" . | nindent 6 }}
revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
template:
metadata:
annotations:
{{- if .Values.podAnnotations }}
{{ toYaml .Values.podAnnotations | indent 8 }}
{{- end }}
{{- if .Values.backend.annotations }}
{{ toYaml .Values.backend.annotations | indent 8 }}
{{- end }}
{{- if .Values.ui.annotations }}
{{ toYaml .Values.ui.annotations | indent 8 }}
{{- end }}
labels:
{{- include "retool.labels" . | nindent 8 }}
{{- include "retool.selectorLabels" . | nindent 8 }}
telemetry.retool.com/service-name: main-backend
{{- if .Values.podLabels }}
{{ toYaml .Values.podLabels | indent 8 }}
{{- end }}
{{- if .Values.backend.labels }}
{{ toYaml .Values.backend.labels | indent 8 }}
{{- end }}
{{- if .Values.ui.labels }}
{{ toYaml .Values.ui.labels | indent 8 }}
{{- end }}
spec:
serviceAccountName: {{ template "retool.serviceAccountName" . }}
{{- if .Values.priorityClassName }}
priorityClassName: "{{ .Values.priorityClassName }}"
{{- end }}
{{- with .Values.hostAliases }}
hostAliases:
{{ toYaml . | indent 8 }}
{{- end }}
{{- if .Values.initContainers }}
initContainers:
{{- range $key, $value := .Values.initContainers }}
- name: "{{ $key }}"
{{ toYaml $value | indent 8 }}
{{- end }}
{{- end }}
containers:
- name: main-backend
image: "{{ .Values.image.repository }}:{{ required "Please set a value for .Values.image.tag" .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- bash
- -c
- chmod -R +x ./docker_scripts; sync; ./docker_scripts/wait-for-it.sh -t 0 {{ template "retool.postgresql.host" . }}:{{ template "retool.postgresql.port" . }}; ./docker_scripts/start_api.sh
{{- if .Values.commandline.args }}
{{ toYaml .Values.commandline.args | indent 10 }}
{{- end }}
env:
- name: DEPLOYMENT_TEMPLATE_TYPE
value: {{ template "retool.deploymentTemplateType" . }}
- name: DEPLOYMENT_TEMPLATE_VERSION
value: {{ template "retool.deploymentTemplateVersion" . }}
- name: NODE_ENV
value: production
{{- $serviceType := list "MAIN_BACKEND" "DB_CONNECTOR" "DB_SSH_CONNECTOR" }}
{{- /*
JAVA_DBCONNECTOR in the service type only applies before the version of Retool that changes it to opt-out (3.93.0-edge),
and only if the Java dbconnector is enabled in values.yaml.
*/}}
{{- if and ( not ( include "retool_version_with_java_dbconnector_opt_out" . ) ) ( $.Values.dbconnector.java.enabled ) }}
{{- $serviceType = append $serviceType "JAVA_DBCONNECTOR" }}
{{- end }}
{{- /*
It may seem counterintuitive to add the JOBS_RUNNER service type only without a jobs runner.
The reason for this is that the backend needs to act as a jobs runner, if the jobs runner is not enabled.
*/}}
{{- if not ( include "retool.jobRunner.enabled" . ) }}
{{- $serviceType = append $serviceType "JOBS_RUNNER" }}
{{- end }}
- name: SERVICE_TYPE
value: {{ join "," $serviceType }}
{{ if and ( include "retool_version_with_java_dbconnector_opt_out" . ) ( not $.Values.dbconnector.java.enabled ) }}
- name: DISABLE_JAVA_DBCONNECTOR
value: "true"
{{ end }}
- name: CLIENT_ID
value: {{ default "" .Values.config.auth.google.clientId }}
- name: COOKIE_INSECURE
value: {{ .Values.config.useInsecureCookies | quote }}
- name: POSTGRES_HOST
value: {{ template "retool.postgresql.host" . }}
- name: POSTGRES_PORT
value: {{ template "retool.postgresql.port" . }}
- name: POSTGRES_DB
value: {{ template "retool.postgresql.database" . }}
- name: POSTGRES_USER
value: {{ template "retool.postgresql.user" . }}
- name: POSTGRES_SSL_ENABLED
value: {{ template "retool.postgresql.ssl_enabled" . }}
{{- if .Values.config.dbConnectorTimeout }}
- name: DBCONNECTOR_QUERY_TIMEOUT_MS
value: {{ .Values.config.dbConnectorTimeout | quote }}
{{- end }}
{{- if and (include "retool.workflows.enabled" .) (or (index .Values "retool-temporal-services-helm" "enabled") (.Values.workflows.temporal.enabled)) }}
- name: WORKFLOW_TEMPORAL_CLUSTER_FRONTEND_HOST
value: {{ template "retool.temporal.host" . }}
- name: WORKFLOW_TEMPORAL_CLUSTER_FRONTEND_PORT
value: {{ template "retool.temporal.port" . }}
- name: WORKFLOW_TEMPORAL_CLUSTER_NAMESPACE
value: {{ template "retool.temporal.namespace" . }}
{{- end }}
{{- if include "retool.workflows.enabled" . }}
- name: WORKFLOW_BACKEND_HOST
value: http://{{ template "retool.fullname" . }}-workflow-backend
{{- end }}
{{- if (.Values.workflows.temporal).sslEnabled }}
- name: WORKFLOW_TEMPORAL_TLS_ENABLED
value: "true"
{{- if (and (.Values.workflows.temporal).sslCert (.Values.workflows.temporal).sslKey) }}
- name: WORKFLOW_TEMPORAL_TLS_CRT
value: {{ .Values.workflows.temporal.sslCert }}
- name: WORKFLOW_TEMPORAL_TLS_KEY
valueFrom:
secretKeyRef:
{{- if (.Values.workflows.temporal).sslKeySecretName }}
name: {{ .Values.workflows.temporal.sslKeySecretName }}
key: {{ .Values.workflows.temporal.sslKeySecretKey | default "temporal-tls-key" }}
{{- else }}
name: {{ template "retool.fullname" . }}
key: "temporal-tls-key"
{{- end }}
{{- end }}
{{- end }}
{{- if include "retool.codeExecutor.enabled" . }}
- name: CODE_EXECUTOR_INGRESS_DOMAIN
value: http://{{ template "retool.codeExecutor.name" . }}
{{- end }}
{{- include "retool.telemetry.includeEnvVars" . | nindent 10 }}
{{- if and (not .Values.externalSecrets.enabled) (not .Values.externalSecrets.externalSecretsOperator.enabled) }}
- name: LICENSE_KEY
valueFrom:
secretKeyRef:
{{- if .Values.config.licenseKeySecretName }}
name: {{ .Values.config.licenseKeySecretName }}
key: {{ .Values.config.licenseKeySecretKey | default "license-key" }}
{{- else }}
name: {{ template "retool.fullname" . }}
key: license-key
{{- end }}
- name: JWT_SECRET
valueFrom:
secretKeyRef:
{{- if .Values.config.jwtSecretSecretName }}
name: {{ .Values.config.jwtSecretSecretName }}
key: {{ .Values.config.jwtSecretSecretKey | default "jwt-secret" }}
{{- else }}
name: {{ template "retool.fullname" . }}
key: jwt-secret
{{- end }}
- name: ENCRYPTION_KEY
valueFrom:
secretKeyRef:
{{- if .Values.config.encryptionKeySecretName }}
name: {{ .Values.config.encryptionKeySecretName }}
key: {{ .Values.config.encryptionKeySecretKey | default "encryption-key" }}
{{- else }}
name: {{ template "retool.fullname" . }}
key: encryption-key
{{- end }}
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
{{- if .Values.postgresql.enabled }}
name: {{ template "retool.postgresql.fullname" . }}
# `postgres` is the default admin username for postgres in the subchart we use, so it needs the admin password
# if a different username is picked, then it needs the custom password instead.
{{- if eq .Values.postgresql.auth.username "postgres" }}
key: postgres-password
{{- else }}
key: password
{{- end }}
{{- else }}
{{- if .Values.config.postgresql.passwordSecretName }}
name: {{ .Values.config.postgresql.passwordSecretName }}
key: {{ .Values.config.postgresql.passwordSecretKey | default "postgresql-password" }}
{{- else }}
name: {{ template "retool.fullname" . }}
key: postgresql-password
{{- end }}
{{- end }}
- name: CLIENT_SECRET
valueFrom:
secretKeyRef:
{{- if .Values.config.auth.google.clientSecretSecretName }}
name: {{ .Values.config.auth.google.clientSecretSecretName }}
key: {{ .Values.config.auth.google.clientSecretSecretKey | default "google-client-secret" }}
{{- else }}
name: {{ template "retool.fullname" . }}
key: google-client-secret
{{- end }}
{{- end }}
{{- range $key, $value := .Values.env }}
- name: "{{ $key }}"
value: "{{ $value }}"
{{- end }}
{{- range .Values.environmentSecrets }}
- name: {{ .name }}
valueFrom:
secretKeyRef:
name: {{ .secretKeyRef.name }}
key: {{ .secretKeyRef.key }}
{{- end }}
{{- with .Values.environmentVariables }}
{{ toYaml . | indent 10 }}
{{- end }}
{{- if .Values.externalSecrets.enabled }}
envFrom:
- secretRef:
name: {{ .Values.externalSecrets.name }}
{{- range .Values.externalSecrets.secrets }}
- secretRef:
name: {{ .name }}
{{- end }}
{{- end }}
{{- if .Values.externalSecrets.externalSecretsOperator.enabled }}
envFrom:
{{- range .Values.externalSecrets.externalSecretsOperator.secretRef }}
- secretRef:
name: {{ .name }}
{{- end }}
{{- end }}
ports:
- containerPort: {{ .Values.service.internalPort }}
name: http-server
protocol: TCP
{{- if .Values.livenessProbe.enabled }}
livenessProbe:
httpGet:
path: {{ .Values.livenessProbe.path }}
port: {{ .Values.service.internalPort }}
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
{{- end }}
{{- if .Values.readinessProbe.enabled }}
readinessProbe:
httpGet:
path: {{ .Values.readinessProbe.path }}
port: {{ .Values.service.internalPort }}
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
successThreshold: {{ .Values.readinessProbe.successThreshold }}
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
{{- end }}
{{- if .Values.preStopHook.enabled }}
lifecycle:
preStop:
exec:
command: ["sleep", "30"]
{{- end }}
{{- if .Values.startupProbe.enabled }}
startupProbe:
httpGet:
path: {{ .Values.startupProbe.path }}
port: {{ .Values.service.internalPort }}
initialDelaySeconds: {{ .Values.startupProbe.initialDelaySeconds }}
timeoutSeconds: {{ .Values.startupProbe.timeoutSeconds }}
successThreshold: {{ .Values.startupProbe.successThreshold }}
periodSeconds: {{ .Values.startupProbe.periodSeconds }}
{{- end }}
resources:
{{ toYaml .Values.resources | indent 10 }}
volumeMounts:
{{- range $configFile := (keys .Values.files) }}
- name: {{ template "retool.name" $ }}
mountPath: "/usr/share/retool/config/{{ $configFile }}"
subPath: {{ $configFile }}
{{- end }}
{{if and .Values.persistentVolumeClaim.enabled .Values.persistentVolumeClaim.mountPath }}
- name: retool-pv
mountPath: {{ .Values.persistentVolumeClaim.mountPath }}
{{- end }}
{{- if .Values.extraVolumeMounts }}
{{ toYaml .Values.extraVolumeMounts | indent 8 }}
{{- end }}
{{- with .Values.extraContainers }}
{{ tpl . $ | indent 6 }}
{{- end }}
{{- range .Values.extraConfigMapMounts }}
- name: {{ .name }}
mountPath: {{ .mountPath }}
subPath: {{ .subPath }}
{{- end }}
{{- if .Values.securityContext.extraContainerSecurityContext }}
securityContext:
{{ toYaml .Values.securityContext.extraContainerSecurityContext | indent 10 }}
{{- end }}
{{- if .Values.image.pullSecrets }}
imagePullSecrets:
{{ toYaml .Values.image.pullSecrets | indent 8 }}
{{- end }}
{{- if .Values.affinity }}
affinity:
{{ toYaml .Values.affinity | indent 8 }}
{{- end }}
{{- if .Values.nodeSelector }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
tolerations:
{{ toYaml .Values.tolerations | indent 8 }}
{{- if .Values.securityContext.enabled }}
securityContext:
runAsUser: {{ .Values.securityContext.runAsUser }}
fsGroup: {{ .Values.securityContext.fsGroup }}
{{- if .Values.securityContext.extraSecurityContext }}
{{ toYaml .Values.securityContext.extraSecurityContext | indent 8 }}
{{- end }}
{{- end }}
volumes:
{{- range .Values.extraConfigMapMounts }}
- name: {{ .name }}
configMap:
name: {{ .configMap }}
{{- end }}
{{- if .Values.persistentVolumeClaim.enabled }}
- name: retool-pv
persistentVolumeClaim:
claimName: {{ default (include "retool.fullname" .) .Values.persistentVolumeClaim.existingClaim }}
{{- end }}
{{- if .Values.extraVolumes }}
{{ toYaml .Values.extraVolumes | indent 8 }}
{{- end }}
---
{{- if .Values.podDisruptionBudget }}
{{- if semverCompare ">=1.21-0" .Capabilities.KubeVersion.Version -}}
apiVersion: policy/v1
{{- else -}}
apiVersion: policy/v1beta1
{{- end }}
kind: PodDisruptionBudget
metadata:
name: {{ template "retool.fullname" . }}
spec:
{{ toYaml .Values.podDisruptionBudget }}
selector:
matchLabels:
{{- include "retool.selectorLabels" . | nindent 6 }}
{{- end }}