This repository was archived by the owner on Feb 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16.3k
Expand file tree
/
Copy pathwebserver-deployment.yaml
More file actions
302 lines (302 loc) · 12.4 KB
/
Copy pathwebserver-deployment.yaml
File metadata and controls
302 lines (302 loc) · 12.4 KB
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
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "airflow.fullname" . }}-web
{{- if .Values.web.annotations }}
annotations:
{{- toYaml .Values.web.annotations | nindent 4 }}
{{- end }}
labels:
app: {{ include "airflow.labels.app" . }}
component: web
chart: {{ include "airflow.labels.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- if .Values.web.labels }}
{{- toYaml .Values.web.labels | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.web.replicas }}
minReadySeconds: {{ .Values.web.minReadySeconds }}
strategy:
# this is safe - multiple web pods can run concurrently
type: RollingUpdate
rollingUpdate:
maxSurge: 25%
maxUnavailable: 0
selector:
matchLabels:
app: {{ include "airflow.labels.app" . }}
component: web
release: {{ .Release.Name }}
template:
metadata:
annotations:
checksum/config-env: {{ include (print $.Template.BasePath "/config/configmap-env.yaml") . | sha256sum }}
checksum/config-git-clone: {{ include (print $.Template.BasePath "/config/configmap-scripts-git.yaml") . | sha256sum }}
checksum/config-scripts: {{ include (print $.Template.BasePath "/config/configmap-scripts.yaml") . | sha256sum }}
{{- if and (.Values.dags.git.url) (.Values.dags.git.ref) }}
checksum/dags-git-ref: {{ .Values.dags.git.ref | sha256sum }}
{{- end }}
{{- if .Values.airflow.podAnnotations }}
{{- toYaml .Values.airflow.podAnnotations | nindent 8 }}
{{- end }}
{{- if .Values.web.podAnnotations }}
{{- toYaml .Values.web.podAnnotations | nindent 8 }}
{{- end }}
{{- if .Values.web.safeToEvict }}
cluster-autoscaler.kubernetes.io/safe-to-evict: "true"
{{- end }}
labels:
app: {{ include "airflow.labels.app" . }}
component: web
release: {{ .Release.Name }}
{{- if .Values.web.podLabels }}
{{- toYaml .Values.web.podLabels | nindent 8 }}
{{- end }}
spec:
{{- if .Values.airflow.image.pullSecret }}
imagePullSecrets:
- name: {{ .Values.airflow.image.pullSecret }}
{{- end }}
restartPolicy: Always
{{- if .Values.web.nodeSelector }}
nodeSelector:
{{- toYaml .Values.web.nodeSelector | nindent 8 }}
{{- end }}
{{- if .Values.web.affinity }}
affinity:
{{- toYaml .Values.web.affinity | nindent 8 }}
{{- end }}
{{- if .Values.web.tolerations }}
tolerations:
{{- toYaml .Values.web.tolerations | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "airflow.serviceAccountName" . }}
{{- if .Values.web.securityContext }}
securityContext:
{{- toYaml .Values.web.securityContext | nindent 8 }}
{{- end }}
{{- if and ( .Values.dags.initContainer.enabled ) ( not .Values.web.serializeDAGs ) }}
initContainers:
- name: git-clone
image: {{ .Values.dags.initContainer.image.repository }}:{{ .Values.dags.initContainer.image.tag }}
imagePullPolicy: {{ .Values.dags.initContainer.image.pullPolicy }}
envFrom:
- configMapRef:
name: "{{ include "airflow.fullname" . }}-env"
env:
{{- include "airflow.mapenvsecrets" . | indent 12 }}
resources:
{{- toYaml .Values.dags.initContainer.resources | nindent 12 }}
command:
- /home/airflow/git/git-clone.sh
args:
- "{{ .Values.dags.git.url }}"
- "{{ .Values.dags.git.ref }}"
- "{{ .Values.dags.initContainer.mountPath }}{{ .Values.dags.initContainer.syncSubPath }}"
- "{{ .Values.dags.git.repoHost }}"
- "{{ .Values.dags.git.repoPort }}"
- "{{ .Values.dags.git.privateKeyName }}"
volumeMounts:
- name: git-clone
mountPath: /home/airflow/git
- name: dags-data
mountPath: "{{ .Values.dags.initContainer.mountPath }}"
{{- if .Values.dags.git.secret }}
- name: git-clone-secret
mountPath: /keys
{{- end }}
{{- end }}
containers:
{{- if and ( .Values.dags.git.gitSync.enabled ) ( not .Values.web.serializeDAGs ) }}
- name: git-sync
image: {{ .Values.dags.git.gitSync.image.repository }}:{{ .Values.dags.git.gitSync.image.tag }}
imagePullPolicy: {{ .Values.dags.git.gitSync.image.pullPolicy }}
envFrom:
- configMapRef:
name: "{{ include "airflow.fullname" . }}-env"
env:
{{- include "airflow.mapenvsecrets" . | indent 12 }}
command:
- /home/airflow/git/git-sync.sh
args:
- "{{ .Values.dags.git.url }}"
- "{{ .Values.dags.git.ref }}"
- "{{ .Values.dags.initContainer.mountPath }}{{ .Values.dags.initContainer.syncSubPath }}"
- "{{ .Values.dags.git.repoHost }}"
- "{{ .Values.dags.git.repoPort }}"
- "{{ .Values.dags.git.privateKeyName }}"
- "{{ .Values.dags.git.gitSync.refreshTime }}"
volumeMounts:
- name: git-clone
mountPath: /home/airflow/git
- name: dags-data
mountPath: "{{ .Values.dags.initContainer.mountPath }}"
{{- if .Values.dags.git.secret }}
- name: git-clone-secret
mountPath: /keys
{{- end }}
resources:
{{- toYaml .Values.dags.git.gitSync.resources | nindent 12 }}
{{- end }}
- name: {{ .Chart.Name }}-web
image: {{ .Values.airflow.image.repository }}:{{ .Values.airflow.image.tag }}
imagePullPolicy: {{ .Values.airflow.image.pullPolicy}}
ports:
- name: web
containerPort: 8080
protocol: TCP
envFrom:
- configMapRef:
name: "{{ include "airflow.fullname" . }}-env"
env:
{{- include "airflow.mapenvsecrets" . | indent 12 }}
resources:
{{- toYaml .Values.web.resources | nindent 12 }}
volumeMounts:
- name: scripts
mountPath: /home/airflow/scripts
{{- if .Values.web.secretsMap }}
- name: {{ .Values.web.secretsMap }}-volume
readOnly: true
mountPath: {{ $.Values.web.secretsDir }}
{{- else }}
{{- range .Values.web.secrets }}
- name: {{ . }}-volume
readOnly: true
mountPath: {{ $.Values.web.secretsDir }}/{{ . }}
{{- end }}
{{- end }}
{{- if .Values.dags.persistence.enabled }}
- name: dags-data
mountPath: {{ .Values.dags.path }}
subPath: {{ .Values.dags.persistence.subPath }}
{{- else if or (.Values.dags.initContainer.enabled) (.Values.dags.git.gitSync.enabled) }}
- name: dags-data
mountPath: {{ .Values.dags.path }}
{{- end }}
{{- if .Values.logs.persistence.enabled }}
- name: logs-data
mountPath: {{ .Values.logs.path }}
subPath: {{ .Values.logs.persistence.subPath }}
{{- end }}
{{- range .Values.airflow.extraConfigmapMounts }}
- name: {{ .name }}
mountPath: {{ .mountPath }}
readOnly: {{ .readOnly }}
{{- if .subPath }}
subPath: {{ .subPath }}
{{- end }}
{{- end }}
{{- if .Values.airflow.extraVolumeMounts }}
{{- toYaml .Values.airflow.extraVolumeMounts | nindent 12 }}
{{- end }}
command:
- "/usr/bin/dumb-init"
- "--"
args:
- "bash"
- "-c"
- >
true \
{{- if gt .Values.web.initialStartupDelay 0.0 }}
&& echo "*** waiting {{ .Values.web.initialStartupDelay }}s..." \
&& sleep {{ .Values.web.initialStartupDelay }} \
{{- end }}
&& mkdir -p /home/airflow/.local/bin \
&& export PATH="/home/airflow/.local/bin:$PATH" \
{{- if .Values.dags.installRequirements }}
&& echo "*** installing requirements..." \
&& /home/airflow/scripts/install-requirements.sh \
{{- end }}
{{- if .Values.airflow.extraPipPackages }}
&& echo "*** installing global extra pip packages..." \
&& pip install --user {{ range .Values.airflow.extraPipPackages }} {{ . | quote }} {{ end }} \
{{- end }}
{{- if .Values.web.extraPipPackages }}
&& echo "*** installing extra pip packages..." \
&& pip install --user {{ range .Values.web.extraPipPackages }} {{ . | quote }} {{ end }} \
{{- end }}
&& echo "*** running webserver..." \
&& exec airflow webserver
{{- if .Values.web.livenessProbe.enabled }}
livenessProbe:
httpGet:
scheme: {{ .Values.web.livenessProbe.scheme }}
{{- if .Values.ingress.web.livenessPath }}
path: "{{ .Values.ingress.web.livenessPath }}"
{{- else }}
path: "{{ .Values.ingress.web.path }}/health"
{{- end }}
port: web
initialDelaySeconds: {{ .Values.web.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.web.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.web.livenessProbe.timeoutSeconds }}
successThreshold: {{ .Values.web.livenessProbe.successThreshold }}
failureThreshold: {{ .Values.web.livenessProbe.failureThreshold }}
{{- end }}
{{- if .Values.web.readinessProbe.enabled }}
readinessProbe:
httpGet:
scheme: {{ .Values.web.readinessProbe.scheme }}
path: "{{ .Values.ingress.web.path }}/health"
port: web
initialDelaySeconds: {{ .Values.web.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.web.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.web.readinessProbe.timeoutSeconds }}
successThreshold: {{ .Values.web.readinessProbe.successThreshold }}
failureThreshold: {{ .Values.web.readinessProbe.failureThreshold }}
{{- end }}
{{- if .Values.airflow.extraContainers }}
{{- toYaml .Values.airflow.extraContainers | nindent 8 }}
{{- end }}
volumes:
- name: scripts
configMap:
name: {{ include "airflow.fullname" . }}-scripts
defaultMode: 0755
{{- if .Values.web.secretsMap }}
- name: {{ .Values.web.secretsMap }}-volume
secret:
secretName: {{ .Values.web.secretsMap }}
{{- else }}
{{- range .Values.web.secrets }}
- name: {{ . }}-volume
secret:
secretName: {{ . }}
{{- end }}
{{- end }}
{{- if .Values.dags.persistence.enabled }}
- name: dags-data
persistentVolumeClaim:
claimName: {{ .Values.dags.persistence.existingClaim | default (include "airflow.fullname" . ) }}
{{- else if or (.Values.dags.initContainer.enabled) (.Values.dags.git.gitSync.enabled) }}
- name: dags-data
emptyDir: {}
{{- end }}
{{- if .Values.logs.persistence.enabled }}
- name: logs-data
persistentVolumeClaim:
claimName: {{ .Values.logs.persistence.existingClaim | default (printf "%s-logs" (include "airflow.fullname" . | trunc 58 )) }}
{{- end }}
{{- if or (.Values.dags.initContainer.enabled) (.Values.dags.git.gitSync.enabled) }}
- name: git-clone
configMap:
name: {{ include "airflow.fullname" . }}-scripts-git
defaultMode: 0755
{{- if .Values.dags.git.secret }}
- name: git-clone-secret
secret:
secretName: {{ .Values.dags.git.secret }}
defaultMode: 0700
{{- end }}
{{- end }}
{{- range .Values.airflow.extraConfigmapMounts }}
- name: {{ .name }}
configMap:
name: {{ .configMap }}
{{- end }}
{{- if .Values.airflow.extraVolumes }}
{{- toYaml .Values.airflow.extraVolumes | nindent 8 }}
{{- end }}