-
Notifications
You must be signed in to change notification settings - Fork 15
/
deployment-server.yaml
294 lines (294 loc) · 11.6 KB
/
deployment-server.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
{{- $metricsPath := "/tmp/django_metrics" -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "substra.fullname" . }}-server
labels:
{{ include "substra.labels" . | nindent 4 }}
app.kubernetes.io/name: {{ template "substra.name" . }}-server
spec:
replicas: {{ .Values.server.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ template "substra.name" . }}-server
{{ include "substra.selectorLabels" . | nindent 8}}
strategy:
type: {{ .Values.server.updateStrategy.type }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ template "substra.name" . }}-server
role-redis-client: 'true'
role-database-client: 'true'
role-internet-ingress: 'true'
role-internet-egress: 'true'
role-orchestrator-client: 'true'
{{- if .Values.server.allowLocalRequests }}
role-server-client: 'true'
{{- end }}
role-storage-client: 'true'
{{ include "substra.labels" . | nindent 8 }}
annotations:
# This will cause the pod to restart if the content of the ConfigMap is updated through Helm
checksum-cm-orchestrator: {{ include (print $.Template.BasePath "/configmap-orchestrator.yaml") . | sha256sum }}
checksum-cm-settings: {{ include (print $.Template.BasePath "/configmap-settings.yaml") . | sha256sum }}
checksum-cm-db: {{ include (print $.Template.BasePath "/configmap-database.yaml") . | sha256sum }}
checksum-cm-oidc: {{ include (print $.Template.BasePath "/configmap-oidc.yaml") . | sha256sum }}
checksum-secret-objectstore : {{ include (print $.Template.BasePath "/secret-objectstore.yaml") . | sha256sum }}
checksum-secret-database : {{ include (print $.Template.BasePath "/secret-database.yaml") . | sha256sum }}
spec:
{{- if .Values.server.podSecurityContext.enabled }}
securityContext:
runAsNonRoot: true
seccompProfile:
type: RuntimeDefault
fsGroup: {{ .Values.server.podSecurityContext.fsGroup }}
runAsUser: {{ .Values.server.podSecurityContext.runAsUser }}
runAsGroup: {{ .Values.server.podSecurityContext.runAsGroup }}
{{- end }}
{{- with .Values.server.image.pullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: server
image: {{ include "substra-backend.images.name" (dict "img" .Values.server.image "defaultTag" $.Chart.AppVersion) }}
securityContext:
allowPrivilegeEscalation: false
runAsNonRoot: true
seccompProfile:
type: RuntimeDefault
capabilities:
drop: ["ALL"]
imagePullPolicy: "{{ .Values.server.image.pullPolicy }}"
command: ["/bin/bash"]
{{- if eq .Values.settings "prod" }}
args: ["-c", "uwsgi --ini uwsgi.ini"]
{{- else }}
args: ["-c", "watchmedo auto-restart --directory=./ --pattern=*.py --recursive -- uwsgi --ini uwsgi.ini --honour-stdin"]
stdin: true
tty: true
{{- end }}
envFrom:
- configMapRef:
name: {{ include "substra.fullname" . }}-orchestrator
- secretRef:
name: {{ include "substra.fullname" . }}-objectstore
- configMapRef:
name: {{ include "substra.fullname" . }}-settings
- configMapRef:
name: {{ include "substra.fullname" . }}-database
- secretRef:
name: {{ include "substra-backend.database.secret-name" . }}
- secretRef:
name: {{ include "substra.fullname" . }}-server-key
- configMapRef:
name: {{ include "substra.fullname" . }}-oidc
{{- if .Values.oidc.enabled }}
- secretRef:
name: {{ .Values.oidc.clientSecretName }}
{{- end }}
env:
- name: HOST_IP
valueFrom:
fieldRef:
fieldPath: status.hostIP
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
{{- if .Values.server.metrics.enabled }}
- name: ENABLE_METRICS
value: "True"
- name: PROMETHEUS_MULTIPROC_DIR
value: {{ $metricsPath }}
{{- end }}
{{- if .Values.privateCa.enabled }}
- name: REQUESTS_CA_BUNDLE
value: /etc/ssl/certs/ca-certificates.crt
{{- end }}
ports:
- name: http
containerPort: 8000
protocol: TCP
volumeMounts:
- name: data-servermedias
mountPath: /var/substra/servermedias
- name: statics
mountPath: /usr/src/app/backend/statics
- name: uwsgi
mountPath: /usr/src/app/uwsgi.ini
subPath: uwsgi.ini
readOnly: true
- name: runtime-secrets
mountPath: /var/substra/runtime-secrets
{{- if .Values.privateCa.enabled }}
- mountPath: /etc/ssl/certs
name: ssl-certs
{{- end }}
{{ if .Values.orchestrator.tls.enabled }}
- name: orchestrator-tls-cacert
mountPath: /var/substra/orchestrator/tls/server
{{ if .Values.orchestrator.tls.mtls.enabled }}
- name: orchestrator-tls-client-pair
mountPath: /var/substra/orchestrator/tls/client
{{ end }}
{{ end }}
{{- if .Values.server.metrics.enabled }}
- name: metrics
mountPath: {{ $metricsPath }}
{{- end }}
{{- if .Values.server.livenessProbe.enabled }}
livenessProbe:
httpGet:
path: {{ .Values.server.livenessProbe.path }}
port: http
initialDelaySeconds: {{ .Values.server.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.server.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.server.livenessProbe.timeoutSeconds }}
successThreshold: {{ .Values.server.livenessProbe.successThreshold }}
failureThreshold: {{ .Values.server.livenessProbe.failureThreshold }}
{{- end }}
{{- if .Values.server.readinessProbe.enabled }}
readinessProbe:
httpGet:
path: {{ .Values.server.readinessProbe.path }}
port: http
initialDelaySeconds: {{ .Values.server.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.server.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.server.readinessProbe.timeoutSeconds }}
successThreshold: {{ .Values.server.readinessProbe.successThreshold }}
failureThreshold: {{ .Values.server.readinessProbe.failureThreshold }}
{{- end }}
resources:
{{- toYaml .Values.server.resources | nindent 12 }}
{{- if .Values.server.metrics.enabled }}
- name: metrics-sidecar
image: {{ include "substra-backend.images.name" (dict "img" .Values.server.metrics.image "defaultTag" $.Chart.AppVersion) }}
imagePullPolicy: {{ .Values.server.metrics.image.pullPolicy }}
securityContext:
allowPrivilegeEscalation: false
runAsNonRoot: true
seccompProfile:
type: RuntimeDefault
capabilities:
drop: ["ALL"]
command: ["/bin/bash"]
args:
- "-c"
- "python /usr/src/app/metrics_exporter/server.py"
envFrom:
- configMapRef:
name: {{ include "substra.fullname" . }}-redis
env:
- name: PROMETHEUS_MULTIPROC_DIR
value: {{ $metricsPath }}
- name: CELERY_MONITORING_ENABLED
value: "True"
- name: CELERY_BROKER_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "substra-backend.redis.secretName" . }}
key: {{ include "substra-backend.redis.secretPasswordKey" . }}
ports:
- name: metrics
containerPort: 8001
protocol: TCP
volumeMounts:
- name: metrics
mountPath: {{ $metricsPath }}
{{- end }}
initContainers:
{{- include "common.addCertInitContainer" . | nindent 6 }}
- name: init-collectstatic
image: {{ include "substra-backend.images.name" (dict "img" .Values.server.image "defaultTag" $.Chart.AppVersion) }}
command: ['python', 'manage.py', 'collectstatic', '--noinput']
securityContext:
allowPrivilegeEscalation: false
runAsNonRoot: true
seccompProfile:
type: RuntimeDefault
capabilities:
drop: ["ALL"]
envFrom:
- configMapRef:
name: {{ include "substra.fullname" . }}-orchestrator
- configMapRef:
name: {{ include "substra.fullname" . }}-settings
env:
- name: DJANGO_SETTINGS_MODULE
value: backend.settings.{{ .Values.settings }}
volumeMounts:
- name: statics
mountPath: /usr/src/app/backend/statics
{{- include "common.waitPostgresqlInitContainer" . | nindent 6 }}
- name: init-migrate
image: {{ include "substra-backend.images.name" (dict "img" .Values.server.image "defaultTag" $.Chart.AppVersion) }}
command: ['python', 'manage.py', 'migrate']
securityContext:
allowPrivilegeEscalation: false
runAsNonRoot: true
seccompProfile:
type: RuntimeDefault
capabilities:
drop: ["ALL"]
envFrom:
- configMapRef:
name: {{ include "substra.fullname" . }}-orchestrator
- secretRef:
name: {{ include "substra.fullname" . }}-objectstore
- configMapRef:
name: {{ include "substra.fullname" . }}-database
- configMapRef:
name: {{ include "substra.fullname" . }}-settings
- secretRef:
name: {{ include "substra-backend.database.secret-name" . }}
env:
- name: DJANGO_SETTINGS_MODULE
value: backend.settings.{{ .Values.settings }}
{{- include "common.waitMinIOContainer" . | nindent 6 }}
{{- include "common.waitRedisInitContainer" . | nindent 6 }}
volumes:
- name: data-servermedias
persistentVolumeClaim:
claimName: {{ .Values.server.persistence.servermedias.existingClaim | default (print (include "substra.fullname" $) "-servermedias") }}
- name: statics
emptyDir: {}
- name: runtime-secrets
emptyDir: {}
- name: uwsgi
configMap:
name: {{ include "substra.fullname" . }}-server-uwsgi
{{- if .Values.server.metrics.enabled }}
- name: metrics
emptyDir: {}
{{- end }}
{{- if .Values.privateCa.enabled }}
- name: ssl-certs
emptyDir: {}
- name: private-ca
secret:
secretName: {{ .Values.privateCa.secret.name }}
{{- end }}
{{ if .Values.orchestrator.tls.enabled }}
- name: orchestrator-tls-cacert
secret:
secretName: {{ .Values.orchestrator.tls.cacert }}
{{ if .Values.orchestrator.tls.mtls.enabled }}
- name: orchestrator-tls-client-pair
secret:
secretName: {{ .Values.orchestrator.tls.mtls.clientCertificate }}
{{ end }}
{{ end }}
{{- with .Values.server.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.server.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.server.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}