Merge "[AAI] Add model-loader tracing config"
[oom.git] / kubernetes / platform / components / oauth2-proxy / components / oauth2-proxy / templates / deployment.yaml
1 apiVersion: apps/v1
2 kind: Deployment
3 metadata:
4   labels:
5     app: {{ template "oauth2-proxy.name" . }}
6 {{- include "oauth2-proxy.labels" . | indent 4 }}
7   {{- if .Values.deploymentAnnotations }}
8   annotations:
9 {{ toYaml .Values.deploymentAnnotations | indent 8 }}
10   {{- end }}
11   name: {{ template "oauth2-proxy.fullname" . }}
12 spec:
13   replicas: {{ .Values.replicaCount }}
14   {{- if .Values.revisionHistoryLimit }}
15   revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
16   {{- end }}
17   selector:
18     matchLabels:
19       {{- include "oauth2-proxy.selectorLabels" . | indent 6 }}
20   template:
21     metadata:
22       annotations:
23         checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
24         {{- if .Values.alphaConfig.enabled }}
25         checksum/alpha-config: {{ include (print $.Template.BasePath "/configmap-alpha.yaml") . | sha256sum }}
26         {{- end }}
27         checksum/config-emails: {{ include (print $.Template.BasePath "/configmap-authenticated-emails-file.yaml") . | sha256sum }}
28         checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
29         checksum/google-secret: {{ include (print $.Template.BasePath "/google-secret.yaml") . | sha256sum }}
30         checksum/redis-secret: {{ include (print $.Template.BasePath "/redis-secret.yaml") . | sha256sum }}
31 {{- if .Values.htpasswdFile.enabled }}
32         checksum/htpasswd: {{ include (print $.Template.BasePath "/secret-htpasswd-file.yaml") . | sha256sum }}
33 {{- end }}
34     {{- if .Values.podAnnotations }}
35 {{ toYaml .Values.podAnnotations | indent 8 }}
36     {{- end }}
37       labels:
38         app: {{ template "oauth2-proxy.name" . }}
39         {{- include "oauth2-proxy.labels" . | indent 8 }}
40       {{- if .Values.podLabels }}
41 {{ toYaml .Values.podLabels | indent 8 }}
42       {{- end }}
43     spec:
44     {{- if .Values.priorityClassName }}
45       priorityClassName: "{{ .Values.priorityClassName }}"
46     {{- end }}
47       {{- with .Values.podSecurityContext }}
48       securityContext:
49         {{- toYaml . | nindent 8 }}
50       {{- end }}
51       serviceAccountName: {{ template "oauth2-proxy.serviceAccountName" . }}
52       automountServiceAccountToken : {{ .Values.serviceAccount.automountServiceAccountToken }}
53       {{- if .Values.hostAlias.enabled }}
54       hostAliases:
55         - ip: {{ .Values.hostAlias.ip }}
56           hostnames:
57           - {{ .Values.hostAlias.hostname }}
58       {{- end }}
59       containers:
60       - name: {{ .Chart.Name }}
61         image: "{{ include "repositoryGenerator.quayRepository" . }}/{{ .Values.image.repository }}:v{{ include "oauth2-proxy.version" . }}"
62         #image: "{{ .Values.image.repository }}:v{{ include "oauth2-proxy.version" . }}"
63         imagePullPolicy: {{ .Values.image.pullPolicy }}
64         args:
65         {{- if .Values.alphaConfig.enabled }}
66           - --alpha-config=/etc/oauth2_proxy/oauth2_proxy.yml
67         {{- else }}
68           - --http-address=0.0.0.0:4180
69           - --https-address=0.0.0.0:4443
70         {{- if .Values.metrics.enabled }}
71           - --metrics-address=0.0.0.0:44180
72         {{- end }}
73         {{- end }}
74         {{- if .Values.config.cookieName }}
75           - --cookie-name={{ .Values.config.cookieName }}
76         {{- end }}
77         {{- if kindIs "map" .Values.extraArgs }}
78           {{- range $key, $value := .Values.extraArgs }}
79           {{- if $value }}
80           - --{{ $key }}={{ tpl ($value | toString) $ }}
81           {{- else }}
82           - --{{ $key }}
83           {{- end }}
84           {{- end }}
85         {{- end }}
86         {{- if kindIs "slice" .Values.extraArgs }}
87           {{- with .Values.extraArgs }}
88             {{- toYaml . | nindent 10 }}
89           {{- end }}
90         {{- end }}
91         {{- if or .Values.config.existingConfig .Values.config.configFile }}
92           - --config=/etc/oauth2_proxy/oauth2_proxy.cfg
93         {{- end }}
94         {{- if .Values.authenticatedEmailsFile.enabled }}
95         {{- if .Values.authenticatedEmailsFile.template }}
96           - --authenticated-emails-file=/etc/oauth2-proxy/{{ .Values.authenticatedEmailsFile.template }}
97         {{- else }}
98           - --authenticated-emails-file=/etc/oauth2-proxy/authenticated-emails-list
99         {{- end }}
100         {{- end }}
101         {{- with .Values.config.google }}
102         {{- if and .adminEmail (or .serviceAccountJson .existingSecret .useApplicationDefaultCredentials) }}
103           - --google-admin-email={{ .adminEmail }}
104         {{- if .useApplicationDefaultCredentials }}
105           - --google-use-application-default-credentials=true
106         {{- else }}
107           - --google-service-account-json=/google/service-account.json
108         {{- end }}
109         {{- if .targetPrincipal }}
110           - --google-target-principal={{ .targetPrincipal }}
111         {{- end }}
112         {{- end }}
113         {{- if .groups }}
114         {{- range $group := .groups }}
115           - --google-group={{ $group }}
116         {{- end }}
117         {{- end }}
118         {{- end }}
119         {{- if .Values.htpasswdFile.enabled }}
120           - --htpasswd-file=/etc/oauth2_proxy/htpasswd/users.txt
121         {{- end }}
122         env:
123         {{- if .Values.proxyVarsAsSecrets }}
124         - name: OAUTH2_PROXY_CLIENT_ID
125           valueFrom:
126             secretKeyRef:
127               name:  {{ template "oauth2-proxy.secretName" . }}
128               key: client-id
129         - name: OAUTH2_PROXY_CLIENT_SECRET
130           valueFrom:
131             secretKeyRef:
132               name:  {{ template "oauth2-proxy.secretName" . }}
133               key: client-secret
134         - name: OAUTH2_PROXY_COOKIE_SECRET
135           valueFrom:
136             secretKeyRef:
137               name:  {{ template "oauth2-proxy.secretName" . }}
138               key: cookie-secret
139         {{- end }}
140         {{- if eq (default "cookie" .Values.sessionStorage.type) "redis" }}
141         - name: OAUTH2_PROXY_SESSION_STORE_TYPE
142           value: "redis"
143          {{- if or .Values.sessionStorage.redis.existingSecret .Values.sessionStorage.redis.password (and .Values.redis.enabled (.Values.redis.auth).enabled )}}
144         - name: OAUTH2_PROXY_REDIS_PASSWORD
145           valueFrom:
146             secretKeyRef:
147               {{- if .Values.sessionStorage.redis.existingSecret }}
148               name: {{ .Values.sessionStorage.redis.existingSecret }}
149               {{- else if .Values.sessionStorage.redis.password }}
150               name: {{ template "oauth2-proxy.fullname" . }}-redis-access
151               {{- else }}
152               name: {{ include "oauth2-proxy.redis.fullname" . }}
153               {{- end }}
154               key: {{ .Values.sessionStorage.redis.passwordKey }}
155         {{- end }}
156         {{- if eq (default "" .Values.sessionStorage.redis.clientType) "standalone" }}
157         - name: OAUTH2_PROXY_REDIS_CONNECTION_URL
158           value: {{ include "oauth2-proxy.redis.StandaloneUrl" . }}
159         {{- else if eq (default "" .Values.sessionStorage.redis.clientType) "cluster" }}
160         - name: OAUTH2_PROXY_REDIS_USE_CLUSTER
161           value: "true"
162         - name: OAUTH2_PROXY_REDIS_CLUSTER_CONNECTION_URLS
163           value: {{ .Values.sessionStorage.redis.cluster.connectionUrls }}
164         {{- else if eq (default "" .Values.sessionStorage.redis.clientType) "sentinel" }}
165         - name: OAUTH2_PROXY_REDIS_USE_SENTINEL
166           value: "true"
167         - name: OAUTH2_PROXY_REDIS_SENTINEL_MASTER_NAME
168           value: {{ .Values.sessionStorage.redis.sentinel.masterName }}
169         - name: OAUTH2_PROXY_REDIS_SENTINEL_CONNECTION_URLS
170           value: {{ .Values.sessionStorage.redis.sentinel.connectionUrls }}
171         {{- if or .Values.sessionStorage.redis.sentinel.existingSecret .Values.sessionStorage.redis.existingSecret .Values.sessionStorage.redis.sentinel.password }}
172         - name: OAUTH2_PROXY_REDIS_SENTINEL_PASSWORD
173           valueFrom:
174             secretKeyRef:
175               {{- if or .Values.sessionStorage.redis.sentinel.existingSecret .Values.sessionStorage.redis.existingSecret }}
176               name: {{ .Values.sessionStorage.redis.sentinel.existingSecret | default .Values.sessionStorage.redis.existingSecret }}
177               {{- else }}
178               name: {{ template "oauth2-proxy.fullname" . }}-redis-access
179               {{- end }}
180               key: {{ .Values.sessionStorage.redis.sentinel.passwordKey }}
181         {{- end }}
182         {{- end }}
183         {{- end }}
184         {{- if .Values.extraEnv }}
185 {{ tpl (toYaml .Values.extraEnv) . | indent 8 }}
186         {{- end }}
187         ports:
188         {{- if .Values.containerPort }}
189           - containerPort: {{ .Values.containerPort }}
190         {{- else if (and (eq .Values.httpScheme "http") (empty .Values.containerPort)) }}
191           - containerPort: 4180
192         {{- else if (and (eq .Values.httpScheme "https") (empty .Values.containerPort)) }}
193           - containerPort: 4443
194         {{- else }}
195         {{- end}}
196             name: {{ .Values.httpScheme }}
197             protocol: TCP
198 {{- if .Values.metrics.enabled }}
199           - containerPort: 44180
200             protocol: TCP
201             name: metrics
202 {{- end }}
203 {{- if .Values.livenessProbe.enabled }}
204         livenessProbe:
205           httpGet:
206             path: /ping
207             port: {{ .Values.httpScheme }}
208             scheme: {{ .Values.httpScheme | upper }}
209           initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
210           timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
211 {{- end }}
212 {{- if .Values.readinessProbe.enabled }}
213         readinessProbe:
214           httpGet:
215             path: {{ if gt (include "oauth2-proxy.version" .) "7.4.0" }}/ready{{ else }}/ping{{ end }}
216             port: {{ .Values.httpScheme }}
217             scheme: {{ .Values.httpScheme | upper }}
218           initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
219           timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
220           successThreshold: {{ .Values.readinessProbe.successThreshold }}
221           periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
222 {{- end }}
223         resources:
224 {{ toYaml .Values.resources | indent 10 }}
225         volumeMounts:
226 {{- with .Values.config.google }}
227 {{- if and .adminEmail (or .serviceAccountJson .existingSecret) }}
228         - name: google-secret
229           mountPath: /google
230           readOnly: true
231 {{- end }}
232 {{- end }}
233 {{- if or .Values.config.existingConfig .Values.config.configFile }}
234         - mountPath: /etc/oauth2_proxy/oauth2_proxy.cfg
235           name: configmain
236           subPath: oauth2_proxy.cfg
237 {{- end }}
238 {{- if .Values.alphaConfig.enabled }}
239         - mountPath: /etc/oauth2_proxy/oauth2_proxy.yml
240           name: configalpha
241           subPath: oauth2_proxy.yml
242 {{- end }}
243 {{- if .Values.authenticatedEmailsFile.enabled }}
244         - mountPath: /etc/oauth2-proxy
245           name: configaccesslist
246           readOnly: true
247 {{- end }}
248 {{- if .Values.htpasswdFile.enabled }}
249         - mountPath: /etc/oauth2_proxy/htpasswd
250           name: {{ template "oauth2-proxy.fullname" . }}-htpasswd-file
251           readOnly: true
252 {{- end }}
253 {{- if ne (len .Values.extraVolumeMounts) 0 }}
254 {{ toYaml .Values.extraVolumeMounts | indent 8 }}
255 {{- end }}
256 {{- if .Values.securityContext.enabled }}
257 {{- $securityContext := unset .Values.securityContext "enabled" }}
258         securityContext:
259           {{- toYaml $securityContext | nindent 10 }}
260 {{- end }}
261 {{- if .Values.extraContainers }}
262   {{- toYaml .Values.extraContainers | nindent 6 }}
263 {{- end }}
264       volumes:
265 {{- with .Values.config.google }}
266 {{- if and .adminEmail (or .serviceAccountJson .existingSecret) }}
267       - name: google-secret
268         secret:
269           secretName: {{ if .existingSecret }}{{ .existingSecret }}{{ else }} {{ template "oauth2-proxy.secretName" $ }}-google{{ end }}
270 {{- end }}
271 {{- end }}
272
273 {{- if .Values.htpasswdFile.enabled }}
274       - name: {{ template "oauth2-proxy.fullname" . }}-htpasswd-file
275         secret:
276           secretName: {{ if .Values.htpasswdFile.existingSecret }}{{ .Values.htpasswdFile.existingSecret }}{{ else }} {{ template "oauth2-proxy.fullname" . }}-htpasswd-file {{ end }}
277 {{- end }}
278
279 {{- if and (.Values.authenticatedEmailsFile.enabled) (eq .Values.authenticatedEmailsFile.persistence "secret") }}
280       - name: configaccesslist
281         secret:
282           items:
283           - key: {{ default "restricted_user_access" .Values.authenticatedEmailsFile.restrictedUserAccessKey }}
284 {{- if .Values.authenticatedEmailsFile.template }}
285             path: {{ .Values.authenticatedEmailsFile.template }}
286 {{- else }}
287             path: authenticated-emails-list
288 {{- end }}
289 {{- if .Values.authenticatedEmailsFile.template }}
290           secretName: {{ .Values.authenticatedEmailsFile.template }}
291 {{- else }}
292           secretName: {{ template "oauth2-proxy.fullname" . }}-accesslist
293 {{- end }}
294 {{- end }}
295
296 {{- if or .Values.config.existingConfig .Values.config.configFile }}
297       - configMap:
298           defaultMode: 420
299           name: {{ if .Values.config.existingConfig }}{{ .Values.config.existingConfig }}{{ else }}{{ template "oauth2-proxy.fullname" . }}{{ end }}
300         name: configmain
301 {{- end }}
302 {{- if .Values.alphaConfig.enabled }}
303       - configMap:
304           defaultMode: 420
305           name: {{ if .Values.alphaConfig.existingConfig }}{{ .Values.alphaConfig.existingConfig }}{{ else }}{{ template "oauth2-proxy.fullname" . }}-alpha{{ end }}
306         name: configalpha
307 {{- end }}
308 {{- if ne (len .Values.extraVolumes) 0 }}
309 {{ toYaml .Values.extraVolumes | indent 6 }}
310 {{- end }}
311 {{- if and (.Values.authenticatedEmailsFile.enabled) (eq .Values.authenticatedEmailsFile.persistence "configmap") }}
312       - configMap:
313 {{- if .Values.authenticatedEmailsFile.template }}
314           name: {{ .Values.authenticatedEmailsFile.template }}
315 {{- else }}
316           name: {{ template "oauth2-proxy.fullname" . }}-accesslist
317 {{- end }}
318           items:
319           - key: {{ default "restricted_user_access" .Values.authenticatedEmailsFile.restrictedUserAccessKey }}
320 {{- if .Values.authenticatedEmailsFile.template }}
321             path: {{ .Values.authenticatedEmailsFile.template }}
322 {{- else }}
323             path: authenticated-emails-list
324 {{- end }}
325         name: configaccesslist
326 {{- end }}
327
328       {{- if .Values.imagePullSecrets }}
329       imagePullSecrets:
330 {{ toYaml .Values.imagePullSecrets | indent 8 }}
331       {{- end }}
332     {{- if .Values.affinity }}
333       affinity:
334 {{ toYaml .Values.affinity | indent 8 }}
335     {{- end }}
336     {{- if .Values.nodeSelector }}
337       nodeSelector:
338 {{ toYaml .Values.nodeSelector | indent 8 }}
339     {{- end }}
340       tolerations:
341 {{ toYaml .Values.tolerations | indent 8 }}
342       {{- with .Values.topologySpreadConstraints }}
343       topologySpreadConstraints:
344         {{- toYaml . | nindent 8 }}
345       {{- end }}