-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy path_helpers.tpl
More file actions
210 lines (195 loc) · 7.12 KB
/
Copy path_helpers.tpl
File metadata and controls
210 lines (195 loc) · 7.12 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
{{- define "imagePullSecret" }}
{{- printf "{\"auths\":{\"%s\":{\"username\":\"%s\",\"password\":\"%s\"}}}" .Values.dockerRegistry.registry .Values.dockerRegistry.loginid .Values.dockerRegistry.password | b64enc }}
{{- end }}
{{- define "hashString" -}}
{{- printf "%s%s%s%s" .Values.license.licenseServer .Values.license.licenseDomain .Release.Namespace .Release.Name | sha256sum -}}
{{- end -}}
{{- define "plane.podScheduling" -}}
{{- with .nodeSelector }}
nodeSelector: {{ toYaml . | nindent 8 }}
{{- end }}
{{- with .tolerations }}
tolerations: {{ toYaml . | nindent 8 }}
{{- end }}
{{- with .affinity }}
affinity: {{ toYaml . | nindent 8 }}
{{- end }}
{{- end }}
{{/*
Pod-level securityContext. Rendered only when securityContext.enabled is true.
Mirrors the kustomize nonroot-security-context component (pod patch).
Place inside spec.template.spec — call with the root context, e.g.
{{- include "plane.podSecurityContext" . }}
*/}}
{{- define "plane.podSecurityContext" -}}
{{- if .Values.securityContext.enabled }}
securityContext: {{- toYaml .Values.securityContext.podSecurityContext | nindent 8 }}
{{- end }}
{{- end -}}
{{/*
Container-level securityContext. Rendered only when securityContext.enabled is true.
Mirrors the kustomize nonroot-security-context component (container patch).
Place inside a container/initContainer entry — call with the root context, e.g.
{{- include "plane.containerSecurityContext" . }}
*/}}
{{- define "plane.containerSecurityContext" -}}
{{- if .Values.securityContext.enabled }}
securityContext: {{- toYaml .Values.securityContext.containerSecurityContext | nindent 10 }}
{{- end }}
{{- end -}}
{{- define "plane.labelsAndAnnotations" -}}
{{- with .labels }}
labels: {{ toYaml . | nindent 4 }}
{{- end }}
{{- with .annotations }}
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
{{- end }}
{{/*
Returns "true" when the bundled MinIO should be deployed.
MinIO is deployed only when services.minio.local_setup is enabled AND the storage
provider is not GCS — GCS native mode never uses the bundled MinIO, so selecting it
must disable the MinIO StatefulSet, bucket job, ingress routes and certs regardless
of the local_setup flag's value.
*/}}
{{- define "plane.minioEnabled" -}}
{{- if and .Values.services.minio.local_setup (ne (.Values.env.storage_provider | default "S3" | upper) "GCS") -}}
true
{{- end -}}
{{- end -}}
{{/*
Returns "true" when at least one custom CA secret is configured, in either the
top-level `customCA` section or the legacy `airgapped` keys. This is decoupled
from `airgapped.enabled` so custom CA certs can be mounted in non-airgapped
deployments (e.g. an S3-compatible endpoint that uses a private CA).
*/}}
{{- define "plane.s3CAEnabled" -}}
{{- if or (gt (len .Values.customCA.s3Secrets) 0) (and .Values.customCA.s3SecretName .Values.customCA.s3SecretKey) (gt (len .Values.airgapped.s3Secrets) 0) (and .Values.airgapped.s3SecretName .Values.airgapped.s3SecretKey) -}}
true
{{- end -}}
{{- end -}}
{{/*
Resolve the effective list of CA secrets and render them as projected-volume sources.
Precedence: customCA.s3Secrets > customCA single secret > airgapped.s3Secrets > airgapped single secret.
Single-secret (legacy) configs are normalized into the same { name, key } shape.
Output starts at column 0; caller controls indentation (e.g. nindent).
*/}}
{{- define "plane.s3CAProjectedSources" -}}
{{- $secrets := list -}}
{{- if gt (len .Values.customCA.s3Secrets) 0 -}}
{{- $secrets = .Values.customCA.s3Secrets -}}
{{- else if and .Values.customCA.s3SecretName .Values.customCA.s3SecretKey -}}
{{- $secrets = list (dict "name" .Values.customCA.s3SecretName "key" .Values.customCA.s3SecretKey) -}}
{{- else if gt (len .Values.airgapped.s3Secrets) 0 -}}
{{- $secrets = .Values.airgapped.s3Secrets -}}
{{- else if and .Values.airgapped.s3SecretName .Values.airgapped.s3SecretKey -}}
{{- $secrets = list (dict "name" .Values.airgapped.s3SecretName "key" .Values.airgapped.s3SecretKey) -}}
{{- end -}}
{{- range $secrets }}
- secret:
name: {{ .name }}
items:
- key: {{ .key }}
path: {{ .key }}
{{- end }}
{{- end -}}
{{/*
Render the volumes block for custom S3 CA certificates.
Always uses a projected volume so both single-secret (legacy) and multi-secret configs
produce the same volume structure.
Caller must nindent to the correct depth.
*/}}
{{- define "plane.s3CAVolumes" -}}
{{- if include "plane.s3CAEnabled" . -}}
volumes:
- name: s3-custom-ca
projected:
sources:
{{- include "plane.s3CAProjectedSources" . | trim | nindent 8 }}
{{- end }}
{{- end -}}
{{/*
Render the volumeMounts block for custom S3 CA certificates.
Caller must nindent to the correct depth.
*/}}
{{- define "plane.s3CAVolumeMounts" -}}
{{- if include "plane.s3CAEnabled" . -}}
volumeMounts:
- name: s3-custom-ca
mountPath: /s3-custom-ca
readOnly: true
{{- end }}
{{- end -}}
{{/*
Render the shell init script that installs custom CA certificates.
Output is raw shell; caller embeds it inside the command block.
*/}}
{{- define "plane.s3CAInitScript" -}}
{{- if include "plane.s3CAEnabled" . -}}
echo "Installing custom CA certificates..."
mkdir -p /usr/local/share/ca-certificates
if [ "$(ls -A /s3-custom-ca)" ]; then
echo "Found certificates in /s3-custom-ca. Installing..."
cp /s3-custom-ca/* /usr/local/share/ca-certificates/
update-ca-certificates
echo "CA certificates installed successfully"
else
echo "No custom S3 CA certificate found, skipping..."
fi
{{- end }}
{{- end -}}
{{/*
Render the SSL/TLS env vars needed when custom CA certs are installed.
Caller must nindent to the correct depth.
*/}}
{{- define "plane.s3CAEnvVars" -}}
{{- if include "plane.s3CAEnabled" . -}}
- name: SSL_CERT_FILE
value: "/etc/ssl/certs/ca-certificates.crt"
- name: SSL_CERT_DIR
value: "/etc/ssl/certs"
- name: REQUESTS_CA_BUNDLE
value: "/etc/ssl/certs/ca-certificates.crt"
- name: CURL_CA_BUNDLE
value: "/etc/ssl/certs/ca-certificates.crt"
{{- end }}
{{- end -}}
{{/*
Render the volumes block for Node.js services that use the init container CA pattern.
Includes both the projected CA secret volume and a shared emptyDir for the bundled output.
Caller must nindent to the correct depth.
*/}}
{{- define "plane.s3CANodeVolumes" -}}
{{- if include "plane.s3CAEnabled" . -}}
volumes:
- name: s3-custom-ca
projected:
sources:
{{- include "plane.s3CAProjectedSources" . | trim | nindent 8 }}
- name: ca-bundle
emptyDir: {}
{{- end }}
{{- end -}}
{{/*
Render the volumeMount for the shared CA bundle emptyDir on the main container.
Caller must nindent to the correct depth.
*/}}
{{- define "plane.s3CANodeBundleMount" -}}
{{- if include "plane.s3CAEnabled" . -}}
volumeMounts:
- name: ca-bundle
mountPath: /ca-bundle
readOnly: true
{{- end }}
{{- end -}}
{{/*
Render env vars for Node.js containers when custom CA certs are installed.
NODE_EXTRA_CA_CERTS tells Node.js to trust additional CAs on top of its built-in bundle.
Caller must nindent to the correct depth.
*/}}
{{- define "plane.s3CANodeEnvVars" -}}
{{- if include "plane.s3CAEnabled" . -}}
- name: NODE_EXTRA_CA_CERTS
value: "/ca-bundle/custom-ca-bundle.crt"
{{- end }}
{{- end -}}