-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path_pods.tpl
73 lines (68 loc) · 3.27 KB
/
_pods.tpl
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
{{- /*
Copyright 2024 New Vector Ltd
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
*/ -}}
{{- define "element-io.ess-library.pods.commonSpec" -}}
{{- $root := .root -}}
{{- with required "element-io.ess-library.pods.commonSpec missing context" .context -}}
{{- $key := required "element-io.ess-library.pods.commonSpec missing context.key" .key -}}
{{- $usesMatrixTools := .usesMatrixTools | default false -}}
{{- $deployment := required "element-io.ess-library.pods.commonSpec missing context.deployment" .deployment -}}
{{- with required "element-io.ess-library.pods.commonSpec missing context.componentValues" .componentValues -}}
automountServiceAccountToken: false
serviceAccountName: {{ include "element-io.ess-library.serviceAccountName" (dict "root" $root "context" (dict "serviceAccount" .serviceAccount "key" $key)) }}
{{- include "element-io.ess-library.pods.pullSecrets" (dict "root" $root "context" (dict "pullSecrets" .image.pullSecrets "usesMatrixTools" $usesMatrixTools)) }}
{{- with .podSecurityContext }}
securityContext:
{{- toYaml . | nindent 2 }}
{{- end }}
{{- with .nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 2 }}
{{- end }}
{{- include "element-io.ess-library.pods.tolerations" (dict "root" $root "context" .tolerations) }}
{{- include "element-io.ess-library.pods.topologySpreadConstraints" (dict "root" $root "context" (dict "instanceSuffix" $key "deployment" $deployment "topologySpreadConstraints" .topologySpreadConstraints)) }}
{{- end }}
{{- end }}
{{- end }}
{{- define "element-io.ess-library.pods.pullSecrets" -}}
{{- $root := .root -}}
{{- with required "element-io.ess-library.pods.pullSecrets missing context" .context -}}
{{- $pullSecrets := list }}
{{- $pullSecrets = concat .pullSecrets $root.Values.imagePullSecrets }}
{{- if .usesMatrixTools -}}
{{- $pullSecrets = concat $pullSecrets $root.Values.matrixTools.image.pullSecrets }}
{{- end }}
{{- with ($pullSecrets | uniq) }}
imagePullSecrets:
{{ tpl (toYaml .) $root }}
{{- end }}
{{- end }}
{{- end }}
{{- define "element-io.ess-library.pods.tolerations" -}}
{{- $root := .root -}}
{{- if not (hasKey . "context") -}}
{{- fail "element-io.ess-library.pods.tolerations missing context" -}}
{{- end }}
{{- $tolerations := concat .context $root.Values.tolerations }}
{{- with ($tolerations | uniq) }}
tolerations:
{{ toYaml . }}
{{- end }}
{{- end }}
{{- define "element-io.ess-library.pods.topologySpreadConstraints" -}}
{{- $root := .root -}}
{{- with required "element-io.ess-library.pods.topologySpreadConstraints missing context" .context -}}
{{- $labelSelector := (dict "matchLabels" (dict "app.kubernetes.io/instance" (printf "%s-%s" $root.Release.Name .instanceSuffix))) }}
{{- $matchLabelKeys := .deployment | ternary (list "pod-template-hash") list }}
{{- $defaultConstraintSettings := dict "labelSelector" $labelSelector "matchLabelKeys" $matchLabelKeys "whenUnsatisfiable" "DoNotSchedule" }}
{{- $topologySpreadConstraints := list -}}
{{- range $constraint := coalesce .topologySpreadConstraints $root.Values.topologySpreadConstraints -}}
{{- $topologySpreadConstraints = append $topologySpreadConstraints (mergeOverwrite (deepCopy $defaultConstraintSettings) $constraint) -}}
{{- end }}
{{- with $topologySpreadConstraints }}
topologySpreadConstraints:
{{ toYaml . }}
{{- end }}
{{- end }}
{{- end }}