3 SPDX-License-Identifier: APACHE-2.0
6 {{- if .Values.backup.enabled }}
10 name: {{ include "mongodb.fullname" . }}-mongodump
11 namespace: {{ include "mongodb.namespace" . | quote }}
12 labels: {{- include "common.labels.standard" . | nindent 4 }}
13 app.kubernetes.io/component: mongodump
14 {{- if .Values.backup.cronjob.labels }}
15 {{- include "common.tplvalues.render" (dict "value" .Values.backup.cronjob.labels "context" $) | nindent 4 }}
17 {{- if .Values.commonLabels }}
18 {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
20 {{- if or .Values.backup.cronjob.annotations .Values.commonAnnotations }}
22 {{- if .Values.backup.cronjob.annotations }}
23 {{- include "common.tplvalues.render" ( dict "value" .Values.backup.cronjob.annotations "context" $) | nindent 4 }}
25 {{- if .Values.commonAnnotations }}
26 {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
30 schedule: {{ quote .Values.backup.cronjob.schedule }}
31 concurrencyPolicy: {{ .Values.backup.cronjob.concurrencyPolicy }}
32 failedJobsHistoryLimit: {{ .Values.backup.cronjob.failedJobsHistoryLimit }}
33 successfulJobsHistoryLimit: {{ .Values.backup.cronjob.successfulJobsHistoryLimit }}
34 {{- if .Values.backup.cronjob.startingDeadlineSeconds }}
35 startingDeadlineSeconds: {{ .Values.backup.cronjob.startingDeadlineSeconds }}
39 {{- if .Values.backup.cronjob.ttlSecondsAfterFinished }}
40 ttlSecondsAfterFinished: {{ .Values.backup.cronjob.ttlSecondsAfterFinished }}
44 labels: {{- include "common.labels.standard" . | nindent 12 }}
45 app.kubernetes.io/component: mongodump
46 {{- if .Values.backup.cronjob.labels }}
47 {{- include "common.tplvalues.render" (dict "value" .Values.backup.cronjob.labels "context" $) | nindent 12 }}
49 {{- if .Values.commonLabels }}
50 {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 12 }}
52 {{- if or .Values.backup.cronjob.annotations .Values.commonAnnotations }}
54 {{- if .Values.backup.cronjob.annotations }}
55 {{- include "common.tplvalues.render" ( dict "value" .Values.backup.cronjob.annotations "context" $) | nindent 12 }}
57 {{- if .Values.commonAnnotations }}
58 {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 12 }}
62 {{- include "mongodb.imagePullSecrets" . | nindent 10 }}
63 {{- if .Values.podSecurityContext.enabled }}
64 securityContext: {{- omit .Values.podSecurityContext "enabled" | toYaml | nindent 12 }}
66 enableServiceLinks: {{ .Values.enableServiceLinks }}
67 {{- if .Values.tls.enabled }}
69 - name: generate-tls-certs
70 image: {{ include "mongodb.tls.image" . }}
71 imagePullPolicy: {{ .Values.tls.image.pullPolicy | quote }}
73 - name: MY_POD_NAMESPACE
76 fieldPath: metadata.namespace
77 - name: MY_POD_HOST_IP
80 fieldPath: status.hostIP
85 {{- if (include "mongodb.autoGenerateCerts" .) }}
89 - name: mongodb-certs-0
94 - name: common-scripts
95 mountPath: /bitnami/scripts
97 - /bitnami/scripts/generate-certs.sh
99 - -s {{ include "mongodb.service.nameOverride" . }}
100 {{- if .Values.externalAccess.service.loadBalancerIPs }}
101 - -i {{ join "," .Values.externalAccess.service.loadBalancerIPs }}
103 {{- if .Values.tls.extraDnsNames }}
104 - -n {{ join "," .Values.tls.extraDnsNames }}
106 {{- if .Values.tls.resources }}
107 resources: {{- toYaml .Values.tls.resources | nindent 16 }}
108 {{- else if ne .Values.tls.resourcesPreset "none" }}
109 resources: {{- include "common.resources.preset" (dict "type" .Values.tls.resourcesPreset) | nindent 16 }}
113 - name: {{ include "mongodb.fullname" . }}-mongodump
114 image: {{ include "mongodb.image" . }}
115 imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
117 {{- if .Values.auth.enabled }}
118 - name: MONGODB_ROOT_USER
119 value: {{ .Values.auth.rootUser | quote }}
120 - name: MONGODB_ROOT_PASSWORD
123 name: {{ include "mongodb.secretName" . }}
124 key: mongodb-root-password
126 - name: MONGODB_SERVICE_NAME
127 value: {{ include "mongodb.service.nameOverride" . }}
128 - name: MONGODB_PORT_NUMBER
129 value: {{ .Values.containerPorts.mongodb | quote }}
130 - name: MONGODUMP_DIR
131 value: {{ .Values.backup.cronjob.storage.mountPath }}
132 {{- if .Values.tls.enabled }}
133 - name: MONGODB_CLIENT_EXTRA_FLAGS
134 value: --ssl --sslPEMKeyFile=/certs/mongodb.pem --sslCAFile=/certs/mongodb-ca-cert
136 {{- if .Values.backup.cronjob.command }}
137 command: {{- include "common.tplvalues.render" (dict "value" .Values.backup.cronjob.command "context" $) | nindent 14 }}
142 - "mongodump {{- if .Values.auth.enabled }} --username=${MONGODB_ROOT_USER} --password=${MONGODB_ROOT_PASSWORD} --authenticationDatabase=admin {{- end }} --host=${MONGODB_SERVICE_NAME} --port=${MONGODB_PORT_NUMBER} ${MONGODB_CLIENT_EXTRA_FLAGS} {{- if (eq $.Values.architecture "replicaset") }}--oplog{{- end }} --gzip --archive=${MONGODUMP_DIR}/mongodump-$(date '+%Y-%m-%d-%H-%M').gz"
148 {{- if .Values.tls.enabled }}
151 {{- if (include "mongodb.autoGenerateCerts" .) }}
153 mountPath: /certs/CAs
155 - name: mongodb-certs-0
160 mountPath: {{ .Values.backup.cronjob.storage.mountPath }}
161 subPath: {{ .Values.backup.cronjob.storage.subPath }}
162 {{- if .Values.backup.cronjob.containerSecurityContext.enabled }}
164 {{- include "common.tplvalues.render" ( dict "value" ( omit .Values.backup.cronjob.containerSecurityContext "enabled" ) "context" $) | nindent 14 }}
166 restartPolicy: {{ .Values.backup.cronjob.restartPolicy }}
170 - name: common-scripts
172 name: {{ printf "%s-common-scripts" (include "mongodb.fullname" .) }}
174 {{- if .Values.tls.enabled }}
177 {{- if (include "mongodb.autoGenerateCerts" .) }}
180 secretName: {{ template "mongodb.tlsSecretName" . }}
182 - key: mongodb-ca-cert
183 path: mongodb-ca-cert
185 - key: mongodb-ca-key
189 - name: mongodb-certs-0
191 secretName: {{ include "common.tplvalues.render" ( dict "value" .Values.tls.standalone.existingSecret "context" $) }}
195 {{- if .Values.backup.cronjob.storage.existingClaim }}
197 persistentVolumeClaim:
198 claimName: {{ printf "%s" (tpl .Values.backup.cronjob.storage.existingClaim .) }}
201 persistentVolumeClaim:
202 claimName: {{ include "mongodb.fullname" . }}-mongodump