Repository navigation
Expand file tree
/
Copy pathdeployment.yaml
More file actions
434 lines (434 loc) · 16.6 KB
/
Copy pathdeployment.yaml
File metadata and controls
434 lines (434 loc) · 16.6 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
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
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "fullname" . }}
labels:
{{- include "athens.metaLabels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
{{- with .Values.strategy }}
strategy:
{{- if eq .type "Recreate" }}
type: Recreate
{{- else }}
{{ toYaml . | nindent 4 }}
{{- end }}
{{- end }}
selector:
matchLabels:
app: {{ include "fullname" . }}
release: "{{ .Release.Name }}"
template:
metadata:
labels:
{{- include "athens.metaLabels" . | nindent 8 }}
annotations:
checksum/upstream: {{ include (print $.Template.BasePath "/config-upstream.yaml") . | sha256sum }}
checksum/ssh-config: {{ include (print $.Template.BasePath "/config-ssh-git-servers.yaml") . | sha256sum }}
checksum/ssh-secret: {{ include (print $.Template.BasePath "/secret-ssh-git-servers.yaml") . | sha256sum }}
{{- if .Values.annotations }}
{{- toYaml .Values.annotations | nindent 8 }}
{{- end }}
spec:
{{- if .Values.priorityClassName }}
priorityClassName: {{ .Values.priorityClassName | quote }}
{{- end }}
{{- if .Values.terminationGracePeriodSeconds }}
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
{{- end }}
{{- if .Values.image.runAsNonRoot }}
securityContext:
runAsUser: 1000
runAsGroup: 1000
{{- end }}
serviceAccountName: {{ include "serviceAccountName" . | quote }}
{{- with .Values.hostAliases }}
hostAliases:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.image.pullSecrets }}
imagePullSecrets:
{{- toYaml .Values.image.pullSecrets | nindent 8 }}
{{- end }}
{{- if or .Values.sshGitServers .Values.extraInitContainers }}
initContainers:
{{- if .Values.sshGitServers }}
- name: copy-key-files
image: "{{ .Values.initContainerImage.registry }}/{{ .Values.initContainerImage.repository }}:{{ .Values.initContainerImage.tag }}"
command:
- sh
- -c
args: ["cp {{ include "home" . }}/.ssh/id_rsa* /ssh-keys && chmod 400 /ssh-keys/*"]
volumeMounts:
- name: ssh-keys
mountPath: /ssh-keys
{{- $dot := . -}}
{{- range $server := .Values.sshGitServers }}
{{- if $server.existingSecret }}
- name: ssh-git-servers-secret-{{ $server.host | replace "." "-" }}
mountPath: "{{ include "home" $dot }}/.ssh/id_rsa-{{ $server.host }}"
subPath: {{ $server.existingSecret.subPath | quote }}
{{- else }}
- name: ssh-git-servers-secret
mountPath: {{ include "home" $dot }}/.ssh/id_rsa-{{ $server.host }}
subPath: id_rsa-{{ $server.host }}
{{- end }}
{{- end }}
{{- with .Values.initContainerSecurityContext }}
securityContext:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with (default .Values.intiContainerResources .Values.initContainerResources) }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- if .Values.extraInitContainers }}
{{- toYaml .Values.extraInitContainers | nindent 6 }}
{{- end }}
{{- end }}
containers:
- name: {{ include "fullname" . }}
image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
livenessProbe:
failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
httpGet:
path: "/healthz"
port: 3000
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
successThreshold: {{ .Values.livenessProbe.successThreshold }}
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
readinessProbe:
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
httpGet:
path: "/readyz"
port: 3000
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
successThreshold: {{ .Values.readinessProbe.successThreshold }}
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
env:
- name: ATHENS_GOGET_WORKERS
value: {{ .Values.goGetWorkers | quote }}
- name: ATHENS_STORAGE_TYPE
value: {{ .Values.storage.type | quote }}
{{- if eq .Values.storage.type "disk"}}
- name: ATHENS_DISK_STORAGE_ROOT
value: {{ .Values.storage.disk.storageRoot | quote }}
{{- else if eq .Values.storage.type "mongo"}}
- name: ATHENS_MONGO_STORAGE_URL
valueFrom:
secretKeyRef:
name: {{ include "fullname" . }}-secret
key: ATHENS_MONGO_STORAGE_URL
{{- else if eq .Values.storage.type "s3" }}
- name: AWS_REGION
value: {{ .Values.storage.s3.region | quote }}
- name: ATHENS_S3_BUCKET_NAME
value: {{ .Values.storage.s3.bucket | quote }}
- name: AWS_USE_DEFAULT_CONFIGURATION
value: {{ .Values.storage.s3.useDefaultConfiguration | quote }}
- name: AWS_FORCE_PATH_STYLE
value: {{ .Values.storage.s3.forcePathStyle | quote }}
{{- if .Values.storage.s3.accessKey }}
- name: AWS_ACCESS_KEY_ID
valueFrom:
secretKeyRef:
name: {{ include "fullname" . }}-secret
key: AWS_ACCESS_KEY_ID
{{- end }}
{{- if .Values.storage.s3.secretKey }}
- name: AWS_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
name: {{ include "fullname" . }}-secret
key: AWS_SECRET_ACCESS_KEY
{{- end }}
{{- if .Values.storage.s3.sessionToken }}
- name: AWS_SESSION_TOKEN
valueFrom:
secretKeyRef:
name: {{ include "fullname" . }}-secret
key: AWS_SESSION_TOKEN
{{- end }}
{{- else if eq .Values.storage.type "gcp"}}
- name: GOOGLE_CLOUD_PROJECT
value: {{ .Values.storage.gcp.projectID | quote }}
- name: ATHENS_STORAGE_GCP_BUCKET
value: {{ .Values.storage.gcp.bucket | quote }}
{{- if .Values.storage.gcp.serviceAccount }}
- name: ATHENS_STORAGE_GCP_JSON_KEY
valueFrom:
secretKeyRef:
name: {{ include "fullname" . }}-secret
key: ATHENS_STORAGE_GCP_JSON_KEY
{{- end }}
{{- else if eq .Values.storage.type "minio" }}
{{- if .Values.storage.minio.endpoint }}
- name: ATHENS_MINIO_ENDPOINT
value: {{ .Values.storage.minio.endpoint | quote }}
{{- end }}
{{- if .Values.storage.minio.accessKey }}
- name: ATHENS_MINIO_ACCESS_KEY_ID
valueFrom:
secretKeyRef:
name: {{ include "fullname" . }}-secret
key: ATHENS_MINIO_ACCESS_KEY_ID
{{- end }}
{{- if .Values.storage.minio.secretKey }}
- name: ATHENS_MINIO_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
name: {{ include "fullname" . }}-secret
key: ATHENS_MINIO_SECRET_ACCESS_KEY
{{- end }}
{{- if .Values.storage.minio.bucket }}
- name: ATHENS_MINIO_BUCKET_NAME
value: {{ .Values.storage.minio.bucket | quote }}
{{- end }}
{{- end }}
{{- if .Values.singleFlight.type }}
- name: ATHENS_SINGLE_FLIGHT_TYPE
value: {{ .Values.singleFlight.type | quote }}
{{- end }}
{{- if eq .Values.singleFlight.type "etcd"}}
{{- if .Values.singleFlight.etcd.endpoints }}
- name: ATHENS_ETCD_ENDPOINTS
value: {{ .Values.singleFlight.etcd.endpoints | quote }}
{{- end }}
{{- else if eq .Values.singleFlight.type "redis"}}
{{- if .Values.singleFlight.redis.endpoint }}
- name: ATHENS_REDIS_ENDPOINT
value: {{ .Values.singleFlight.redis.endpoint | quote }}
{{- end }}
{{- if .Values.singleFlight.redis.existingSecret }}
- name: ATHENS_REDIS_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.singleFlight.redis.existingSecret | quote }}
key: {{ .Values.singleFlight.redis.existingSecretKey | quote }}
{{- else if .Values.singleFlight.redis.password }}
- name: ATHENS_REDIS_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "fullname" . }}-secret
key: ATHENS_SINGLE_FLIGHT_REDIS_PASSWORD
{{- end }}
{{- with .Values.singleFlight.redis.lockConfig }}
{{- if .ttl }}
- name: ATHENS_REDIS_LOCK_TTL
value: {{ .ttl | quote }}
{{- end }}
{{- if .timeout }}
- name: ATHENS_REDIS_LOCK_TIMEOUT
value: {{ .timeout | quote }}
{{- end }}
{{- if .maxRetries }}
- name: ATHENS_REDIS_LOCK_MAX_RETRIES
value: {{ .maxRetries | quote }}
{{- end }}
{{- end }}
{{- else if eq .Values.singleFlight.type "redis-sentinel"}}
{{- if .Values.singleFlight.redisSentinel.endpoints }}
- name: ATHENS_REDIS_SENTINEL_ENDPOINTS
value: {{ .Values.singleFlight.redisSentinel.endpoints | quote }}
{{- end }}
{{- if .Values.singleFlight.redisSentinel.masterName }}
- name: ATHENS_REDIS_SENTINEL_MASTER_NAME
value: {{ .Values.singleFlight.redisSentinel.masterName | quote }}
{{- end }}
{{- if .Values.singleFlight.redisSentinel.existingSecret }}
- name: ATHENS_REDIS_SENTINEL_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.singleFlight.redisSentinel.existingSecret | quote }}
key: {{ .Values.singleFlight.redisSentinel.existingSecretKey | quote }}
{{- else if .Values.singleFlight.redisSentinel.sentinelPassword }}
- name: ATHENS_REDIS_SENTINEL_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "fullname" . }}-secret
key: ATHENS_SINGLE_FLIGHT_REDIS_SENTINEL_SENTINEL_PASSWORD
{{- end }}
{{- if .Values.singleFlight.redisSentinel.redisUsername }}
- name: ATHENS_REDIS_USERNAME
value: {{ .Values.singleFlight.redisSentinel.redisUsername | quote }}
{{- end }}
{{- if .Values.singleFlight.redisSentinel.redisPassword }}
- name: ATHENS_REDIS_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "fullname" . }}-secret
key: ATHENS_SINGLE_FLIGHT_REDIS_SENTINEL_REDIS_PASSWORD
{{- end }}
{{- with .Values.singleFlight.redisSentinel.lockConfig }}
{{- if .ttl }}
- name: ATHENS_REDIS_LOCK_TTL
value: {{ .ttl | quote }}
{{- end }}
{{- if .timeout }}
- name: ATHENS_REDIS_LOCK_TIMEOUT
value: {{ .timeout | quote }}
{{- end }}
{{- if .maxRetries }}
- name: ATHENS_REDIS_LOCK_MAX_RETRIES
value: {{ .maxRetries | quote }}
{{- end }}
{{- end }}
{{- end }}
{{- if .Values.netrc.enabled }}
- name: ATHENS_NETRC_PATH
value: "/etc/netrc/.netrc"
{{- end }}
{{- if .Values.upstreamProxy.enabled }}
- name: ATHENS_FILTER_FILE
value: "/usr/local/lib/FilterForUpstreamProxy"
- name: ATHENS_GLOBAL_ENDPOINT
value: {{ .Values.upstreamProxy.url | quote }}
{{- end }}
{{- if .Values.jaeger.enabled }}
- name: ATHENS_TRACE_EXPORTER_URL
value: {{ .Values.jaeger.url | default (print "http://" (include "fullname" .) "-jaeger:14268" ) | quote }}
- name: ATHENS_TRACE_EXPORTER
value: "jaeger"
{{- end }}
{{- if and .Values.tracing.enabled (not .Values.jaeger.enabled) }}
- name: ATHENS_TRACE_EXPORTER_URL
value: {{ .Values.tracing.url }}
- name: ATHENS_TRACE_EXPORTER
value: {{ .Values.tracing.type }}
{{- end }}
{{- if .Values.basicAuth.enabled }}
- name: BASIC_AUTH_USER
valueFrom:
secretKeyRef:
name: {{ default "athens-proxy-basic-auth" .Values.basicAuth.secretName | quote }}
key: {{ default "username" .Values.basicAuth.usernameSecretKey | quote }}
- name: BASIC_AUTH_PASS
valueFrom:
secretKeyRef:
name: {{ default "athens-proxy-basic-auth" .Values.basicAuth.secretName | quote }}
key: {{ default "password" .Values.basicAuth.passwordSecretKey | quote }}
{{- end }}
{{- if .Values.configEnvVars }}
{{- toYaml .Values.configEnvVars | nindent 8 }}
{{- end }}
ports:
- containerPort: 3000
{{- if or (eq .Values.storage.type "disk") .Values.upstreamProxy.enabled .Values.netrc.enabled .Values.sshGitServers .Values.gitconfig.enabled .Values.extraVolumeMounts }}
volumeMounts:
{{- end }}
{{- if eq .Values.storage.type "disk" }}
- name: storage-volume
mountPath: {{ .Values.storage.disk.storageRoot | quote }}
{{- end }}
{{- if .Values.upstreamProxy.enabled }}
- name: upstream-config
mountPath: "/usr/local/lib"
readOnly: true
{{- end }}
{{- if .Values.netrc.enabled }}
- name: netrc
mountPath: "/etc/netrc"
readOnly: true
{{- end }}
{{- if .Values.sshGitServers }}
- name: ssh-git-servers-config
mountPath: {{ include "home" . }}/.ssh/config
subPath: ssh_config
- name: ssh-git-servers-config
mountPath: {{ include "home" . }}/.gitconfig
subPath: git_config
- name: ssh-keys
mountPath: /ssh-keys
{{- end }}
{{- if .Values.gitconfig.enabled }}
- name: gitconfig
mountPath: "/etc/gitconfig"
subPath: "gitconfig"
{{- end }}
{{- range $server := .Values.sshGitServers }}
{{- if $server.existingSecret }}
- name: ssh-git-servers-secret-{{ $server.host | replace "." "-" }}
mountPath: {{ include "home" $ }}/.ssh/id_rsa-{{ $server.host }}
subPath: {{ $server.existingSecret.subPath | quote }}
{{- end }}
{{- end }}
{{- with .Values.extraVolumeMounts }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.securityContext }}
securityContext:
{{- toYaml . | nindent 10 }}
{{- end }}
{{- with .Values.lifecycle }}
lifecycle:
{{- toYaml . | nindent 10 }}
{{- end }}
{{- with .Values.resources }}
resources:
{{- toYaml . | nindent 10 }}
{{- end }}
{{- with .Values.extraContainers }}
{{- toYaml . | nindent 6 }}
{{- end }}
volumes:
- name: storage-volume
{{- if .Values.storage.disk.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ include "fullname" . }}-storage
{{- else }}
emptyDir: {}
{{- end }}
{{- if .Values.upstreamProxy.enabled }}
- name: upstream-config
configMap:
name: {{ include "fullname" . }}-upstream
{{- end }}
{{- if .Values.netrc.enabled }}
- name: netrc
secret:
secretName: {{ .Values.netrc.existingSecret }}
{{- end }}
{{- if .Values.sshGitServers }}
- name: ssh-keys
emptyDir: {}
- name: ssh-git-servers-config
configMap:
name: {{ include "fullname" . }}-ssh-git-servers
- name: ssh-git-servers-secret
secret:
secretName: {{ include "fullname" . }}-ssh-git-servers
{{- range $server := .Values.sshGitServers }}
{{- if $server.existingSecret }}
- name: ssh-git-servers-secret-{{ $server.host | replace "." "-" }}
secret:
secretName: {{ $server.existingSecret.name | quote }}
{{- end }}
{{- end }}
{{- end }}
{{- if .Values.gitconfig.enabled }}
- name: gitconfig
secret:
secretName: {{ .Values.gitconfig.secretName }}
items:
- key: {{ .Values.gitconfig.secretKey }}
path: "gitconfig"
{{- end }}
{{- with .Values.extraVolumes }}
{{- toYaml . | nindent 6 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}