Commit dba458cb by Guangbo Chen

Bump mongodb chart to v7.2.6

parent 5d3dbc6d
apiVersion: v1
name: mongodb name: mongodb
version: 5.0.0 version: 7.2.6
appVersion: 4.0.3 appVersion: 4.0.12
description: NoSQL document-oriented database that stores JSON-like documents with dynamic schemas, simplifying the integration of data in content-driven applications. description: NoSQL document-oriented database that stores JSON-like documents with dynamic schemas, simplifying the integration of data in content-driven applications.
keywords: keywords:
- mongodb - mongodb
...@@ -10,7 +11,7 @@ keywords: ...@@ -10,7 +11,7 @@ keywords:
- replicaset - replicaset
- replication - replication
home: https://mongodb.org home: https://mongodb.org
icon: https://bitnami.com/assets/stacks/mongodb/img/mongodb-stack-220x234.png icon: file://../mongodb-stack-220x234.png
sources: sources:
- https://github.com/bitnami/bitnami-docker-mongodb - https://github.com/bitnami/bitnami-docker-mongodb
maintainers: maintainers:
......
...@@ -3,10 +3,12 @@ approvers: ...@@ -3,10 +3,12 @@ approvers:
- tompizmor - tompizmor
- sameersbn - sameersbn
- carrodher - carrodher
- javsalgar
- juan131 - juan131
reviewers: reviewers:
- prydonius - prydonius
- tompizmor - tompizmor
- sameersbn - sameersbn
- carrodher - carrodher
- javsalgar
- juan131 - juan131
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
[MongoDB](https://www.mongodb.com/) is a cross-platform document-oriented database. Classified as a NoSQL database, MongoDB eschews the traditional table-based relational database structure in favor of JSON-like documents with dynamic schemas, making the integration of data in certain types of applications easier and faster. [MongoDB](https://www.mongodb.com/) is a cross-platform document-oriented database. Classified as a NoSQL database, MongoDB eschews the traditional table-based relational database structure in favor of JSON-like documents with dynamic schemas, making the integration of data in certain types of applications easier and faster.
## Replica Set
By default, a MongoDB replica set will consist of a primary, a secondary and an arbiter mongod instance. ## Introduction
Arbiters do not maintain a data set. The purpose of an arbiter is to maintain a quorum in a replica set by responding to heartbeat and election requests by other replica set members.
This chart bootstraps a [MongoDB](https://github.com/bitnami/bitnami-docker-mongodb) deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.
Bitnami charts can be used with [Kubeapps](https://kubeapps.com/) for deployment and management of Helm Charts in clusters. This chart has been tested to work with NGINX Ingress, cert-manager, fluentd and Prometheus on top of the [BKPR](https://kubeprod.io/).
categories: categories:
- Database - Database
- NoSQL
questions: questions:
- variable: defaultImage - variable: defaultImage
default: "true" default: "true"
...@@ -11,23 +10,33 @@ questions: ...@@ -11,23 +10,33 @@ questions:
group: "Container Images" group: "Container Images"
subquestions: subquestions:
- variable: image.repository - variable: image.repository
default: "bitnami/mongodb" default: "ranchercharts/bitnami-mongodb"
description: "MongoDB image name" description: "MongoDB image name"
type: string type: string
label: MongoDB Image Name label: MongoDB Image Name
- variable: image.tag - variable: image.tag
default: "4.0.3" default: "4.0.12-debian-9-r5"
description: "MongoDB image tag"
type: string
label: Image Tag
- variable: volumePermissions.image.repository
default: "ranchercharts/bitnami-minideb"
description: "MongoDB image name"
type: string
label: MongoDB Image Name
- variable: volumePermissions.image.tag
default: "stretch"
description: "MongoDB image tag" description: "MongoDB image tag"
type: string type: string
label: Image Tag label: Image Tag
- variable: metrics.image.repository - variable: metrics.image.repository
default: "forekshub/percona-mongodb-exporter" default: "ranchercharts/bitnami-mongodb-exporter"
description: "MongoDB metrics image name" description: "MongoDB metrics image name"
type: string type: string
label: MongoDB Metrics Image Name label: MongoDB Metrics Image Name
show_if: "defaultImage=false&&metrics.enabled=true" show_if: "defaultImage=false&&metrics.enabled=true"
- variable: metrics.image.tag - variable: metrics.image.tag
default: "latest" default: "0.8.0-debian-9-r4"
description: "MongoDB metrics image tag" description: "MongoDB metrics image tag"
type: string type: string
label: Image Metrics Tag label: Image Metrics Tag
......
...@@ -17,9 +17,9 @@ ...@@ -17,9 +17,9 @@
** Please be patient while the chart is being deployed ** ** Please be patient while the chart is being deployed **
MongoDB can be accessed via port 27017 on the following DNS name from within your cluster: MongoDB can be accessed via port {{ .Values.service.port }} on the following DNS name from within your cluster:
{{ template "mongodb.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local {{ template "mongodb.fullname" . }}.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}
{{ if .Values.usePassword -}} {{ if .Values.usePassword -}}
...@@ -60,7 +60,16 @@ To connect to your database from outside the cluster execute the following comma ...@@ -60,7 +60,16 @@ To connect to your database from outside the cluster execute the following comma
{{- else if contains "ClusterIP" .Values.service.type }} {{- else if contains "ClusterIP" .Values.service.type }}
kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{ template "mongodb.fullname" . }} 27017:27017 & kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{ template "mongodb.fullname" . }} {{ .Values.service.port }}:{{ .Values.service.port }} &
mongo --host 127.0.0.1 {{- if .Values.usePassword }} --authenticationDatabase admin -p $MONGODB_ROOT_PASSWORD{{- end }} mongo --host 127.0.0.1 {{- if .Values.usePassword }} --authenticationDatabase admin -p $MONGODB_ROOT_PASSWORD{{- end }}
{{- end }} {{- end }}
{{- include "mongodb.validateValues" . -}}
{{- if and (contains "bitnami/" .Values.image.repository) (not (.Values.image.tag | toString | regexFind "-r\\d+$|sha256:")) }}
WARNING: Rolling tag detected ({{ .Values.image.repository }}:{{ .Values.image.tag }}), please note that it is strongly recommended to avoid using rolling tags in a production environment.
+info https://docs.bitnami.com/containers/how-to/understand-rolling-tags-containers/
{{- end }}
...@@ -57,6 +57,7 @@ Create the name for the key secret. ...@@ -57,6 +57,7 @@ Create the name for the key secret.
Return the proper MongoDB image name Return the proper MongoDB image name
*/}} */}}
{{- define "mongodb.image" -}} {{- define "mongodb.image" -}}
{{- $registryName := .Values.image.registry -}}
{{- $repositoryName := .Values.image.repository -}} {{- $repositoryName := .Values.image.repository -}}
{{- $tag := .Values.image.tag | toString -}} {{- $tag := .Values.image.tag | toString -}}
{{/* {{/*
...@@ -68,19 +69,159 @@ Also, we can't use a single if because lazy evaluation is not an option ...@@ -68,19 +69,159 @@ Also, we can't use a single if because lazy evaluation is not an option
{{- if .Values.global.imageRegistry }} {{- if .Values.global.imageRegistry }}
{{- printf "%s/%s:%s" .Values.global.imageRegistry $repositoryName $tag -}} {{- printf "%s/%s:%s" .Values.global.imageRegistry $repositoryName $tag -}}
{{- else -}} {{- else -}}
{{- printf "%s:%s" $repositoryName $tag -}} {{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
{{- end -}} {{- end -}}
{{- else -}} {{- else -}}
{{- printf "%s:%s" $repositoryName $tag -}} {{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
{{/* {{/*
Return the proper image name (for the metrics image) Return the proper image name (for the metrics image)
*/}} */}}
{{- define "metrics.image" -}} {{- define "mongodb.metrics.image" -}}
{{- $registryName := .Values.metrics.image.registry -}}
{{- $repositoryName := .Values.metrics.image.repository -}} {{- $repositoryName := .Values.metrics.image.repository -}}
{{- $tag := .Values.metrics.image.tag | toString -}} {{- $tag := .Values.metrics.image.tag | toString -}}
{{- printf "%s:%s" $repositoryName $tag -}} {{/*
Helm 2.11 supports the assignment of a value to a variable defined in a different scope,
but Helm 2.9 and 2.10 doesn't support it, so we need to implement this if-else logic.
Also, we can't use a single if because lazy evaluation is not an option
*/}}
{{- if .Values.global }}
{{- if .Values.global.imageRegistry }}
{{- printf "%s/%s:%s" .Values.global.imageRegistry $repositoryName $tag -}}
{{- else -}}
{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
{{- end -}}
{{- else -}}
{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
{{- end -}} {{- end -}}
{{- end -}}
{{/*
Return the proper Docker Image Registry Secret Names
*/}}
{{- define "mongodb.imagePullSecrets" -}}
{{/*
Helm 2.11 supports the assignment of a value to a variable defined in a different scope,
but Helm 2.9 and 2.10 does not support it, so we need to implement this if-else logic.
Also, we can not use a single if because lazy evaluation is not an option
*/}}
{{- if .Values.global }}
{{- if .Values.global.imagePullSecrets }}
imagePullSecrets:
{{- range .Values.global.imagePullSecrets }}
- name: {{ . }}
{{- end }}
{{- else if or .Values.image.pullSecrets .Values.metrics.image.pullSecrets .Values.volumePermissions.image.pullSecrets }}
imagePullSecrets:
{{- range .Values.image.pullSecrets }}
- name: {{ . }}
{{- end }}
{{- range .Values.metrics.image.pullSecrets }}
- name: {{ . }}
{{- end }}
{{- range .Values.volumePermissions.image.pullSecrets }}
- name: {{ . }}
{{- end }}
{{- end -}}
{{- else if or .Values.image.pullSecrets .Values.metrics.image.pullSecrets .Values.volumePermissions.image.pullSecrets }}
imagePullSecrets:
{{- range .Values.image.pullSecrets }}
- name: {{ . }}
{{- end }}
{{- range .Values.metrics.image.pullSecrets }}
- name: {{ . }}
{{- end }}
{{- range .Values.volumePermissions.image.pullSecrets }}
- name: {{ . }}
{{- end }}
{{- end -}}
{{- end -}}
{{/*
Return the proper image name (for the init container volume-permissions image)
*/}}
{{- define "mongodb.volumePermissions.image" -}}
{{- $registryName := .Values.volumePermissions.image.registry -}}
{{- $repositoryName := .Values.volumePermissions.image.repository -}}
{{- $tag := .Values.volumePermissions.image.tag | toString -}}
{{/*
Helm 2.11 supports the assignment of a value to a variable defined in a different scope,
but Helm 2.9 and 2.10 doesn't support it, so we need to implement this if-else logic.
Also, we can't use a single if because lazy evaluation is not an option
*/}}
{{- if .Values.global }}
{{- if .Values.global.imageRegistry }}
{{- printf "%s/%s:%s" .Values.global.imageRegistry $repositoryName $tag -}}
{{- else -}}
{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
{{- end -}}
{{- else -}}
{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
{{- end -}}
{{- end -}}
{{/*
Compile all warnings into a single message, and call fail.
*/}}
{{- define "mongodb.validateValues" -}}
{{- $messages := list -}}
{{- $messages := append $messages (include "mongodb.validateValues.mongodbCustomDatabase" .) -}}
{{- $messages := without $messages "" -}}
{{- $message := join "\n" $messages -}}
{{- if $message -}}
{{- printf "\nVALUES VALIDATION:\n%s" $message | fail -}}
{{- end -}}
{{- end -}}
{{/*
Validate values of MongoDB - both mongodbUsername and mongodbDatabase are necessary
to create a custom user and database during 1st initialization
*/}}
{{- define "mongodb.validateValues.mongodbCustomDatabase" -}}
{{- if or (and .Values.mongodbUsername (not .Values.mongodbDatabase)) (and (not .Values.mongodbUsername) .Values.mongodbDatabase) }}
mongodb: mongodbUsername, mongodbDatabase
Both mongodbUsername and mongodbDatabase must be provided to create
a custom user and database during 1st initialization.
Please set both of them (--set mongodbUsername="xxxx",mongodbDatabase="yyyy")
{{- end -}}
{{- end -}}
{{/*
Return the proper Storage Class
*/}}
{{- define "mongodb.storageClass" -}}
{{/*
Helm 2.11 supports the assignment of a value to a variable defined in a different scope,
but Helm 2.9 and 2.10 does not support it, so we need to implement this if-else logic.
*/}}
{{- if .Values.global -}}
{{- if .Values.global.storageClass -}}
{{- if (eq "-" .Values.global.storageClass) -}}
{{- printf "storageClassName: \"\"" -}}
{{- else }}
{{- printf "storageClassName: %s" .Values.global.storageClass -}}
{{- end -}}
{{- else -}}
{{- if .Values.persistence.storageClass -}}
{{- if (eq "-" .Values.persistence.storageClass) -}}
{{- printf "storageClassName: \"\"" -}}
{{- else }}
{{- printf "storageClassName: %s" .Values.persistence.storageClass -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- else -}}
{{- if .Values.persistence.storageClass -}}
{{- if (eq "-" .Values.persistence.storageClass) -}}
{{- printf "storageClassName: \"\"" -}}
{{- else }}
{{- printf "storageClassName: %s" .Values.persistence.storageClass -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- if not .Values.replicaSet.enabled }} {{- if not .Values.replicaSet.enabled }}
apiVersion: extensions/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
name: {{ template "mongodb.fullname" . }} name: {{ template "mongodb.fullname" . }}
...@@ -32,10 +32,15 @@ spec: ...@@ -32,10 +32,15 @@ spec:
{{- end }} {{- end }}
{{- end }} {{- end }}
spec: spec:
{{- if .Values.schedulerName }}
schedulerName: "{{ .Values.schedulerName }}"
{{- end }}
{{- if .Values.priorityClassName }}
priorityClassName: {{ .Values.priorityClassName }}
{{- end }}
{{- if .Values.securityContext.enabled }} {{- if .Values.securityContext.enabled }}
securityContext: securityContext:
fsGroup: {{ .Values.securityContext.fsGroup }} fsGroup: {{ .Values.securityContext.fsGroup }}
runAsUser: {{ .Values.securityContext.runAsUser }}
{{- end }} {{- end }}
{{- if .Values.affinity }} {{- if .Values.affinity }}
affinity: affinity:
...@@ -49,43 +54,83 @@ spec: ...@@ -49,43 +54,83 @@ spec:
tolerations: tolerations:
{{ toYaml .Values.tolerations | indent 8 }} {{ toYaml .Values.tolerations | indent 8 }}
{{- end }} {{- end }}
{{- if .Values.image.pullSecrets }} {{- include "mongodb.imagePullSecrets" . | indent 6 }}
imagePullSecrets: initContainers:
{{- range .Values.image.pullSecrets }} {{- if .Values.extraInitContainers }}
- name: {{ . }} {{ tpl .Values.extraInitContainers . | indent 6}}
{{- end}} {{- end }}
{{- if and .Values.volumePermissions.enabled .Values.persistence.enabled }}
- name: volume-permissions
image: {{ template "mongodb.volumePermissions.image" . }}
imagePullPolicy: {{ .Values.volumePermissions.image.pullPolicy | quote }}
command: ["chown", "-R", "{{ .Values.securityContext.runAsUser }}:{{ .Values.securityContext.fsGroup }}", "{{ .Values.persistence.mountPath }}"]
securityContext:
runAsUser: 0
resources: {{ toYaml .Values.volumePermissions.resources | nindent 10 }}
volumeMounts:
- name: data
mountPath: {{ .Values.persistence.mountPath }}
{{- end }} {{- end }}
containers: containers:
- name: {{ template "mongodb.fullname" . }} - name: {{ template "mongodb.fullname" . }}
image: {{ template "mongodb.image" . }} image: {{ template "mongodb.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy | quote }} imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
{{- if .Values.securityContext.enabled }}
securityContext:
runAsNonRoot: true
runAsUser: {{ .Values.securityContext.runAsUser }}
{{- end }}
env: env:
{{- if .Values.image.debug}}
- name: BITNAMI_DEBUG
value: "true"
{{- end }}
{{- if .Values.usePassword }} {{- if .Values.usePassword }}
- name: MONGODB_ROOT_PASSWORD {{- if and .Values.mongodbUsername .Values.mongodbDatabase }}
- name: MONGODB_PASSWORD
valueFrom: valueFrom:
secretKeyRef: secretKeyRef:
name: {{ if .Values.existingSecret }}{{ .Values.existingSecret }}{{- else }}{{ template "mongodb.fullname" . }}{{- end }} name: {{ if .Values.existingSecret }}{{ .Values.existingSecret }}{{- else }}{{ template "mongodb.fullname" . }}{{- end }}
key: mongodb-root-password key: mongodb-password
{{- end }} {{- end }}
- name: MONGODB_USERNAME - name: MONGODB_ROOT_PASSWORD
value: {{ default "" .Values.mongodbUsername | quote }}
{{- if and .Values.mongodbUsername .Values.mongodbDatabase }}
- name: MONGODB_PASSWORD
valueFrom: valueFrom:
secretKeyRef: secretKeyRef:
name: {{ if .Values.existingSecret }}{{ .Values.existingSecret }}{{- else }}{{ template "mongodb.fullname" . }}{{- end }} name: {{ if .Values.existingSecret }}{{ .Values.existingSecret }}{{- else }}{{ template "mongodb.fullname" . }}{{- end }}
key: mongodb-password key: mongodb-root-password
{{- end }}
{{- if .Values.mongodbUsername }}
- name: MONGODB_USERNAME
value: {{ .Values.mongodbUsername | quote }}
{{- end }} {{- end }}
- name: MONGODB_SYSTEM_LOG_VERBOSITY
value: {{ .Values.mongodbSystemLogVerbosity | quote }}
- name: MONGODB_DISABLE_SYSTEM_LOG
{{- if .Values.mongodbDisableSystemLog }}
value: "yes"
{{- else }}
value: "no"
{{- end }}
{{- if .Values.mongodbDatabase }}
- name: MONGODB_DATABASE - name: MONGODB_DATABASE
value: {{ default "" .Values.mongodbDatabase | quote }} value: {{ .Values.mongodbDatabase | quote }}
{{- end }}
- name: MONGODB_ENABLE_IPV6 - name: MONGODB_ENABLE_IPV6
{{- if .Values.mongodbEnableIPv6 }} {{- if .Values.mongodbEnableIPv6 }}
value: "yes" value: "yes"
{{- else }} {{- else }}
value: "no" value: "no"
{{- end }} {{- end }}
- name: MONGODB_ENABLE_DIRECTORY_PER_DB
{{- if .Values.mongodbDirectoryPerDB }}
value: "yes"
{{- else }}
value: "no"
{{- end }}
{{- if .Values.mongodbExtraFlags }}
- name: MONGODB_EXTRA_FLAGS - name: MONGODB_EXTRA_FLAGS
value: {{ default "" .Values.mongodbExtraFlags | join " " }} value: {{ .Values.mongodbExtraFlags | join " " }}
{{- end }}
ports: ports:
- name: mongodb - name: mongodb
containerPort: 27017 containerPort: 27017
...@@ -117,8 +162,9 @@ spec: ...@@ -117,8 +162,9 @@ spec:
{{- end }} {{- end }}
volumeMounts: volumeMounts:
- name: data - name: data
mountPath: /bitnami/mongodb mountPath: {{ .Values.persistence.mountPath }}
{{- if (.Files.Glob "files/docker-entrypoint-initdb.d/*[sh|js]") }} subPath: {{ .Values.persistence.subPath }}
{{- if or (.Files.Glob "files/docker-entrypoint-initdb.d/*[sh|js|json]") (.Values.initConfigMap) }}
- name: custom-init-scripts - name: custom-init-scripts
mountPath: /docker-entrypoint-initdb.d mountPath: /docker-entrypoint-initdb.d
{{- end }} {{- end }}
...@@ -131,8 +177,13 @@ spec: ...@@ -131,8 +177,13 @@ spec:
{{ toYaml .Values.resources | indent 10 }} {{ toYaml .Values.resources | indent 10 }}
{{- if .Values.metrics.enabled }} {{- if .Values.metrics.enabled }}
- name: metrics - name: metrics
image: {{ template "metrics.image" . }} image: {{ template "mongodb.metrics.image" . }}
imagePullPolicy: {{ .Values.metrics.image.pullPolicy | quote }} imagePullPolicy: {{ .Values.metrics.image.pullPolicy | quote }}
{{- if .Values.securityContext.enabled }}
securityContext:
runAsNonRoot: true
runAsUser: {{ .Values.securityContext.runAsUser }}
{{- end }}
env: env:
{{- if .Values.usePassword }} {{- if .Values.usePassword }}
- name: MONGODB_ROOT_PASSWORD - name: MONGODB_ROOT_PASSWORD
...@@ -140,34 +191,49 @@ spec: ...@@ -140,34 +191,49 @@ spec:
secretKeyRef: secretKeyRef:
name: {{ if .Values.existingSecret }}{{ .Values.existingSecret }}{{- else }}{{ template "mongodb.fullname" . }}{{- end }} name: {{ if .Values.existingSecret }}{{ .Values.existingSecret }}{{- else }}{{ template "mongodb.fullname" . }}{{- end }}
key: mongodb-root-password key: mongodb-root-password
command: [ 'sh', '-c', '/bin/mongodb_exporter --mongodb.uri mongodb://root:${MONGODB_ROOT_PASSWORD}@localhost:{{ .Values.service.port }}/admin' ] command: [ 'sh', '-c', '/bin/mongodb_exporter --mongodb.uri mongodb://root:${MONGODB_ROOT_PASSWORD}@localhost:{{ .Values.service.port }}/admin {{ .Values.metrics.extraArgs }}' ]
{{- else }} {{- else }}
command: [ 'sh', '-c', '/bin/mongodb_exporter --mongodb.uri mongodb://localhost:{{ .Values.service.port }}' ] command: [ 'sh', '-c', '/bin/mongodb_exporter --mongodb.uri mongodb://localhost:{{ .Values.service.port }} {{ .Values.metrics.extraArgs }}' ]
{{- end }} {{- end }}
ports: ports:
- name: metrics - name: metrics
containerPort: 9216 containerPort: 9216
{{- if .Values.metrics.livenessProbe.enabled }}
livenessProbe: livenessProbe:
httpGet: httpGet:
path: /metrics path: /metrics
port: metrics port: metrics
initialDelaySeconds: 15 initialDelaySeconds: {{ .Values.metrics.livenessProbe.initialDelaySeconds }}
timeoutSeconds: 5 periodSeconds: {{ .Values.metrics.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.metrics.livenessProbe.timeoutSeconds }}
failureThreshold: {{ .Values.metrics.livenessProbe.failureThreshold }}
successThreshold: {{ .Values.metrics.livenessProbe.successThreshold }}
{{- end }}
{{- if .Values.metrics.readinessProbe.enabled }}
readinessProbe: readinessProbe:
httpGet: httpGet:
path: /metrics path: /metrics
port: metrics port: metrics
initialDelaySeconds: 5 initialDelaySeconds: {{ .Values.metrics.readinessProbe.initialDelaySeconds }}
timeoutSeconds: 1 periodSeconds: {{ .Values.metrics.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.metrics.readinessProbe.timeoutSeconds }}
failureThreshold: {{ .Values.metrics.readinessProbe.failureThreshold }}
successThreshold: {{ .Values.metrics.readinessProbe.successThreshold }}
{{- end }}
resources: resources:
{{ toYaml .Values.metrics.resources | indent 10 }} {{ toYaml .Values.metrics.resources | indent 10 }}
{{- end }} {{- end }}
volumes: volumes:
{{- if (.Files.Glob "files/docker-entrypoint-initdb.d/*[sh|js]") }} {{- if (.Files.Glob "files/docker-entrypoint-initdb.d/*[sh|js|json]") }}
- name: custom-init-scripts - name: custom-init-scripts
configMap: configMap:
name: {{ template "mongodb.fullname" . }}-init-scripts name: {{ template "mongodb.fullname" . }}-init-scripts
{{- end }} {{- end }}
{{- if (.Values.initConfigMap) }}
- name: custom-init-scripts
configMap:
name: {{ .Values.initConfigMap.name }}
{{- end }}
- name: data - name: data
{{- if .Values.persistence.enabled }} {{- if .Values.persistence.enabled }}
persistentVolumeClaim: persistentVolumeClaim:
......
...@@ -9,8 +9,7 @@ metadata: ...@@ -9,8 +9,7 @@ metadata:
release: "{{ .Release.Name }}" release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}" heritage: "{{ .Release.Service }}"
{{- if .Values.service.annotations }} {{- if .Values.service.annotations }}
annotations: annotations: {{ toYaml .Values.service.annotations | nindent 4 }}
{{ toYaml .Values.service.annotations | indent 4 }}
{{- end }} {{- end }}
spec: spec:
type: ClusterIP type: ClusterIP
...@@ -18,11 +17,6 @@ spec: ...@@ -18,11 +17,6 @@ spec:
ports: ports:
- name: mongodb - name: mongodb
port: {{ .Values.service.port }} port: {{ .Values.service.port }}
{{- if .Values.metrics.enabled }}
- name: metrics
port: 9216
targetPort: metrics
{{- end }}
selector: selector:
app: {{ template "mongodb.name" . }} app: {{ template "mongodb.name" . }}
release: {{ .Release.Name }} release: {{ .Release.Name }}
......
{{- if .Values.ingress.enabled }}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ template "mongodb.fullname" . }}
labels:
app: {{ template "mongodb.name" . }}
chart: {{ template "mongodb.chart" . }}
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
annotations:
{{- if .Values.ingress.certManager }}
kubernetes.io/tls-acme: "true"
{{- end }}
{{- range $key, $value := .Values.ingress.annotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
spec:
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .name }}
http:
paths:
- path: {{ default "/" .path }}
backend:
serviceName: "{{ template "mongodb.fullname" $ }}"
servicePort: mongodb
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{ toYaml .Values.ingress.tls | indent 4 }}
{{- end }}
{{- end }}
\ No newline at end of file
{{ if (.Files.Glob "files/docker-entrypoint-initdb.d/*[sh|js]") }} {{ if (.Files.Glob "files/docker-entrypoint-initdb.d/*[sh|js|json]") }}
apiVersion: v1 apiVersion: v1
kind: ConfigMap kind: ConfigMap
metadata: metadata:
...@@ -9,5 +9,5 @@ metadata: ...@@ -9,5 +9,5 @@ metadata:
release: {{ .Release.Name | quote }} release: {{ .Release.Name | quote }}
heritage: {{ .Release.Service | quote }} heritage: {{ .Release.Service | quote }}
data: data:
{{ (.Files.Glob "files/docker-entrypoint-initdb.d/*[sh|js]").AsConfig | indent 2 }} {{ tpl (.Files.Glob "files/docker-entrypoint-initdb.d/*[sh|js|json]").AsConfig . | indent 2 }}
{{ end }} {{ end }}
{{- if .Values.replicaSet.enabled }} {{- if and .Values.replicaSet.enabled .Values.replicaSet.pdb.enabled }}
{{- if .Release.IsInstall }}
apiVersion: policy/v1beta1 apiVersion: policy/v1beta1
kind: PodDisruptionBudget kind: PodDisruptionBudget
metadata: metadata:
...@@ -10,11 +9,19 @@ metadata: ...@@ -10,11 +9,19 @@ metadata:
release: {{ .Release.Name }} release: {{ .Release.Name }}
name: {{ template "mongodb.fullname" . }}-arbiter name: {{ template "mongodb.fullname" . }}-arbiter
spec: spec:
{{- if .Values.replicaSet.pdb.minAvailable }}
{{- if .Values.replicaSet.pdb.minAvailable.arbiter }}
minAvailable: {{ .Values.replicaSet.pdb.minAvailable.arbiter }}
{{- end }}
{{- end }}
{{- if .Values.replicaSet.pdb.maxUnavailable }}
{{- if .Values.replicaSet.pdb.maxUnavailable.arbiter }}
maxUnavailable: {{ .Values.replicaSet.pdb.maxUnavailable.arbiter }}
{{- end }}
{{- end }}
selector: selector:
matchLabels: matchLabels:
app: {{ template "mongodb.name" . }} app: {{ template "mongodb.name" . }}
release: {{ .Release.Name }} release: {{ .Release.Name }}
component: arbiter component: arbiter
minAvailable: {{ .Values.replicaSet.pdb.minAvailable.arbiter }}
{{- end }}
{{- end }} {{- end }}
\ No newline at end of file
{{- if .Values.replicaSet.enabled }}
{{- if .Release.IsInstall }}
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
labels:
app: {{ template "mongodb.name" . }}
chart: {{ template "mongodb.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
name: {{ template "mongodb.fullname" . }}-primary
spec:
selector:
matchLabels:
app: {{ template "mongodb.name" . }}
release: {{ .Release.Name }}
component: primary
minAvailable: {{ .Values.replicaSet.pdb.minAvailable.primary }}
{{- end }}
{{- end }}
{{- if .Values.replicaSet.enabled }} {{- if and .Values.replicaSet.enabled .Values.replicaSet.pdb.enabled }}
{{- if .Release.IsInstall }}
apiVersion: policy/v1beta1 apiVersion: policy/v1beta1
kind: PodDisruptionBudget kind: PodDisruptionBudget
metadata: metadata:
...@@ -10,11 +9,19 @@ metadata: ...@@ -10,11 +9,19 @@ metadata:
release: {{ .Release.Name }} release: {{ .Release.Name }}
name: {{ template "mongodb.fullname" . }}-secondary name: {{ template "mongodb.fullname" . }}-secondary
spec: spec:
{{- if .Values.replicaSet.pdb.minAvailable }}
{{- if .Values.replicaSet.pdb.minAvailable.secondary }}
minAvailable: {{ .Values.replicaSet.pdb.minAvailable.secondary }}
{{- end }}
{{- end }}
{{- if .Values.replicaSet.pdb.maxUnavailable }}
{{- if .Values.replicaSet.pdb.maxUnavailable.secondary }}
maxUnavailable: {{ .Values.replicaSet.pdb.maxUnavailable.secondary }}
{{- end }}
{{- end }}
selector: selector:
matchLabels: matchLabels:
app: {{ template "mongodb.name" . }} app: {{ template "mongodb.name" . }}
release: {{ .Release.Name }} release: {{ .Release.Name }}
component: secondary component: secondary
minAvailable: {{ .Values.replicaSet.pdb.minAvailable.secondary }}
{{- end }}
{{- end }} {{- end }}
...@@ -3,6 +3,9 @@ apiVersion: monitoring.coreos.com/v1 ...@@ -3,6 +3,9 @@ apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor kind: ServiceMonitor
metadata: metadata:
name: {{ template "mongodb.fullname" . }} name: {{ template "mongodb.fullname" . }}
{{- if .Values.metrics.serviceMonitor.namespace }}
namespace: {{ .Values.metrics.serviceMonitor.namespace }}
{{- end }}
labels: labels:
app: {{ template "mongodb.name" . }} app: {{ template "mongodb.name" . }}
chart: {{ template "mongodb.chart" . }} chart: {{ template "mongodb.chart" . }}
......
...@@ -16,11 +16,5 @@ spec: ...@@ -16,11 +16,5 @@ spec:
resources: resources:
requests: requests:
storage: {{ .Values.persistence.size | quote }} storage: {{ .Values.persistence.size | quote }}
{{- if .Values.persistence.storageClass }} {{ include "mongodb.storageClass" . }}
{{- if (eq "-" .Values.persistence.storageClass) }}
storageClassName: ""
{{- else }}
storageClassName: "{{ .Values.persistence.storageClass }}"
{{- end }}
{{- end }}
{{- end }} {{- end }}
...@@ -10,13 +10,11 @@ metadata: ...@@ -10,13 +10,11 @@ metadata:
heritage: "{{ .Release.Service }}" heritage: "{{ .Release.Service }}"
type: Opaque type: Opaque
data: data:
{{- if .Values.usePassword }}
{{- if .Values.mongodbRootPassword }} {{- if .Values.mongodbRootPassword }}
mongodb-root-password: {{ .Values.mongodbRootPassword | b64enc | quote }} mongodb-root-password: {{ .Values.mongodbRootPassword | b64enc | quote }}
{{- else }} {{- else }}
mongodb-root-password: {{ randAlphaNum 10 | b64enc | quote }} mongodb-root-password: {{ randAlphaNum 10 | b64enc | quote }}
{{- end }} {{- end }}
{{- end }}
{{- if and .Values.mongodbUsername .Values.mongodbDatabase }} {{- if and .Values.mongodbUsername .Values.mongodbDatabase }}
{{- if .Values.mongodbPassword }} {{- if .Values.mongodbPassword }}
mongodb-password: {{ .Values.mongodbPassword | b64enc | quote }} mongodb-password: {{ .Values.mongodbPassword | b64enc | quote }}
......
...@@ -16,6 +16,11 @@ spec: ...@@ -16,6 +16,11 @@ spec:
component: arbiter component: arbiter
serviceName: {{ template "mongodb.fullname" . }}-headless serviceName: {{ template "mongodb.fullname" . }}-headless
replicas: {{ .Values.replicaSet.replicas.arbiter }} replicas: {{ .Values.replicaSet.replicas.arbiter }}
updateStrategy:
type: {{ .Values.updateStrategy.type }}
{{- if (eq "Recreate" .Values.updateStrategy.type) }}
rollingUpdate: null
{{- end }}
template: template:
metadata: metadata:
labels: labels:
...@@ -31,14 +36,19 @@ spec: ...@@ -31,14 +36,19 @@ spec:
{{ toYaml .Values.podAnnotations | indent 8 }} {{ toYaml .Values.podAnnotations | indent 8 }}
{{- end }} {{- end }}
spec: spec:
{{- if .Values.schedulerName }}
schedulerName: "{{ .Values.schedulerName }}"
{{- end }}
{{- if .Values.priorityClassName }}
priorityClassName: {{ .Values.priorityClassName }}
{{- end }}
{{- if .Values.securityContext.enabled }} {{- if .Values.securityContext.enabled }}
securityContext: securityContext:
fsGroup: {{ .Values.securityContext.fsGroup }} fsGroup: {{ .Values.securityContext.fsGroup }}
runAsUser: {{ .Values.securityContext.runAsUser }}
{{- end }} {{- end }}
{{- if .Values.affinity }} {{- if .Values.affinityArbiter }}
affinity: affinity:
{{ toYaml .Values.affinity | indent 8 }} {{ toYaml .Values.affinityArbiter | indent 8 }}
{{- end -}} {{- end -}}
{{- if .Values.nodeSelector }} {{- if .Values.nodeSelector }}
nodeSelector: nodeSelector:
...@@ -48,20 +58,36 @@ spec: ...@@ -48,20 +58,36 @@ spec:
tolerations: tolerations:
{{ toYaml .Values.tolerations | indent 8 }} {{ toYaml .Values.tolerations | indent 8 }}
{{- end }} {{- end }}
{{- if .Values.image.pullSecrets }} {{- include "mongodb.imagePullSecrets" . | indent 6 }}
imagePullSecrets: {{- if .Values.extraInitContainers }}
{{- range .Values.image.pullSecrets }} initContainers:
- name: {{ . }} {{ tpl .Values.extraInitContainers . | indent 6}}
{{- end}}
{{- end }} {{- end }}
containers: containers:
- name: {{ template "mongodb.name" . }}-arbiter - name: {{ template "mongodb.name" . }}-arbiter
image: {{ template "mongodb.image" . }} image: {{ template "mongodb.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy }} imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if .Values.securityContext.enabled }}
securityContext:
runAsNonRoot: true
runAsUser: {{ .Values.securityContext.runAsUser }}
{{- end }}
ports: ports:
- containerPort: {{ .Values.service.port }} - containerPort: {{ .Values.service.port }}
name: mongodb name: mongodb
env: env:
{{- if .Values.image.debug}}
- name: BITNAMI_DEBUG
value: "true"
{{- end }}
- name: MONGODB_SYSTEM_LOG_VERBOSITY
value: {{ .Values.mongodbSystemLogVerbosity | quote }}
- name: MONGODB_DISABLE_SYSTEM_LOG
{{- if .Values.mongodbDisableSystemLog }}
value: "yes"
{{- else }}
value: "no"
{{- end }}
- name: MONGODB_POD_NAME - name: MONGODB_POD_NAME
valueFrom: valueFrom:
fieldRef: fieldRef:
...@@ -94,8 +120,16 @@ spec: ...@@ -94,8 +120,16 @@ spec:
{{- else }} {{- else }}
value: "no" value: "no"
{{- end }} {{- end }}
- name: MONGODB_ENABLE_DIRECTORY_PER_DB
{{- if .Values.mongodbDirectoryPerDB }}
value: "yes"
{{- else }}
value: "no"
{{- end }}
{{- if .Values.mongodbExtraFlags }}
- name: MONGODB_EXTRA_FLAGS - name: MONGODB_EXTRA_FLAGS
value: {{ default "" .Values.mongodbExtraFlags | join " " }} value: {{ .Values.mongodbExtraFlags | join " " }}
{{- end }}
{{- if .Values.livenessProbe.enabled }} {{- if .Values.livenessProbe.enabled }}
livenessProbe: livenessProbe:
tcpSocket: tcpSocket:
...@@ -123,7 +157,7 @@ spec: ...@@ -123,7 +157,7 @@ spec:
subPath: mongodb.conf subPath: mongodb.conf
{{- end }} {{- end }}
resources: resources:
{{ toYaml .Values.resources | indent 12 }} {{ toYaml .Values.resourcesArbiter | indent 12 }}
volumes: volumes:
{{- if .Values.configmap }} {{- if .Values.configmap }}
- name: config - name: config
......
...@@ -11,6 +11,11 @@ metadata: ...@@ -11,6 +11,11 @@ metadata:
spec: spec:
serviceName: {{ template "mongodb.fullname" . }}-headless serviceName: {{ template "mongodb.fullname" . }}-headless
replicas: 1 replicas: 1
updateStrategy:
type: {{ .Values.updateStrategy.type }}
{{- if (eq "Recreate" .Values.updateStrategy.type) }}
rollingUpdate: null
{{- end }}
selector: selector:
matchLabels: matchLabels:
app: {{ template "mongodb.name" . }} app: {{ template "mongodb.name" . }}
...@@ -36,10 +41,15 @@ spec: ...@@ -36,10 +41,15 @@ spec:
{{- end }} {{- end }}
{{- end }} {{- end }}
spec: spec:
{{- if .Values.schedulerName }}
schedulerName: "{{ .Values.schedulerName }}"
{{- end }}
{{- if .Values.priorityClassName }}
priorityClassName: {{ .Values.priorityClassName }}
{{- end }}
{{- if .Values.securityContext.enabled }} {{- if .Values.securityContext.enabled }}
securityContext: securityContext:
fsGroup: {{ .Values.securityContext.fsGroup }} fsGroup: {{ .Values.securityContext.fsGroup }}
runAsUser: {{ .Values.securityContext.runAsUser }}
{{- end }} {{- end }}
{{- if .Values.affinity }} {{- if .Values.affinity }}
affinity: affinity:
...@@ -53,20 +63,48 @@ spec: ...@@ -53,20 +63,48 @@ spec:
tolerations: tolerations:
{{ toYaml .Values.tolerations | indent 8 }} {{ toYaml .Values.tolerations | indent 8 }}
{{- end }} {{- end }}
{{- if .Values.image.pullSecrets }} {{- include "mongodb.imagePullSecrets" . | indent 6 }}
imagePullSecrets: initContainers:
{{- range .Values.image.pullSecrets }} {{- if .Values.extraInitContainers }}
- name: {{ . }} {{ tpl .Values.extraInitContainers . | indent 6}}
{{- end}} {{- end }}
{{- if and .Values.volumePermissions.enabled .Values.persistence.enabled }}
- name: volume-permissions
image: {{ template "mongodb.volumePermissions.image" . }}
imagePullPolicy: {{ .Values.volumePermissions.image.pullPolicy | quote }}
command: ["chown", "-R", "{{ .Values.securityContext.runAsUser }}:{{ .Values.securityContext.fsGroup }}", "{{ .Values.persistence.mountPath }}"]
securityContext:
runAsUser: 0
resources: {{ toYaml .Values.volumePermissions.resources | nindent 10 }}
volumeMounts:
- name: datadir
mountPath: {{ .Values.persistence.mountPath }}
{{- end }} {{- end }}
containers: containers:
- name: {{ template "mongodb.name" . }}-primary - name: {{ template "mongodb.name" . }}-primary
image: {{ template "mongodb.image" . }} image: {{ template "mongodb.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy }} imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if .Values.securityContext.enabled }}
securityContext:
runAsNonRoot: true
runAsUser: {{ .Values.securityContext.runAsUser }}
{{- end }}
ports: ports:
- containerPort: {{ .Values.service.port }} - containerPort: {{ .Values.service.port }}
name: mongodb name: mongodb
env: env:
{{- if .Values.image.debug}}
- name: BITNAMI_DEBUG
value: "true"
{{- end }}
- name: MONGODB_SYSTEM_LOG_VERBOSITY
value: {{ .Values.mongodbSystemLogVerbosity | quote }}
- name: MONGODB_DISABLE_SYSTEM_LOG
{{- if .Values.mongodbDisableSystemLog }}
value: "yes"
{{- else }}
value: "no"
{{- end }}
- name: MONGODB_POD_NAME - name: MONGODB_POD_NAME
valueFrom: valueFrom:
fieldRef: fieldRef:
...@@ -79,12 +117,16 @@ spec: ...@@ -79,12 +117,16 @@ spec:
- name: MONGODB_ADVERTISED_HOSTNAME - name: MONGODB_ADVERTISED_HOSTNAME
value: "$(MONGODB_POD_NAME).{{ template "mongodb.fullname" . }}-headless.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}" value: "$(MONGODB_POD_NAME).{{ template "mongodb.fullname" . }}-headless.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}"
{{- end }} {{- end }}
{{- if .Values.mongodbUsername }}
- name: MONGODB_USERNAME - name: MONGODB_USERNAME
value: {{ .Values.mongodbUsername | quote }} value: {{ .Values.mongodbUsername | quote }}
{{- end }}
{{- if .Values.mongodbDatabase }}
- name: MONGODB_DATABASE - name: MONGODB_DATABASE
value: {{ .Values.mongodbDatabase | quote }} value: {{ .Values.mongodbDatabase | quote }}
{{- end }}
{{- if .Values.usePassword }} {{- if .Values.usePassword }}
{{- if or .Values.mongodbPassword .Values.existingSecret }} {{- if and .Values.mongodbUsername .Values.mongodbDatabase }}
- name: MONGODB_PASSWORD - name: MONGODB_PASSWORD
valueFrom: valueFrom:
secretKeyRef: secretKeyRef:
...@@ -108,8 +150,16 @@ spec: ...@@ -108,8 +150,16 @@ spec:
{{- else }} {{- else }}
value: "no" value: "no"
{{- end }} {{- end }}
- name: MONGODB_ENABLE_DIRECTORY_PER_DB
{{- if .Values.mongodbDirectoryPerDB }}
value: "yes"
{{- else }}
value: "no"
{{- end }}
{{- if .Values.mongodbExtraFlags }}
- name: MONGODB_EXTRA_FLAGS - name: MONGODB_EXTRA_FLAGS
value: {{ default "" .Values.mongodbExtraFlags | join " " }} value: {{ .Values.mongodbExtraFlags | join " " }}
{{- end }}
{{- if .Values.livenessProbe.enabled }} {{- if .Values.livenessProbe.enabled }}
livenessProbe: livenessProbe:
exec: exec:
...@@ -138,8 +188,9 @@ spec: ...@@ -138,8 +188,9 @@ spec:
{{- end }} {{- end }}
volumeMounts: volumeMounts:
- name: datadir - name: datadir
mountPath: /bitnami/mongodb mountPath: {{ .Values.persistence.mountPath }}
{{- if (.Files.Glob "files/docker-entrypoint-initdb.d/*[sh|js]") }} subPath: {{ .Values.persistence.subPath }}
{{- if or (.Files.Glob "files/docker-entrypoint-initdb.d/*[sh|js|json]") (.Values.initConfigMap) }}
- name: custom-init-scripts - name: custom-init-scripts
mountPath: /docker-entrypoint-initdb.d mountPath: /docker-entrypoint-initdb.d
{{- end }} {{- end }}
...@@ -152,8 +203,13 @@ spec: ...@@ -152,8 +203,13 @@ spec:
{{ toYaml .Values.resources | indent 12 }} {{ toYaml .Values.resources | indent 12 }}
{{- if .Values.metrics.enabled }} {{- if .Values.metrics.enabled }}
- name: metrics - name: metrics
image: {{ template "metrics.image" . }} image: {{ template "mongodb.metrics.image" . }}
imagePullPolicy: {{ .Values.metrics.image.pullPolicy | quote }} imagePullPolicy: {{ .Values.metrics.image.pullPolicy | quote }}
{{- if .Values.securityContext.enabled }}
securityContext:
runAsNonRoot: true
runAsUser: {{ .Values.securityContext.runAsUser }}
{{- end }}
env: env:
{{- if .Values.usePassword }} {{- if .Values.usePassword }}
- name: MONGODB_ROOT_PASSWORD - name: MONGODB_ROOT_PASSWORD
...@@ -161,34 +217,49 @@ spec: ...@@ -161,34 +217,49 @@ spec:
secretKeyRef: secretKeyRef:
name: {{ if .Values.existingSecret }}{{ .Values.existingSecret }}{{- else }}{{ template "mongodb.fullname" . }}{{- end }} name: {{ if .Values.existingSecret }}{{ .Values.existingSecret }}{{- else }}{{ template "mongodb.fullname" . }}{{- end }}
key: mongodb-root-password key: mongodb-root-password
command: [ 'sh', '-c', '/bin/mongodb_exporter --mongodb.uri mongodb://root:${MONGODB_ROOT_PASSWORD}@localhost:{{ .Values.service.port }}/admin' ] command: [ 'sh', '-c', '/bin/mongodb_exporter --mongodb.uri mongodb://root:${MONGODB_ROOT_PASSWORD}@localhost:{{ .Values.service.port }}/admin {{ .Values.metrics.extraArgs }}' ]
{{- else }} {{- else }}
command: [ 'sh', '-c', '/bin/mongodb_exporter --mongodb.uri mongodb://localhost:{{ .Values.service.port }}' ] command: [ 'sh', '-c', '/bin/mongodb_exporter --mongodb.uri mongodb://localhost:{{ .Values.service.port }} {{ .Values.metrics.extraArgs }}' ]
{{- end }} {{- end }}
ports: ports:
- name: metrics - name: metrics
containerPort: 9216 containerPort: 9216
{{- if .Values.metrics.livenessProbe.enabled }}
livenessProbe: livenessProbe:
httpGet: httpGet:
path: /metrics path: /metrics
port: metrics port: metrics
initialDelaySeconds: 15 initialDelaySeconds: {{ .Values.metrics.livenessProbe.initialDelaySeconds }}
timeoutSeconds: 5 periodSeconds: {{ .Values.metrics.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.metrics.livenessProbe.timeoutSeconds }}
failureThreshold: {{ .Values.metrics.livenessProbe.failureThreshold }}
successThreshold: {{ .Values.metrics.livenessProbe.successThreshold }}
{{- end }}
{{- if .Values.metrics.readinessProbe.enabled }}
readinessProbe: readinessProbe:
httpGet: httpGet:
path: /metrics path: /metrics
port: metrics port: metrics
initialDelaySeconds: 5 initialDelaySeconds: {{ .Values.metrics.readinessProbe.initialDelaySeconds }}
timeoutSeconds: 1 periodSeconds: {{ .Values.metrics.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.metrics.readinessProbe.timeoutSeconds }}
failureThreshold: {{ .Values.metrics.readinessProbe.failureThreshold }}
successThreshold: {{ .Values.metrics.readinessProbe.successThreshold }}
{{- end }}
resources: resources:
{{ toYaml .Values.metrics.resources | indent 10 }} {{ toYaml .Values.metrics.resources | indent 12 }}
{{- end }} {{- end }}
volumes: volumes:
{{- if (.Files.Glob "files/docker-entrypoint-initdb.d/*[sh|js]") }} {{- if (.Files.Glob "files/docker-entrypoint-initdb.d/*[sh|js|json]") }}
- name: custom-init-scripts - name: custom-init-scripts
configMap: configMap:
name: {{ template "mongodb.fullname" . }}-init-scripts name: {{ template "mongodb.fullname" . }}-init-scripts
{{- end }} {{- end }}
{{- if (.Values.initConfigMap) }}
- name: custom-init-scripts
configMap:
name: {{ .Values.initConfigMap.name }}
{{- end }}
{{- if .Values.configmap }} {{- if .Values.configmap }}
- name: config - name: config
configMap: configMap:
...@@ -200,7 +271,7 @@ spec: ...@@ -200,7 +271,7 @@ spec:
name: datadir name: datadir
annotations: annotations:
{{- range $key, $value := .Values.persistence.annotations }} {{- range $key, $value := .Values.persistence.annotations }}
{{ $key }}: {{ $value }} {{ $key }}: "{{ $value }}"
{{- end }} {{- end }}
spec: spec:
accessModes: accessModes:
...@@ -210,13 +281,7 @@ spec: ...@@ -210,13 +281,7 @@ spec:
resources: resources:
requests: requests:
storage: {{ .Values.persistence.size | quote }} storage: {{ .Values.persistence.size | quote }}
{{- if .Values.persistence.storageClass }} {{ include "mongodb.storageClass" . }}
{{- if (eq "-" .Values.persistence.storageClass) }}
storageClassName: ""
{{- else }}
storageClassName: "{{ .Values.persistence.storageClass }}"
{{- end }}
{{- end }}
{{- else }} {{- else }}
- name: datadir - name: datadir
emptyDir: {} emptyDir: {}
......
...@@ -17,6 +17,11 @@ spec: ...@@ -17,6 +17,11 @@ spec:
podManagementPolicy: "Parallel" podManagementPolicy: "Parallel"
serviceName: {{ template "mongodb.fullname" . }}-headless serviceName: {{ template "mongodb.fullname" . }}-headless
replicas: {{ .Values.replicaSet.replicas.secondary }} replicas: {{ .Values.replicaSet.replicas.secondary }}
updateStrategy:
type: {{ .Values.updateStrategy.type }}
{{- if (eq "Recreate" .Values.updateStrategy.type) }}
rollingUpdate: null
{{- end }}
template: template:
metadata: metadata:
labels: labels:
...@@ -37,10 +42,15 @@ spec: ...@@ -37,10 +42,15 @@ spec:
{{- end }} {{- end }}
{{- end }} {{- end }}
spec: spec:
{{- if .Values.schedulerName }}
schedulerName: "{{ .Values.schedulerName }}"
{{- end }}
{{- if .Values.priorityClassName }}
priorityClassName: {{ .Values.priorityClassName }}
{{- end }}
{{- if .Values.securityContext.enabled }} {{- if .Values.securityContext.enabled }}
securityContext: securityContext:
fsGroup: {{ .Values.securityContext.fsGroup }} fsGroup: {{ .Values.securityContext.fsGroup }}
runAsUser: {{ .Values.securityContext.runAsUser }}
{{- end }} {{- end }}
{{- if .Values.affinity }} {{- if .Values.affinity }}
affinity: affinity:
...@@ -54,20 +64,48 @@ spec: ...@@ -54,20 +64,48 @@ spec:
tolerations: tolerations:
{{ toYaml .Values.tolerations | indent 8 }} {{ toYaml .Values.tolerations | indent 8 }}
{{- end }} {{- end }}
{{- if .Values.image.pullSecrets }} {{- include "mongodb.imagePullSecrets" . | indent 6 }}
imagePullSecrets: initContainers:
{{- range .Values.image.pullSecrets }} {{- if .Values.extraInitContainers }}
- name: {{ . }} {{ tpl .Values.extraInitContainers . | indent 6}}
{{- end}} {{- end }}
{{- if and .Values.volumePermissions.enabled .Values.persistence.enabled }}
- name: volume-permissions
image: {{ template "mongodb.volumePermissions.image" . }}
imagePullPolicy: {{ .Values.volumePermissions.image.pullPolicy | quote }}
command: ["chown", "-R", "{{ .Values.securityContext.runAsUser }}:{{ .Values.securityContext.fsGroup }}", "{{ .Values.persistence.mountPath }}"]
securityContext:
runAsUser: 0
resources: {{ toYaml .Values.volumePermissions.resources | nindent 10 }}
volumeMounts:
- name: datadir
mountPath: {{ .Values.persistence.mountPath }}
{{- end }} {{- end }}
containers: containers:
- name: {{ template "mongodb.name" . }}-secondary - name: {{ template "mongodb.name" . }}-secondary
image: {{ template "mongodb.image" . }} image: {{ template "mongodb.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy }} imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if .Values.securityContext.enabled }}
securityContext:
runAsNonRoot: true
runAsUser: {{ .Values.securityContext.runAsUser }}
{{- end }}
ports: ports:
- containerPort: {{ .Values.service.port }} - containerPort: {{ .Values.service.port }}
name: mongodb name: mongodb
env: env:
{{- if .Values.image.debug}}
- name: BITNAMI_DEBUG
value: "true"
{{- end }}
- name: MONGODB_SYSTEM_LOG_VERBOSITY
value: {{ .Values.mongodbSystemLogVerbosity | quote }}
- name: MONGODB_DISABLE_SYSTEM_LOG
{{- if .Values.mongodbDisableSystemLog }}
value: "yes"
{{- else }}
value: "no"
{{- end }}
- name: MONGODB_POD_NAME - name: MONGODB_POD_NAME
valueFrom: valueFrom:
fieldRef: fieldRef:
...@@ -100,8 +138,16 @@ spec: ...@@ -100,8 +138,16 @@ spec:
{{- else }} {{- else }}
value: "no" value: "no"
{{- end }} {{- end }}
- name: MONGODB_ENABLE_DIRECTORY_PER_DB
{{- if .Values.mongodbDirectoryPerDB }}
value: "yes"
{{- else }}
value: "no"
{{- end }}
{{- if .Values.mongodbExtraFlags }}
- name: MONGODB_EXTRA_FLAGS - name: MONGODB_EXTRA_FLAGS
value: {{ default "" .Values.mongodbExtraFlags | join " " }} value: {{ .Values.mongodbExtraFlags | join " " }}
{{- end }}
{{- if .Values.livenessProbe.enabled }} {{- if .Values.livenessProbe.enabled }}
livenessProbe: livenessProbe:
exec: exec:
...@@ -130,7 +176,8 @@ spec: ...@@ -130,7 +176,8 @@ spec:
{{- end }} {{- end }}
volumeMounts: volumeMounts:
- name: datadir - name: datadir
mountPath: /bitnami/mongodb mountPath: {{ .Values.persistence.mountPath }}
subPath: {{ .Values.persistence.subPath }}
{{- if .Values.configmap }} {{- if .Values.configmap }}
- name: config - name: config
mountPath: /opt/bitnami/mongodb/conf/mongodb.conf mountPath: /opt/bitnami/mongodb/conf/mongodb.conf
...@@ -140,8 +187,13 @@ spec: ...@@ -140,8 +187,13 @@ spec:
{{ toYaml .Values.resources | indent 12 }} {{ toYaml .Values.resources | indent 12 }}
{{- if .Values.metrics.enabled }} {{- if .Values.metrics.enabled }}
- name: metrics - name: metrics
image: {{ template "metrics.image" . }} image: {{ template "mongodb.metrics.image" . }}
imagePullPolicy: {{ .Values.metrics.image.pullPolicy | quote }} imagePullPolicy: {{ .Values.metrics.image.pullPolicy | quote }}
{{- if .Values.securityContext.enabled }}
securityContext:
runAsNonRoot: true
runAsUser: {{ .Values.securityContext.runAsUser }}
{{- end }}
env: env:
{{- if .Values.usePassword }} {{- if .Values.usePassword }}
- name: MONGODB_ROOT_PASSWORD - name: MONGODB_ROOT_PASSWORD
...@@ -149,27 +201,37 @@ spec: ...@@ -149,27 +201,37 @@ spec:
secretKeyRef: secretKeyRef:
name: {{ if .Values.existingSecret }}{{ .Values.existingSecret }}{{- else }}{{ template "mongodb.fullname" . }}{{- end }} name: {{ if .Values.existingSecret }}{{ .Values.existingSecret }}{{- else }}{{ template "mongodb.fullname" . }}{{- end }}
key: mongodb-root-password key: mongodb-root-password
command: [ 'sh', '-c', '/bin/mongodb_exporter --mongodb.uri mongodb://root:${MONGODB_ROOT_PASSWORD}@localhost:{{ .Values.service.port }}/admin' ] command: [ 'sh', '-c', '/bin/mongodb_exporter --mongodb.uri mongodb://root:${MONGODB_ROOT_PASSWORD}@localhost:{{ .Values.service.port }}/admin {{ .Values.metrics.extraArgs }}' ]
{{- else }} {{- else }}
command: [ 'sh', '-c', '/bin/mongodb_exporter --mongodb.uri mongodb://localhost:{{ .Values.service.port }}' ] command: [ 'sh', '-c', '/bin/mongodb_exporter --mongodb.uri mongodb://localhost:{{ .Values.service.port }} {{ .Values.metrics.extraArgs }}' ]
{{- end }} {{- end }}
ports: ports:
- name: metrics - name: metrics
containerPort: 9216 containerPort: 9216
{{- if .Values.metrics.livenessProbe.enabled }}
livenessProbe: livenessProbe:
httpGet: httpGet:
path: /metrics path: /metrics
port: metrics port: metrics
initialDelaySeconds: 15 initialDelaySeconds: {{ .Values.metrics.livenessProbe.initialDelaySeconds }}
timeoutSeconds: 5 periodSeconds: {{ .Values.metrics.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.metrics.livenessProbe.timeoutSeconds }}
failureThreshold: {{ .Values.metrics.livenessProbe.failureThreshold }}
successThreshold: {{ .Values.metrics.livenessProbe.successThreshold }}
{{- end }}
{{- if .Values.metrics.readinessProbe.enabled }}
readinessProbe: readinessProbe:
httpGet: httpGet:
path: /metrics path: /metrics
port: metrics port: metrics
initialDelaySeconds: 5 initialDelaySeconds: {{ .Values.metrics.readinessProbe.initialDelaySeconds }}
timeoutSeconds: 1 periodSeconds: {{ .Values.metrics.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.metrics.readinessProbe.timeoutSeconds }}
failureThreshold: {{ .Values.metrics.readinessProbe.failureThreshold }}
successThreshold: {{ .Values.metrics.readinessProbe.successThreshold }}
{{- end }}
resources: resources:
{{ toYaml .Values.metrics.resources | indent 10 }} {{ toYaml .Values.metrics.resources | indent 12 }}
{{- end }} {{- end }}
volumes: volumes:
{{- if .Values.configmap }} {{- if .Values.configmap }}
...@@ -183,7 +245,7 @@ spec: ...@@ -183,7 +245,7 @@ spec:
name: datadir name: datadir
annotations: annotations:
{{- range $key, $value := .Values.persistence.annotations }} {{- range $key, $value := .Values.persistence.annotations }}
{{ $key }}: {{ $value }} {{ $key }}: "{{ $value }}"
{{- end }} {{- end }}
spec: spec:
accessModes: accessModes:
...@@ -193,13 +255,7 @@ spec: ...@@ -193,13 +255,7 @@ spec:
resources: resources:
requests: requests:
storage: {{ .Values.persistence.size | quote }} storage: {{ .Values.persistence.size | quote }}
{{- if .Values.persistence.storageClass }} {{ include "mongodb.storageClass" . }}
{{- if (eq "-" .Values.persistence.storageClass) }}
storageClassName: ""
{{- else }}
storageClassName: "{{ .Values.persistence.storageClass }}"
{{- end }}
{{- end }}
{{- else }} {{- else }}
- name: datadir - name: datadir
emptyDir: {} emptyDir: {}
......
...@@ -9,21 +9,34 @@ metadata: ...@@ -9,21 +9,34 @@ metadata:
release: "{{ .Release.Name }}" release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}" heritage: "{{ .Release.Service }}"
{{- if .Values.service.annotations }} {{- if .Values.service.annotations }}
annotations: annotations: {{ toYaml .Values.service.annotations | nindent 4 }}
{{ toYaml .Values.service.annotations | indent 4 }}
{{- end }} {{- end }}
spec: spec:
type: {{ .Values.service.type }} type: {{ .Values.service.type }}
{{- if and (eq .Values.service.type "ClusterIP") .Values.service.clusterIP }} {{- if and (eq .Values.service.type "ClusterIP") .Values.service.clusterIP }}
clusterIP: {{ .Values.service.clusterIP }} clusterIP: {{ .Values.service.clusterIP }}
{{- end }} {{- end }}
{{- if and (eq .Values.service.type "LoadBalancer") .Values.service.loadBalancerIP }}
loadBalancerIP: {{ .Values.service.loadBalancerIP }}
{{- end }}
{{- if .Values.service.externalIPs }}
externalIPs: {{ toYaml .Values.service.externalIPs | nindent 4 }}
{{- end }}
{{- if .Values.service.loadBalancerSourceRanges }}
loadBalancerSourceRanges: {{- toYaml .Values.service.loadBalancerSourceRanges | nindent 4 }}
{{- end }}
ports: ports:
- name: mongodb - name: mongodb
port: 27017 port: {{ .Values.service.port }}
targetPort: mongodb targetPort: mongodb
{{- if .Values.service.nodePort }} {{- if .Values.service.nodePort }}
nodePort: {{ .Values.service.nodePort }} nodePort: {{ .Values.service.nodePort }}
{{- end }} {{- end }}
{{- if .Values.metrics.enabled }}
- name: metrics
port: 9216
targetPort: metrics
{{- end }}
selector: selector:
app: {{ template "mongodb.name" . }} app: {{ template "mongodb.name" . }}
release: "{{ .Release.Name }}" release: "{{ .Release.Name }}"
......
...@@ -9,17 +9,25 @@ metadata: ...@@ -9,17 +9,25 @@ metadata:
release: "{{ .Release.Name }}" release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}" heritage: "{{ .Release.Service }}"
{{- if .Values.service.annotations }} {{- if .Values.service.annotations }}
annotations: annotations: {{ toYaml .Values.service.annotations | nindent 4 }}
{{ toYaml .Values.service.annotations | indent 4 }}
{{- end }} {{- end }}
spec: spec:
type: {{ .Values.service.type }} type: {{ .Values.service.type }}
{{- if and (eq .Values.service.type "ClusterIP") .Values.service.clusterIP }} {{- if and (eq .Values.service.type "ClusterIP") .Values.service.clusterIP }}
clusterIP: {{ .Values.service.clusterIP }} clusterIP: {{ .Values.service.clusterIP }}
{{- end }} {{- end }}
{{- if and (eq .Values.service.type "LoadBalancer") .Values.service.loadBalancerIP }}
loadBalancerIP: {{ .Values.service.loadBalancerIP }}
{{- end }}
{{- if .Values.service.externalIPs }}
externalIPs: {{ toYaml .Values.service.externalIPs | nindent 4 }}
{{- end }}
{{- if .Values.service.loadBalancerSourceRanges }}
loadBalancerSourceRanges: {{- toYaml .Values.service.loadBalancerSourceRanges | nindent 4 }}
{{- end }}
ports: ports:
- name: mongodb - name: mongodb
port: 27017 port: {{ .Values.service.port }}
targetPort: mongodb targetPort: mongodb
{{- if .Values.service.nodePort }} {{- if .Values.service.nodePort }}
nodePort: {{ .Values.service.nodePort }} nodePort: {{ .Values.service.nodePort }}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment