1 {{- if .Values.replicaSet.enabled }}
5 name: {{ template "mongodb.fullname" . }}-primary
6 namespace: {{.Values.namespace }}
8 app: {{ template "mongodb.name" . }}
9 chart: {{ template "mongodb.chart" . }}
10 heritage: {{ .Release.Service }}
11 release: {{ .Release.Name }}
12 {{- with .Values.labels }}
13 {{ toYaml . | indent 4 }}
15 {{- with .Values.annotations }}
17 {{ toYaml . | indent 4 }}
20 serviceName: {{ template "mongodb.fullname" . }}-headless
23 type: {{ .Values.updateStrategy.type }}
24 {{- if (eq "Recreate" .Values.updateStrategy.type) }}
29 app: {{ template "mongodb.name" . }}
30 release: {{ .Release.Name }}
35 app: {{ template "mongodb.name" . }}
36 chart: {{ template "mongodb.chart" . }}
37 release: {{ .Release.Name }}
39 {{- if .Values.podLabels }}
40 {{ toYaml .Values.podLabels | indent 8 }}
42 {{- if or .Values.podAnnotations .Values.metrics.enabled }}
44 {{- if .Values.podAnnotations }}
45 {{ toYaml .Values.podAnnotations | indent 8 }}
47 {{- if .Values.metrics.enabled }}
48 {{ toYaml .Values.metrics.podAnnotations | indent 8 }}
52 {{- if .Values.schedulerName }}
53 schedulerName: "{{ .Values.schedulerName }}"
55 {{- if .Values.priorityClassName }}
56 priorityClassName: {{ .Values.priorityClassName }}
58 {{- if .Values.securityContext.enabled }}
60 fsGroup: {{ .Values.securityContext.fsGroup }}
62 {{- if .Values.affinity }}
64 {{ toYaml .Values.affinity | indent 8 }}
66 {{- if .Values.nodeSelector }}
68 {{ toYaml .Values.nodeSelector | indent 8 }}
70 {{- if .Values.tolerations }}
72 {{ toYaml .Values.tolerations | indent 8 }}
74 {{- include "mongodb.imagePullSecrets" . | indent 6 }}
76 {{- if .Values.extraInitContainers }}
77 {{ tpl .Values.extraInitContainers . | indent 6}}
79 {{- if and .Values.volumePermissions.enabled .Values.persistence.enabled }}
80 - name: volume-permissions
81 image: {{ template "mongodb.volumePermissions.image" . }}
82 imagePullPolicy: {{ .Values.volumePermissions.image.pullPolicy | quote }}
83 command: ["chown", "-R", "{{ .Values.securityContext.runAsUser }}:{{ .Values.securityContext.fsGroup }}", "{{ .Values.persistence.mountPath }}"]
86 resources: {{ toYaml .Values.volumePermissions.resources | nindent 10 }}
89 mountPath: {{ .Values.persistence.mountPath }}
92 - name: {{ template "mongodb.name" . }}-primary
93 image: {{ template "mongodb.image" . }}
94 imagePullPolicy: {{ .Values.image.pullPolicy }}
95 {{- if .Values.securityContext.enabled }}
98 runAsUser: {{ .Values.securityContext.runAsUser }}
101 - containerPort: {{ .Values.service.port }}
104 {{- if .Values.image.debug}}
105 - name: BITNAMI_DEBUG
108 - name: MONGODB_SYSTEM_LOG_VERBOSITY
109 value: {{ .Values.mongodbSystemLogVerbosity | quote }}
110 - name: MONGODB_DISABLE_SYSTEM_LOG
111 {{- if .Values.mongodbDisableSystemLog }}
116 - name: MONGODB_POD_NAME
119 fieldPath: metadata.name
120 - name: MONGODB_REPLICA_SET_MODE
122 - name: MONGODB_REPLICA_SET_NAME
123 value: {{ .Values.replicaSet.name | quote }}
124 {{- if .Values.replicaSet.useHostnames }}
125 - name: MONGODB_ADVERTISED_HOSTNAME
126 value: "$(MONGODB_POD_NAME).{{ template "mongodb.fullname" . }}-headless.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}"
128 {{- if .Values.mongodbUsername }}
129 - name: MONGODB_USERNAME
130 value: {{ .Values.mongodbUsername | quote }}
132 {{- if .Values.mongodbDatabase }}
133 - name: MONGODB_DATABASE
134 value: {{ .Values.mongodbDatabase | quote }}
136 {{- if .Values.usePassword }}
137 {{- if and .Values.mongodbUsername .Values.mongodbDatabase }}
138 - name: MONGODB_PASSWORD
141 name: {{ if .Values.existingSecret }}{{ .Values.existingSecret }}{{- else }}{{ template "mongodb.fullname" . }}{{- end }}
142 key: mongodb-password
144 - name: MONGODB_ROOT_PASSWORD
147 name: {{ if .Values.existingSecret }}{{ .Values.existingSecret }}{{- else }}{{ template "mongodb.fullname" . }}{{- end }}
148 key: mongodb-root-password
149 - name: MONGODB_REPLICA_SET_KEY
152 name: {{ if .Values.existingSecret }}{{ .Values.existingSecret }}{{- else }}{{ template "mongodb.fullname" . }}{{- end }}
153 key: mongodb-replica-set-key
155 - name: MONGODB_ENABLE_IPV6
156 {{- if .Values.mongodbEnableIPv6 }}
161 - name: MONGODB_ENABLE_DIRECTORY_PER_DB
162 {{- if .Values.mongodbDirectoryPerDB }}
167 {{- if .Values.mongodbExtraFlags }}
168 - name: MONGODB_EXTRA_FLAGS
169 value: {{ .Values.mongodbExtraFlags | join " " | quote }}
171 {{- if .Values.extraEnvVars }}
172 {{- include "mongodb.tplValue" ( dict "value" .Values.extraEnvVars "context" $ ) | nindent 10 }}
174 {{- if .Values.livenessProbe.enabled }}
180 initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
181 periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
182 timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
183 successThreshold: {{ .Values.livenessProbe.successThreshold }}
184 failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
186 {{- if .Values.readinessProbe.enabled }}
192 - "db.adminCommand('ping')"
193 initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
194 periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
195 timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
196 successThreshold: {{ .Values.readinessProbe.successThreshold }}
197 failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
201 mountPath: {{ .Values.persistence.mountPath }}
202 subPath: {{ .Values.persistence.subPath }}
203 {{- if or (.Files.Glob "files/docker-entrypoint-initdb.d/*[sh|js|json]") (.Values.initConfigMap) }}
204 - name: custom-init-scripts
205 mountPath: /docker-entrypoint-initdb.d
207 {{- if .Values.configmap }}
209 mountPath: /opt/bitnami/mongodb/conf/mongodb.conf
210 subPath: mongodb.conf
212 {{- if .Values.extraVolumeMounts }}
213 {{ toYaml .Values.extraVolumeMounts | indent 12}}
216 {{ toYaml .Values.resources | indent 12 }}
217 {{- if .Values.metrics.enabled }}
219 image: {{ template "mongodb.metrics.image" . }}
220 imagePullPolicy: {{ .Values.metrics.image.pullPolicy | quote }}
221 {{- if .Values.securityContext.enabled }}
224 runAsUser: {{ .Values.securityContext.runAsUser }}
227 {{- if .Values.usePassword }}
228 - name: MONGODB_ROOT_PASSWORD
231 name: {{ if .Values.existingSecret }}{{ .Values.existingSecret }}{{- else }}{{ template "mongodb.fullname" . }}{{- end }}
232 key: mongodb-root-password
233 command: [ 'sh', '-c', '/bin/mongodb_exporter --mongodb.uri mongodb://root:${MONGODB_ROOT_PASSWORD}@localhost:{{ .Values.service.port }}/admin {{ .Values.metrics.extraArgs }}' ]
235 command: [ 'sh', '-c', '/bin/mongodb_exporter --mongodb.uri mongodb://localhost:{{ .Values.service.port }} {{ .Values.metrics.extraArgs }}' ]
240 {{- if .Values.metrics.livenessProbe.enabled }}
245 initialDelaySeconds: {{ .Values.metrics.livenessProbe.initialDelaySeconds }}
246 periodSeconds: {{ .Values.metrics.livenessProbe.periodSeconds }}
247 timeoutSeconds: {{ .Values.metrics.livenessProbe.timeoutSeconds }}
248 failureThreshold: {{ .Values.metrics.livenessProbe.failureThreshold }}
249 successThreshold: {{ .Values.metrics.livenessProbe.successThreshold }}
251 {{- if .Values.metrics.readinessProbe.enabled }}
256 initialDelaySeconds: {{ .Values.metrics.readinessProbe.initialDelaySeconds }}
257 periodSeconds: {{ .Values.metrics.readinessProbe.periodSeconds }}
258 timeoutSeconds: {{ .Values.metrics.readinessProbe.timeoutSeconds }}
259 failureThreshold: {{ .Values.metrics.readinessProbe.failureThreshold }}
260 successThreshold: {{ .Values.metrics.readinessProbe.successThreshold }}
263 {{ toYaml .Values.metrics.resources | indent 12 }}
265 {{- if .Values.sidecars }}
266 {{ toYaml .Values.sidecars | indent 8 }}
269 {{- if (.Files.Glob "files/docker-entrypoint-initdb.d/*[sh|js|json]") }}
270 - name: custom-init-scripts
272 name: {{ template "mongodb.fullname" . }}-init-scripts
274 {{- if (.Values.initConfigMap) }}
275 - name: custom-init-scripts
277 name: {{ .Values.initConfigMap.name }}
279 {{- if .Values.configmap }}
282 name: {{ template "mongodb.fullname" . }}
284 {{- if .Values.extraVolumes }}
285 {{ toYaml .Values.extraVolumes | indent 8}}
287 {{- if .Values.persistence.enabled }}
288 volumeClaimTemplates:
292 {{- range $key, $value := .Values.persistence.annotations }}
293 {{ $key }}: "{{ $value }}"
297 {{- range .Values.persistence.accessModes }}
302 storage: {{ .Values.persistence.size | quote }}
303 {{ include "mongodb.storageClass" . }}