updating helm/docker files and database config files
[it/otf.git] / otf-helm / otf / charts / databases / mongodb / templates / deployment-standalone.yaml
1 {{- if not .Values.replicaSet.enabled }}
2 apiVersion: apps/v1
3 kind: {{ if .Values.useStatefulSet }}{{ "StatefulSet" }}{{- else }}{{ "Deployment" }}{{- end }}
4 metadata:
5   name: {{ template "mongodb.fullname" . }}
6   namespace: {{.Values.namespace }}
7   labels:
8     app: {{ template "mongodb.name" . }}
9     chart: {{ template "mongodb.chart" . }}
10     release: "{{ .Release.Name }}"
11     heritage: "{{ .Release.Service }}"
12     {{- with .Values.labels }}
13 {{ toYaml . | indent 4 }}
14     {{- end }}
15   {{- with .Values.annotations }}
16   annotations:
17 {{ toYaml . | indent 4 }}
18   {{- end }}
19 spec:
20   {{- if .Values.useStatefulSet }}
21   serviceName: {{ template "mongodb.serviceName" . }}
22   updateStrategy:
23   {{- else }}
24   strategy:
25   {{- end }}
26     type: {{ .Values.updateStrategy.type }}
27     {{- if (eq "Recreate" .Values.updateStrategy.type) }}
28     rollingUpdate: null
29     {{- end }}
30   selector:
31     matchLabels:
32       app: {{ template "mongodb.name" . }}
33       release: "{{ .Release.Name }}"
34   template:
35     metadata:
36       labels:
37         app: {{ template "mongodb.name" . }}
38         release: "{{ .Release.Name }}"
39         chart: {{ template "mongodb.chart" . }}
40       {{- if .Values.podLabels }}
41 {{ toYaml .Values.podLabels | indent 8 }}
42       {{- end }}
43       {{- if or .Values.podAnnotations .Values.metrics.enabled }}
44       annotations:
45 {{- if .Values.podAnnotations }}
46 {{ toYaml .Values.podAnnotations | indent 8 }}
47 {{- end }}
48 {{- if .Values.metrics.enabled }}
49 {{ toYaml .Values.metrics.podAnnotations | indent 8 }}
50 {{- end }}
51       {{- end }}
52     spec:
53       {{- if .Values.schedulerName }}
54       schedulerName: "{{ .Values.schedulerName }}"
55       {{- end }}
56       {{- if .Values.priorityClassName }}
57       priorityClassName: {{ .Values.priorityClassName }}
58       {{- end }}
59       {{- if .Values.securityContext.enabled }}
60       securityContext:
61         fsGroup: {{ .Values.securityContext.fsGroup }}
62       {{- end }}
63       {{- if .Values.affinity }}
64       affinity:
65 {{ toYaml .Values.affinity | indent 8 }}
66       {{- end -}}
67       {{- if .Values.nodeSelector }}
68       nodeSelector:
69 {{ toYaml .Values.nodeSelector | indent 8 }}
70       {{- end }}
71       {{- if .Values.tolerations }}
72       tolerations:
73 {{ toYaml .Values.tolerations | indent 8 }}
74       {{- end }}
75 {{- include "mongodb.imagePullSecrets" . | indent 6 }}
76       initContainers:
77       {{- if .Values.extraInitContainers }}
78 {{ tpl .Values.extraInitContainers . | indent 6}}
79       {{- end }}
80       {{- if and .Values.volumePermissions.enabled .Values.persistence.enabled }}
81       - name: volume-permissions
82         image: {{ template "mongodb.volumePermissions.image" . }}
83         imagePullPolicy: {{ .Values.volumePermissions.image.pullPolicy | quote }}
84         command: ["chown", "-R", "{{ .Values.securityContext.runAsUser }}:{{ .Values.securityContext.fsGroup }}", "{{ .Values.persistence.mountPath }}"]
85         securityContext:
86           runAsUser: 0
87         resources: {{ toYaml .Values.volumePermissions.resources | nindent 10 }}
88         volumeMounts:
89         - name: data
90           mountPath: {{ .Values.persistence.mountPath }}
91       {{- end }}
92       containers:
93       - name: {{ template "mongodb.fullname" . }}
94         image: {{ template "mongodb.image" . }}
95         imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
96         {{- if .Values.securityContext.enabled }}
97         securityContext:
98           runAsNonRoot: true
99           runAsUser: {{ .Values.securityContext.runAsUser }}
100         {{- end }}
101         env:
102         {{- if .Values.image.debug}}
103         - name: BITNAMI_DEBUG
104           value: "true"
105         {{- end }}
106         {{- if .Values.usePassword }}
107         {{- if and .Values.mongodbUsername .Values.mongodbDatabase }}
108         - name: MONGODB_PASSWORD
109           valueFrom:
110             secretKeyRef:
111               name: {{ if .Values.existingSecret }}{{ .Values.existingSecret }}{{- else }}{{ template "mongodb.fullname" . }}{{- end }}
112               key: mongodb-password
113         {{- end }}
114         - name: MONGODB_ROOT_PASSWORD
115           valueFrom:
116             secretKeyRef:
117               name: {{ if .Values.existingSecret }}{{ .Values.existingSecret }}{{- else }}{{ template "mongodb.fullname" . }}{{- end }}
118               key: mongodb-root-password
119         {{- end }}
120         {{- if .Values.mongodbUsername }}
121         - name: MONGODB_USERNAME
122           value: {{ .Values.mongodbUsername | quote }}
123         {{- end }}
124         - name: MONGODB_SYSTEM_LOG_VERBOSITY
125           value: {{ .Values.mongodbSystemLogVerbosity | quote }}
126         - name: MONGODB_DISABLE_SYSTEM_LOG
127           {{- if .Values.mongodbDisableSystemLog }}
128           value: "yes"
129           {{- else }}
130           value: "no"
131           {{- end }}
132         {{- if .Values.mongodbDatabase }}
133         - name: MONGODB_DATABASE
134           value: {{ .Values.mongodbDatabase | quote }}
135         {{- end }}
136         - name: MONGODB_ENABLE_IPV6
137         {{- if .Values.mongodbEnableIPv6 }}
138           value: "yes"
139         {{- else }}
140           value: "no"
141         {{- end }}
142         - name: MONGODB_ENABLE_DIRECTORY_PER_DB
143         {{- if .Values.mongodbDirectoryPerDB }}
144           value: "yes"
145         {{- else }}
146           value: "no"
147         {{- end }}
148         {{- if .Values.mongodbExtraFlags }}
149         - name: MONGODB_EXTRA_FLAGS
150           value: {{ .Values.mongodbExtraFlags | join " " | quote }}
151         {{- end }}
152         {{- if .Values.extraEnvVars }}
153         {{- include "mongodb.tplValue" ( dict "value" .Values.extraEnvVars "context" $ ) | nindent 8 }}
154         {{- end }}
155         ports:
156         - name: mongodb
157           containerPort: 27017
158         {{- if .Values.livenessProbe.enabled }}
159         livenessProbe:
160           exec:
161             command:
162             - mongo
163             - --eval
164             - "db.adminCommand('ping')"
165           initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
166           periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
167           timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
168           successThreshold: {{ .Values.livenessProbe.successThreshold }}
169           failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
170         {{- end }}
171         {{- if .Values.readinessProbe.enabled }}
172         readinessProbe:
173           exec:
174             command:
175             - mongo
176             - --eval
177             - "db.adminCommand('ping')"
178           initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
179           periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
180           timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
181           successThreshold: {{ .Values.readinessProbe.successThreshold }}
182           failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
183         {{- end }}
184         volumeMounts:
185         - name: data
186           mountPath: {{ .Values.persistence.mountPath }}
187           subPath: {{ .Values.persistence.subPath }}
188         {{- if  or (.Files.Glob "files/docker-entrypoint-initdb.d/*[sh|js|json]") (.Values.initConfigMap) }}
189         - name: custom-init-scripts
190           mountPath: /docker-entrypoint-initdb.d
191         {{- end }}
192         {{- if .Values.configmap }}
193         - name: config
194           mountPath: /opt/bitnami/mongodb/conf/mongodb.conf
195           subPath: mongodb.conf
196         {{- end }}
197         {{- if .Values.extraVolumeMounts }}
198 {{ toYaml .Values.extraVolumeMounts | indent 8}}
199         {{- end }}
200         resources:
201 {{ toYaml .Values.resources | indent 10 }}
202 {{- if .Values.metrics.enabled }}
203       - name: metrics
204         image: {{ template "mongodb.metrics.image" . }}
205         imagePullPolicy: {{ .Values.metrics.image.pullPolicy | quote }}
206         {{- if .Values.securityContext.enabled }}
207         securityContext:
208           runAsNonRoot: true
209           runAsUser: {{ .Values.securityContext.runAsUser }}
210         {{- end }}
211         env:
212         {{- if .Values.usePassword }}
213         - name: MONGODB_ROOT_PASSWORD
214           valueFrom:
215             secretKeyRef:
216               name: {{ if .Values.existingSecret }}{{ .Values.existingSecret }}{{- else }}{{ template "mongodb.fullname" . }}{{- end }}
217               key: mongodb-root-password
218         command: [ 'sh', '-c', '/bin/mongodb_exporter --mongodb.uri mongodb://root:${MONGODB_ROOT_PASSWORD}@localhost:{{ .Values.service.port }}/admin {{ .Values.metrics.extraArgs }}' ]
219         {{- else }}
220         command: [ 'sh', '-c', '/bin/mongodb_exporter --mongodb.uri mongodb://localhost:{{ .Values.service.port }} {{ .Values.metrics.extraArgs }}' ]
221         {{- end }}
222         ports:
223         - name: metrics
224           containerPort: 9216
225         {{- if .Values.metrics.livenessProbe.enabled }}
226         livenessProbe:
227           httpGet:
228             path: /metrics
229             port: metrics
230           initialDelaySeconds: {{ .Values.metrics.livenessProbe.initialDelaySeconds }}
231           periodSeconds: {{ .Values.metrics.readinessProbe.periodSeconds }}
232           timeoutSeconds: {{ .Values.metrics.livenessProbe.timeoutSeconds }}
233           failureThreshold: {{ .Values.metrics.livenessProbe.failureThreshold }}
234           successThreshold: {{ .Values.metrics.livenessProbe.successThreshold }}
235         {{- end }}
236         {{- if .Values.metrics.readinessProbe.enabled }}
237         readinessProbe:
238           httpGet:
239             path: /metrics
240             port: metrics
241           initialDelaySeconds: {{ .Values.metrics.readinessProbe.initialDelaySeconds }}
242           periodSeconds: {{ .Values.metrics.readinessProbe.periodSeconds }}
243           timeoutSeconds: {{ .Values.metrics.readinessProbe.timeoutSeconds }}
244           failureThreshold: {{ .Values.metrics.readinessProbe.failureThreshold }}
245           successThreshold: {{ .Values.metrics.readinessProbe.successThreshold }}
246         {{- end }}
247         resources:
248 {{ toYaml .Values.metrics.resources | indent 10 }}
249 {{- end }}
250 {{- if .Values.sidecars }}
251 {{ toYaml .Values.sidecars | indent 6 }}
252 {{- end }}
253       volumes:
254       {{- if (.Files.Glob "files/docker-entrypoint-initdb.d/*[sh|js|json]") }}
255       - name: custom-init-scripts
256         configMap:
257           name: {{ template "mongodb.fullname" . }}-init-scripts
258       {{- end }}
259       {{- if (.Values.initConfigMap) }}
260       - name: custom-init-scripts
261         configMap:
262           name: {{ .Values.initConfigMap.name }}
263       {{- end }}
264       - name: data
265       {{- if not .Values.useStatefulSet }}
266       {{- if .Values.persistence.enabled }}
267         persistentVolumeClaim:
268           claimName: {{ if .Values.persistence.existingClaim }}{{ .Values.persistence.existingClaim }}{{- else }}{{ template "mongodb.fullname" . }}{{- end }}
269
270       {{- else }}
271         emptyDir: {}
272       {{- end -}}
273       {{- end -}}
274       {{- if .Values.configmap }}
275       - name: config
276         configMap:
277           name: {{ template "mongodb.fullname" . }}
278       {{- end }}
279       {{- if .Values.extraVolumes }}
280 {{ toYaml .Values.extraVolumes | indent 6}}
281       {{- end }}
282 {{- if .Values.useStatefulSet }}
283 {{- if .Values.persistence.enabled }}
284   volumeClaimTemplates:
285     - metadata:
286         name: data
287         annotations:
288         {{- range $key, $value := .Values.persistence.annotations }}
289           {{ $key }}: "{{ $value }}"
290         {{- end }}
291       spec:
292         accessModes:
293         {{- range .Values.persistence.accessModes }}
294           - {{ . | quote }}
295         {{- end }}
296         resources:
297           requests:
298             storage: {{ .Values.persistence.size | quote }}
299         {{ include "mongodb.storageClass" . }}
300 {{- else }}
301         - name: data
302           emptyDir: {}
303 {{- end }}
304 {{- end }}
305 {{- end -}}