-
Notifications
You must be signed in to change notification settings - Fork 472
/
webserver-deployment.yaml
178 lines (178 loc) · 8.21 KB
/
webserver-deployment.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
{{- $podNodeSelector := include "airflow.podNodeSelector" (dict "Release" .Release "Values" .Values "nodeSelector" .Values.web.nodeSelector) }}
{{- $podTopologySpreadConstraints := include "airflow.podTopologySpreadConstraints" (dict "Release" .Release "Values" .Values "topologySpreadConstraints" .Values.web.topologySpreadConstraints) }}
{{- $podAffinity := include "airflow.podAffinity" (dict "Release" .Release "Values" .Values "affinity" .Values.web.affinity) }}
{{- $podTolerations := include "airflow.podTolerations" (dict "Release" .Release "Values" .Values "tolerations" .Values.web.tolerations) }}
{{- $podSecurityContext := include "airflow.podSecurityContext" (dict "Release" .Release "Values" .Values "securityContext" .Values.web.securityContext) }}
{{- $extraPipPackages := concat .Values.airflow.extraPipPackages .Values.web.extraPipPackages }}
{{- $extraVolumeMounts := .Values.web.extraVolumeMounts }}
{{- $volumeMounts := include "airflow.volumeMounts" (dict "Release" .Release "Values" .Values "extraPipPackages" $extraPipPackages "extraVolumeMounts" $extraVolumeMounts) }}
{{- $extraVolumes := .Values.web.extraVolumes }}
{{- $volumes := include "airflow.volumes" (dict "Release" .Release "Values" .Values "extraPipPackages" $extraPipPackages "extraVolumes" $extraVolumes "extraVolumeMounts" $extraVolumeMounts) }}
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 }}
strategy:
type: RollingUpdate
rollingUpdate:
## multiple web pods can safely run concurrently
maxSurge: 25%
maxUnavailable: 0
selector:
matchLabels:
app: {{ include "airflow.labels.app" . }}
component: web
release: {{ .Release.Name }}
template:
metadata:
annotations:
checksum/secret-config-envs: {{ include (print $.Template.BasePath "/config/secret-config-envs.yaml") . | sha256sum }}
checksum/secret-local-settings: {{ include (print $.Template.BasePath "/config/secret-local-settings.yaml") . | sha256sum }}
{{- if and (.Values.web.webserverConfig.enabled) (not .Values.web.webserverConfig.existingSecret) }}
checksum/config-webserver-config: {{ include (print $.Template.BasePath "/config/secret-webserver-config.yaml") . | 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:
restartPolicy: Always
{{- if .Values.airflow.image.pullSecret }}
imagePullSecrets:
- name: {{ .Values.airflow.image.pullSecret }}
{{- end }}
{{- if $podNodeSelector }}
nodeSelector:
{{- $podNodeSelector | nindent 8 }}
{{- end }}
{{- if $podTopologySpreadConstraints }}
topologySpreadConstraints:
{{- $podTopologySpreadConstraints | nindent 8 }}
{{- end }}
{{- if $podAffinity }}
affinity:
{{- $podAffinity | nindent 8 }}
{{- end }}
{{- if $podTolerations }}
tolerations:
{{- $podTolerations | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "airflow.serviceAccountName" . }}
{{- if $podSecurityContext }}
securityContext:
{{- $podSecurityContext | nindent 8 }}
{{- end }}
initContainers:
{{- if $extraPipPackages }}
{{- include "airflow.init_container.install_pip_packages" (dict "Release" .Release "Values" .Values "extraPipPackages" $extraPipPackages) | indent 8 }}
{{- end }}
{{- if .Values.dags.gitSync.enabled }}
{{- include "airflow.container.git_sync" (dict "Release" .Release "Values" .Values "sync_one_time" "true") | indent 8 }}
{{- end }}
{{- include "airflow.init_container.check_db" (dict "Release" .Release "Values" .Values "volumeMounts" $volumeMounts) | indent 8 }}
{{- include "airflow.init_container.wait_for_db_migrations" (dict "Release" .Release "Values" .Values "volumeMounts" $volumeMounts) | indent 8 }}
{{- if .Values.airflow.extraInitContainers }}
{{- toYaml .Values.airflow.extraInitContainers | nindent 8 }}
{{- end }}
{{- if .Values.web.extraInitContainers }}
{{- toYaml .Values.web.extraInitContainers | nindent 8 }}
{{- end }}
containers:
- name: airflow-web
{{- include "airflow.image" . | indent 10 }}
resources:
{{- toYaml .Values.web.resources | nindent 12 }}
ports:
- name: web
containerPort: 8080
protocol: TCP
envFrom:
{{- include "airflow.envFrom" . | indent 12 }}
env:
{{- include "airflow.env" . | indent 12 }}
command:
{{- include "airflow.command" . | indent 12 }}
args:
- "bash"
- "-c"
- "exec airflow webserver"
{{- if .Values.web.livenessProbe.enabled }}
livenessProbe:
initialDelaySeconds: {{ .Values.web.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.web.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.web.livenessProbe.timeoutSeconds }}
failureThreshold: {{ .Values.web.livenessProbe.failureThreshold }}
httpGet:
scheme: {{ include "airflow.web.scheme" . }}
{{- $airflowUrl := .Values.airflow.config.AIRFLOW__WEBSERVER__BASE_URL | default "" | printf "%s/health" | urlParse }}
path: {{ get $airflowUrl "path" }}
port: web
{{- end }}
{{- if .Values.web.readinessProbe.enabled }}
readinessProbe:
initialDelaySeconds: {{ .Values.web.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.web.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.web.readinessProbe.timeoutSeconds }}
failureThreshold: {{ .Values.web.readinessProbe.failureThreshold }}
httpGet:
scheme: {{ include "airflow.web.scheme" . }}
{{- $airflowUrl := .Values.airflow.config.AIRFLOW__WEBSERVER__BASE_URL | default "" | printf "%s/health" | urlParse }}
path: {{ get $airflowUrl "path" }}
port: web
{{- end }}
volumeMounts:
{{- $volumeMounts | indent 12 }}
{{- if .Values.web.webserverConfig.enabled }}
- name: webserver-config
mountPath: /opt/airflow/webserver_config.py
subPath: webserver_config.py
readOnly: true
{{- end }}
{{- if .Values.dags.gitSync.enabled }}
{{- include "airflow.container.git_sync" . | indent 8 }}
{{- end }}
{{- if .Values.airflow.extraContainers }}
{{- toYaml .Values.airflow.extraContainers | nindent 8 }}
{{- end }}
{{- if .Values.web.extraContainers }}
{{- toYaml .Values.web.extraContainers | nindent 8 }}
{{- end }}
volumes:
{{- $volumes | indent 8 }}
{{- if .Values.web.webserverConfig.enabled }}
- name: webserver-config
secret:
{{- if .Values.web.webserverConfig.existingSecret }}
secretName: {{ .Values.web.webserverConfig.existingSecret }}
{{- else }}
secretName: {{ include "airflow.fullname" . }}-webserver-config
{{- end }}
defaultMode: 0644
{{- end }}