blob: 817698beeda555fa76d5e6e706388c10c780b641 [file] [log] [blame]
Andreas Geisslercde4a782024-02-28 16:08:06 +01001{{- /*
2Copyright VMware, Inc.
3SPDX-License-Identifier: APACHE-2.0
4*/}}
5
6{{- if not (eq .Values.architecture "replicaset") }}
7apiVersion: {{ if .Values.useStatefulSet }}{{ include "common.capabilities.statefulset.apiVersion" . }}{{- else }}{{ include "common.capabilities.deployment.apiVersion" . }}{{- end }}
8kind: {{ if .Values.useStatefulSet }}StatefulSet{{- else }}Deployment{{- end }}
9metadata:
10 name: {{ include "mongodb.fullname" . }}
11 namespace: {{ include "mongodb.namespace" . | quote }}
12 {{- $labels := include "common.tplvalues.merge" ( dict "values" ( list .Values.labels .Values.commonLabels ) "context" . ) }}
13 labels: {{- include "common.labels.standard" ( dict "customLabels" $labels "context" $ ) | nindent 4 }}
14 app.kubernetes.io/component: mongodb
15 {{- if or .Values.annotations .Values.commonAnnotations }}
16 {{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.annotations .Values.commonAnnotations ) "context" . ) }}
17 annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
18 {{- end }}
19spec:
20 replicas: {{ gt (.Values.replicaCount | int) 1 | ternary 1 .Values.replicaCount }}
21 {{- if .Values.useStatefulSet }}
22 serviceName: {{ include "mongodb.service.nameOverride" . }}
23 {{- end }}
24 {{- if .Values.updateStrategy}}
25 {{- if .Values.useStatefulSet }}
26 updateStrategy:
27 {{- else }}
28 strategy:
29 {{- end }}
30 {{- toYaml .Values.updateStrategy | nindent 4 }}
31 {{- end}}
32 {{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.podLabels .Values.commonLabels ) "context" . ) }}
33 selector:
34 matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
35 app.kubernetes.io/component: mongodb
36 template:
37 metadata:
38 labels: {{- include "common.labels.standard" ( dict "customLabels" $podLabels "context" $ ) | nindent 8 }}
39 app.kubernetes.io/component: mongodb
40 {{- if or (include "mongodb.createConfigmap" .) .Values.podAnnotations }}
41 annotations:
42 {{- if (include "mongodb.createConfigmap" .) }}
43 checksum/configuration: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
44 {{- end }}
45 {{- if .Values.podAnnotations }}
46 {{- include "common.tplvalues.render" (dict "value" .Values.podAnnotations "context" $) | nindent 8 }}
47 {{- end }}
48 {{- end }}
49 spec:
50 {{- include "mongodb.imagePullSecrets" . | nindent 6 }}
51 automountServiceAccountToken: {{ .Values.automountServiceAccountToken }}
52 {{- if .Values.hostAliases }}
53 hostAliases: {{- include "common.tplvalues.render" (dict "value" .Values.hostAliases "context" $) | nindent 8 }}
54 {{- end }}
55 {{- if .Values.schedulerName }}
56 schedulerName: {{ .Values.schedulerName | quote }}
57 {{- end }}
58 serviceAccountName: {{ template "mongodb.serviceAccountName" . }}
59 {{- if .Values.affinity }}
60 affinity: {{- include "common.tplvalues.render" (dict "value" .Values.affinity "context" $) | nindent 8 }}
61 {{- else }}
62 affinity:
63 podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.podAffinityPreset "component" "mongodb" "customLabels" $podLabels "topologyKey" .Values.topologyKey "context" $) | nindent 10 }}
64 podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.podAntiAffinityPreset "component" "mongodb" "customLabels" $podLabels "topologyKey" .Values.topologyKey "context" $) | nindent 10 }}
65 nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.nodeAffinityPreset.type "key" .Values.nodeAffinityPreset.key "values" .Values.nodeAffinityPreset.values) | nindent 10 }}
66 {{- end }}
67 {{- if .Values.nodeSelector }}
68 nodeSelector: {{- include "common.tplvalues.render" (dict "value" .Values.nodeSelector "context" $) | nindent 8 }}
69 {{- end }}
70 {{- if .Values.tolerations }}
71 tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.tolerations "context" $) | nindent 8 }}
72 {{- end }}
73 {{- if .Values.priorityClassName }}
74 priorityClassName: {{ .Values.priorityClassName }}
75 {{- end }}
76 {{- if .Values.runtimeClassName }}
77 runtimeClassName: {{ .Values.runtimeClassName }}
78 {{- end }}
79 {{- if .Values.podSecurityContext.enabled }}
80 securityContext: {{- omit .Values.podSecurityContext "enabled" | toYaml | nindent 8 }}
81 {{- end }}
82 {{ if .Values.terminationGracePeriodSeconds }}
83 terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
84 {{- end }}
85 enableServiceLinks: {{ .Values.enableServiceLinks }}
86 {{- if or .Values.initContainers (and .Values.volumePermissions.enabled .Values.persistence.enabled) .Values.tls.enabled }}
87 initContainers:
88 {{- if .Values.initContainers }}
89 {{- include "common.tplvalues.render" (dict "value" .Values.initContainers "context" $) | nindent 8 }}
90 {{- end }}
91 {{- if and .Values.volumePermissions.enabled .Values.persistence.enabled }}
92 - name: volume-permissions
93 image: {{ include "mongodb.volumePermissions.image" . }}
94 imagePullPolicy: {{ .Values.volumePermissions.image.pullPolicy | quote }}
95 command:
96 - /bin/bash
97 args:
98 - -ec
99 - |
100 mkdir -p {{ printf "%s/%s" .Values.persistence.mountPath (default "" .Values.persistence.subPath) }}
101 chown {{ .Values.containerSecurityContext.runAsUser }}:{{ .Values.podSecurityContext.fsGroup }} {{ printf "%s/%s" .Values.persistence.mountPath (default "" .Values.persistence.subPath) }}
102 find {{ printf "%s/%s" .Values.persistence.mountPath (default "" .Values.persistence.subPath) }} -mindepth 1 -maxdepth 1 -not -name ".snapshot" -not -name "lost+found" | xargs -r chown -R {{ .Values.containerSecurityContext.runAsUser }}:{{ .Values.podSecurityContext.fsGroup }}
103 {{- if eq ( toString ( .Values.volumePermissions.securityContext.runAsUser )) "auto" }}
104 securityContext: {{- omit .Values.volumePermissions.securityContext "runAsUser" | toYaml | nindent 12 }}
105 {{- else }}
106 securityContext: {{- .Values.volumePermissions.securityContext | toYaml | nindent 12 }}
107 {{- end }}
108 {{- if .Values.volumePermissions.resources }}
109 resources: {{- toYaml .Values.volumePermissions.resources | nindent 12 }}
110 {{- else if ne .Values.volumePermissions.resourcesPreset "none" }}
111 resources: {{- include "common.resources.preset" (dict "type" .Values.volumePermissions.resourcesPreset) | nindent 12 }}
112 {{- end }}
113 volumeMounts:
114 - name: empty-dir
115 mountPath: /tmp
116 subPath: tmp-dir
117 - name: {{ .Values.persistence.name | default "datadir" }}
118 mountPath: {{ .Values.persistence.mountPath }}
119 {{- end }}
120 {{- if .Values.tls.enabled }}
121 - name: generate-tls-certs
122 image: {{ include "mongodb.tls.image" . }}
123 imagePullPolicy: {{ .Values.tls.image.pullPolicy | quote }}
124 env:
125 - name: MY_POD_NAMESPACE
126 valueFrom:
127 fieldRef:
128 fieldPath: metadata.namespace
129 - name: MY_POD_HOST_IP
130 valueFrom:
131 fieldRef:
132 fieldPath: status.hostIP
133 volumeMounts:
134 - name: empty-dir
135 mountPath: /tmp
136 subPath: tmp-dir
137 {{- if (include "mongodb.autoGenerateCerts" .) }}
138 - name: certs-volume
139 mountPath: /certs/CAs
140 {{- else }}
141 - name: mongodb-certs-0
142 mountPath: /certs-0
143 {{- end }}
144 - name: certs
145 mountPath: /certs
146 - name: common-scripts
147 mountPath: /bitnami/scripts
148 command:
149 - /bitnami/scripts/generate-certs.sh
150 args:
151 - -s {{ include "mongodb.service.nameOverride" . }}
152 {{- if .Values.externalAccess.service.loadBalancerIPs }}
153 - -i {{ join "," .Values.externalAccess.service.loadBalancerIPs }}
154 {{- end }}
155 {{- if .Values.tls.extraDnsNames }}
156 - -n {{ join "," .Values.tls.extraDnsNames }}
157 {{- end }}
158 {{- if .Values.tls.resources }}
159 resources: {{- toYaml .Values.tls.resources | nindent 12 }}
160 {{- else if ne .Values.tls.resourcesPreset "none" }}
161 resources: {{- include "common.resources.preset" (dict "type" .Values.tls.resourcesPreset) | nindent 12 }}
162 {{- end }}
163 {{- if .Values.tls.securityContext }}
164 securityContext: {{- toYaml .Values.tls.securityContext | nindent 12 }}
165 {{- end }}
166 {{- end }}
167 {{- end }}
168 containers:
169 - name: mongodb
170 image: {{ include "mongodb.image" . }}
171 imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
172 {{- if .Values.containerSecurityContext.enabled }}
173 securityContext: {{- omit .Values.containerSecurityContext "enabled" | toYaml | nindent 12 }}
174 {{- end }}
175 {{- if .Values.diagnosticMode.enabled }}
176 command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
177 {{- else if .Values.command }}
178 command: {{- include "common.tplvalues.render" (dict "value" .Values.command "context" $) | nindent 12 }}
179 {{- end }}
180 {{- if .Values.diagnosticMode.enabled }}
181 args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
182 {{- else if .Values.args }}
183 args: {{- include "common.tplvalues.render" (dict "value" .Values.args "context" $) | nindent 12 }}
184 {{- end }}
185 {{- if .Values.lifecycleHooks }}
186 lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.lifecycleHooks "context" $) | nindent 12 }}
187 {{- end }}
188 env:
189 - name: BITNAMI_DEBUG
190 value: {{ ternary "true" "false" (or .Values.image.debug .Values.diagnosticMode.enabled) | quote }}
191 {{- $customUsers := include "mongodb.customUsers" . -}}
192 {{- $customDatabases := include "mongodb.customDatabases" . -}}
193 {{- if not (empty $customUsers) }}
194 - name: MONGODB_EXTRA_USERNAMES
195 value: {{ $customUsers | quote }}
196 {{- end }}
197 {{- if not (empty $customDatabases) }}
198 - name: MONGODB_EXTRA_DATABASES
199 value: {{ $customDatabases | quote }}
200 {{- end }}
201 {{- if .Values.auth.enabled }}
202 {{- if and (not (empty $customUsers)) (not (empty $customDatabases)) }}
203 - name: MONGODB_EXTRA_PASSWORDS
204 valueFrom:
205 secretKeyRef:
206 name: {{ include "mongodb.secretName" . }}
207 key: mongodb-passwords
208 {{- end }}
209 - name: MONGODB_ROOT_USER
210 value: {{ .Values.auth.rootUser | quote }}
211 - name: MONGODB_ROOT_PASSWORD
212 valueFrom:
213 secretKeyRef:
214 name: {{ include "mongodb.secretName" . }}
215 key: mongodb-root-password
216 {{- end }}
217 {{- if and .Values.metrics.enabled (not (empty .Values.metrics.username)) }}
218 - name: MONGODB_METRICS_USERNAME
219 value: {{ .Values.metrics.username | quote }}
220 {{- if .Values.auth.enabled }}
221 - name: MONGODB_METRICS_PASSWORD
222 valueFrom:
223 secretKeyRef:
224 name: {{ include "mongodb.secretName" . }}
225 key: mongodb-metrics-password
226 {{- end }}
227 {{- end }}
228 - name: ALLOW_EMPTY_PASSWORD
229 value: {{ ternary "no" "yes" .Values.auth.enabled | quote }}
230 - name: MONGODB_SYSTEM_LOG_VERBOSITY
231 value: {{ .Values.systemLogVerbosity | quote }}
232 - name: MONGODB_DISABLE_SYSTEM_LOG
233 value: {{ ternary "yes" "no" .Values.disableSystemLog | quote }}
234 - name: MONGODB_DISABLE_JAVASCRIPT
235 value: {{ ternary "yes" "no" .Values.disableJavascript | quote }}
236 - name: MONGODB_ENABLE_JOURNAL
237 value: {{ ternary "yes" "no" .Values.enableJournal | quote }}
238 - name: MONGODB_PORT_NUMBER
239 value: {{ .Values.containerPorts.mongodb | quote }}
240 - name: MONGODB_ENABLE_IPV6
241 value: {{ ternary "yes" "no" .Values.enableIPv6 | quote }}
242 - name: MONGODB_ENABLE_DIRECTORY_PER_DB
243 value: {{ ternary "yes" "no" .Values.directoryPerDB | quote }}
244 {{- $extraFlags := .Values.extraFlags | join " " -}}
245 {{- if .Values.tls.enabled }}
246 {{- if .Values.tls.mTLS.enabled }}
247 {{- $extraFlags = printf "--tlsCAFile=/certs/mongodb-ca-cert %s" $extraFlags }}
248 {{- end }}
249 {{- $extraFlags = printf "--tlsMode=%s --tlsCertificateKeyFile=/certs/mongodb.pem %s" .Values.tls.mode $extraFlags }}
250 {{- end }}
251 {{- if ne $extraFlags "" }}
252 - name: MONGODB_EXTRA_FLAGS
253 value: {{ $extraFlags | quote }}
254 {{- end }}
255 {{- if .Values.tls.enabled }}
256 - name: MONGODB_CLIENT_EXTRA_FLAGS
257 value: --tls {{ if .Values.tls.mTLS.enabled }}--tlsCertificateKeyFile=/certs/mongodb.pem {{ end }}--tlsCAFile=/certs/mongodb-ca-cert
258 {{- end }}
259 {{- if .Values.extraEnvVars }}
260 {{- include "common.tplvalues.render" (dict "value" .Values.extraEnvVars "context" $) | nindent 12 }}
261 {{- end }}
262 {{- if or .Values.extraEnvVarsCM .Values.extraEnvVarsSecret }}
263 envFrom:
264 {{- if .Values.extraEnvVarsCM }}
265 - configMapRef:
266 name: {{ tpl .Values.extraEnvVarsCM . | quote }}
267 {{- end }}
268 {{- if .Values.extraEnvVarsSecret }}
269 - secretRef:
270 name: {{ tpl .Values.extraEnvVarsSecret . | quote }}
271 {{- end }}
272 {{- end }}
273 ports:
274 - name: mongodb
275 containerPort: {{ .Values.containerPorts.mongodb }}
276 {{- if not .Values.diagnosticMode.enabled }}
277 {{- if .Values.customLivenessProbe }}
278 livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customLivenessProbe "context" $) | nindent 12 }}
279 {{- else if .Values.livenessProbe.enabled }}
280 livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.livenessProbe "enabled") "context" $) | nindent 12 }}
281 exec:
282 command:
283 - /bitnami/scripts/ping-mongodb.sh
284 {{- end }}
285 {{- end }}
286 {{- if not .Values.diagnosticMode.enabled }}
287 {{- if .Values.customReadinessProbe }}
288 readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customReadinessProbe "context" $) | nindent 12 }}
289 {{- else if .Values.readinessProbe.enabled }}
290 readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.readinessProbe "enabled") "context" $) | nindent 12 }}
291 exec:
292 command:
293 - /bitnami/scripts/readiness-probe.sh
294 {{- end }}
295 {{- end }}
296 {{- if not .Values.diagnosticMode.enabled }}
297 {{- if .Values.customStartupProbe }}
298 startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customStartupProbe "context" $) | nindent 12 }}
299 {{- else if .Values.startupProbe.enabled }}
300 startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.startupProbe "enabled") "context" $) | nindent 12 }}
301 exec:
302 command:
303 - /bitnami/scripts/startup-probe.sh
304 {{- end }}
305 {{- end }}
306 {{- if .Values.resources }}
307 resources: {{- toYaml .Values.resources | nindent 12 }}
308 {{- else if ne .Values.resourcesPreset "none" }}
309 resources: {{- include "common.resources.preset" (dict "type" .Values.resourcesPreset) | nindent 12 }}
310 {{- end }}
311 volumeMounts:
312 - name: empty-dir
313 mountPath: /tmp
314 subPath: tmp-dir
315 - name: empty-dir
316 mountPath: /opt/bitnami/mongodb/conf
317 subPath: app-conf-dir
318 - name: empty-dir
319 mountPath: /opt/bitnami/mongodb/tmp
320 subPath: app-tmp-dir
321 - name: empty-dir
322 mountPath: /opt/bitnami/mongodb/logs
323 subPath: app-logs-dir
324 - name: {{ .Values.persistence.name | default "datadir" }}
325 mountPath: {{ .Values.persistence.mountPath }}
326 subPath: {{ .Values.persistence.subPath }}
327 - name: common-scripts
328 mountPath: /bitnami/scripts
329 {{- if or .Values.initdbScriptsConfigMap .Values.initdbScripts }}
330 - name: custom-init-scripts
331 mountPath: /docker-entrypoint-initdb.d
332 {{- end }}
333 {{- if or .Values.configuration .Values.existingConfigmap }}
334 - name: config
335 mountPath: /opt/bitnami/mongodb/conf/mongodb.conf
336 subPath: mongodb.conf
337 {{- end }}
338 {{- if .Values.tls.enabled }}
339 - name: certs
340 mountPath: /certs
341 {{- end }}
342 {{- if .Values.extraVolumeMounts }}
343 {{- include "common.tplvalues.render" (dict "value" .Values.extraVolumeMounts "context" $) | nindent 12 }}
344 {{- end }}
345 {{- if .Values.metrics.enabled }}
346 - name: metrics
347 image: {{ template "mongodb.metrics.image" . }}
348 imagePullPolicy: {{ .Values.metrics.image.pullPolicy | quote }}
349 {{- if .Values.containerSecurityContext.enabled }}
350 securityContext: {{- omit .Values.containerSecurityContext "enabled" | toYaml | nindent 12 }}
351 {{- end }}
352 {{- if .Values.diagnosticMode.enabled }}
353 command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
354 {{- else if .Values.metrics.command }}
355 command: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.command "context" $) | nindent 12 }}
356 {{- else }}
357 command:
358 - /bin/bash
359 - -ec
360 {{- end }}
361 {{- if .Values.diagnosticMode.enabled }}
362 args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
363 {{- else if .Values.metrics.args }}
364 args: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.args "context" $) | nindent 12 }}
365 {{- else }}
366 args:
367 - |
368 /bin/mongodb_exporter {{ include "mongodb.exporterArgs" $ }} --mongodb.direct-connect --mongodb.global-conn-pool --web.listen-address ":{{ .Values.metrics.containerPort }}" --mongodb.uri "{{ include "mongodb.mongodb_exporter.uri" . }}" {{ .Values.metrics.extraFlags }}
369 {{- end }}
370 env:
371 {{- if .Values.auth.enabled }}
372 {{- if not .Values.metrics.username }}
373 - name: MONGODB_ROOT_USER
374 value: {{ .Values.auth.rootUser | quote }}
375 - name: MONGODB_ROOT_PASSWORD
376 valueFrom:
377 secretKeyRef:
378 name: {{ include "mongodb.secretName" . }}
379 key: mongodb-root-password
380 {{- else }}
381 - name: MONGODB_METRICS_USERNAME
382 value: {{ .Values.metrics.username | quote }}
383 - name: MONGODB_METRICS_PASSWORD
384 valueFrom:
385 secretKeyRef:
386 name: {{ include "mongodb.secretName" . }}
387 key: mongodb-metrics-password
388 {{- end }}
389 {{- end }}
390 volumeMounts:
391 - name: empty-dir
392 mountPath: /tmp
393 subPath: tmp-dir
394 {{- if .Values.tls.enabled }}
395 - name: certs
396 mountPath: /certs
397 {{- end }}
398 {{- if .Values.metrics.extraVolumeMounts }}
399 {{- include "common.tplvalues.render" (dict "value" .Values.metrics.extraVolumeMounts "context" $) | nindent 12 }}
400 {{- end }}
401 ports:
402 - name: metrics
403 containerPort: {{ .Values.metrics.containerPort }}
404 {{- if not .Values.diagnosticMode.enabled }}
405 {{- if .Values.metrics.customLivenessProbe }}
406 livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.customLivenessProbe "context" $) | nindent 12 }}
407 {{- else if .Values.metrics.livenessProbe.enabled }}
408 livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.metrics.livenessProbe "enabled") "context" $) | nindent 12 }}
409 httpGet:
410 path: /
411 port: metrics
412 {{- end }}
413 {{- if .Values.metrics.customReadinessProbe }}
414 readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.customReadinessProbe "context" $) | nindent 12 }}
415 {{- else if .Values.metrics.readinessProbe.enabled }}
416 readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.metrics.readinessProbe "enabled") "context" $) | nindent 12 }}
417 httpGet:
418 path: /
419 port: metrics
420 {{- end }}
421 {{- if .Values.metrics.customStartupProbe }}
422 startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.customStartupProbe "context" $) | nindent 12 }}
423 {{- else if .Values.metrics.startupProbe.enabled }}
424 startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.metrics.startupProbe "enabled") "context" $) | nindent 12 }}
425 tcpSocket:
426 port: metrics
427 {{- end }}
428 {{- end }}
429 {{- if .Values.metrics.resources }}
430 resources: {{- toYaml .Values.metrics.resources | nindent 12 }}
431 {{- else if ne .Values.metrics.resourcesPreset "none" }}
432 resources: {{- include "common.resources.preset" (dict "type" .Values.metrics.resourcesPreset) | nindent 12 }}
433 {{- end }}
434 {{- end }}
435 {{- if .Values.sidecars }}
436 {{- include "common.tplvalues.render" (dict "value" .Values.sidecars "context" $) | nindent 8 }}
437 {{- end }}
438 volumes:
439 - name: empty-dir
Fiete Ostkampd2b2a3d2024-04-30 13:08:03 +0200440 emptyDir:
Andreas Geisslerdbabc4b2024-08-02 14:18:07 +0200441 sizeLimit: {{ .Values.standalone.emptyDir.sizeLimit }}
Andreas Geisslercde4a782024-02-28 16:08:06 +0100442 - name: common-scripts
443 configMap:
444 name: {{ printf "%s-common-scripts" (include "mongodb.fullname" .) }}
445 defaultMode: 0550
446 {{- if or .Values.initdbScriptsConfigMap .Values.initdbScripts }}
447 - name: custom-init-scripts
448 configMap:
449 name: {{ template "mongodb.initdbScriptsCM" . }}
450 {{- end }}
451 {{- if or .Values.configuration .Values.existingConfigmap }}
452 - name: config
453 configMap:
454 name: {{ include "mongodb.configmapName" . }}
455 {{- end }}
456 {{- if .Values.extraVolumes }}
457 {{- include "common.tplvalues.render" (dict "value" .Values.extraVolumes "context" $) | nindent 8 }}
458 {{- end }}
459 {{- if .Values.tls.enabled }}
460 - name: certs
Fiete Ostkampd2b2a3d2024-04-30 13:08:03 +0200461 emptyDir:
462 sizeLimit: 64Mi
Andreas Geisslercde4a782024-02-28 16:08:06 +0100463 {{- if (include "mongodb.autoGenerateCerts" .) }}
464 - name: certs-volume
465 secret:
466 secretName: {{ template "mongodb.tlsSecretName" . }}
467 items:
468 - key: mongodb-ca-cert
469 path: mongodb-ca-cert
470 mode: 0600
471 - key: mongodb-ca-key
472 path: mongodb-ca-key
473 mode: 0600
474 {{- else }}
475 - name: mongodb-certs-0
476 secret:
477 secretName: {{ include "common.tplvalues.render" ( dict "value" .Values.tls.standalone.existingSecret "context" $) }}
478 defaultMode: 256
479 {{- end }}
480 {{- end }}
481 {{- if not .Values.persistence.enabled }}
482 - name: {{ .Values.persistence.name | default "datadir" }}
483 {{- if .Values.persistence.medium }}
484 emptyDir:
485 medium: {{ .Values.persistence.medium | quote }}
Fiete Ostkampd2b2a3d2024-04-30 13:08:03 +0200486 sizeLimit: 64Mi
Andreas Geisslercde4a782024-02-28 16:08:06 +0100487 {{- else }}
Fiete Ostkampd2b2a3d2024-04-30 13:08:03 +0200488 emptyDir:
489 sizeLimit: 64Mi
Andreas Geisslercde4a782024-02-28 16:08:06 +0100490 {{- end }}
491 {{- else if .Values.persistence.existingClaim }}
492 - name: {{ .Values.persistence.name | default "datadir" }}
493 persistentVolumeClaim:
494 claimName: {{ printf "%s" (tpl .Values.persistence.existingClaim .) }}
495 {{- else if not .Values.useStatefulSet }}
496 - name: {{ .Values.persistence.name | default "datadir" }}
497 persistentVolumeClaim:
498 claimName: {{ template "mongodb.fullname" . }}
499 {{- else }}
500 {{- if .Values.persistentVolumeClaimRetentionPolicy.enabled }}
501 persistentVolumeClaimRetentionPolicy:
502 whenDeleted: {{ .Values.persistentVolumeClaimRetentionPolicy.whenDeleted }}
503 whenScaled: {{ .Values.persistentVolumeClaimRetentionPolicy.whenScaled }}
504 {{- end }}
505 volumeClaimTemplates:
506 - metadata:
507 name: {{ .Values.persistence.name | default "datadir" }}
508 {{- if .Values.persistence.annotations }}
509 annotations: {{- include "common.tplvalues.render" (dict "value" .Values.persistence.annotations "context" $) | nindent 10 }}
510 {{- end }}
511 spec:
512 accessModes:
513 {{- range .Values.persistence.accessModes }}
514 - {{ . | quote }}
515 {{- end }}
516 resources:
517 requests:
518 storage: {{ .Values.persistence.size | quote }}
519 {{- if .Values.persistence.volumeClaimTemplates.selector }}
520 selector: {{- include "common.tplvalues.render" (dict "value" .Values.persistence.volumeClaimTemplates.selector "context" $) | nindent 10 }}
521 {{- end }}
522 {{ include "common.storage.class" (dict "persistence" .Values.persistence "global" .Values.global) }}
523 {{- end }}
524{{- end }}