diff --git a/bitnami/mongodb/Chart.yaml b/bitnami/mongodb/Chart.yaml index 1fa6f6ab3..4fe1e27e9 100644 --- a/bitnami/mongodb/Chart.yaml +++ b/bitnami/mongodb/Chart.yaml @@ -26,4 +26,4 @@ name: mongodb sources: - https://github.com/bitnami/bitnami-docker-mongodb - https://mongodb.org -version: 10.26.1 +version: 10.26.2 diff --git a/bitnami/mongodb/README.md b/bitnami/mongodb/README.md index 362cedccc..48a04b932 100644 --- a/bitnami/mongodb/README.md +++ b/bitnami/mongodb/README.md @@ -413,6 +413,8 @@ Refer to the [chart documentation for more information on each of these architec | `metrics.image.tag` | MongoDB® Prometheus exporter image tag (immutable tags are recommended) | `0.11.2-debian-10-r266` | | `metrics.image.pullPolicy` | MongoDB® Prometheus exporter image pull policy | `IfNotPresent` | | `metrics.image.pullSecrets` | Specify docker-registry secret names as an array | `[]` | +| `metrics.username` | String with username for the metrics exporter | `""` | +| `metrics.password` | String with password for the metrics exporter | `""` | | `metrics.extraFlags` | String with extra flags to the metrics exporter | `""` | | `metrics.extraUri` | Additional URI options of the metrics service | `""` | | `metrics.resources.limits` | The resources limits for Prometheus exporter containers | `{}` | diff --git a/bitnami/mongodb/templates/_helpers.tpl b/bitnami/mongodb/templates/_helpers.tpl index 4ce6c5eee..66c749cae 100644 --- a/bitnami/mongodb/templates/_helpers.tpl +++ b/bitnami/mongodb/templates/_helpers.tpl @@ -346,9 +346,13 @@ Validate values of MongoDB® exporter URI string - auth.enabled and/or tls.en */}} {{- define "mongodb.mongodb_exporter.uri" -}} {{- $uriTlsArgs := ternary "tls=true&tlsCertificateKeyFile=/certs/mongodb.pem&tlsCAFile=/certs/mongodb-ca-cert" "" .Values.tls.enabled -}} - {{- $uriAuth := ternary "$MONGODB_ROOT_USER:$(echo $MONGODB_ROOT_PASSWORD | sed -r \"s/@/%40/g;s/:/%3A/g\")@" "" .Values.auth.enabled -}} - - {{- printf "mongodb://%slocalhost:27017/admin?%s" $uriAuth $uriTlsArgs -}} + {{- if .Values.metrics.username }} + {{- $uriAuth := ternary "$(echo $MONGODB_METRICS_USERNAME | sed -r \"s/@/%40/g;s/:/%3A/g\"):$(echo $MONGODB_METRICS_PASSWORD | sed -r \"s/@/%40/g;s/:/%3A/g\")@" "" .Values.auth.enabled -}} + {{- printf "mongodb://%slocalhost:27017/admin?%s" $uriAuth $uriTlsArgs -}} + {{- else -}} + {{- $uriAuth := ternary "$MONGODB_ROOT_USER:$(echo $MONGODB_ROOT_PASSWORD | sed -r \"s/@/%40/g;s/:/%3A/g\")@" "" .Values.auth.enabled -}} + {{- printf "mongodb://%slocalhost:27017/admin?%s" $uriAuth $uriTlsArgs -}} + {{- end -}} {{- end -}} diff --git a/bitnami/mongodb/templates/hidden/statefulset.yaml b/bitnami/mongodb/templates/hidden/statefulset.yaml index ca732e8c2..253e2ad85 100644 --- a/bitnami/mongodb/templates/hidden/statefulset.yaml +++ b/bitnami/mongodb/templates/hidden/statefulset.yaml @@ -244,6 +244,10 @@ spec: - name: MONGODB_DATABASE value: {{ .Values.auth.database | quote }} {{- end }} + {{- if .Values.metrics.username }} + - name: MONGODB_METRICS_USERNAME + value: {{ .Values.metrics.username | quote }} + {{- end }} {{- if .Values.auth.enabled }} {{- if and .Values.auth.username .Values.auth.database }} - name: MONGODB_PASSWORD @@ -252,6 +256,13 @@ spec: name: {{ include "mongodb.secretName" . }} key: mongodb-password {{- end }} + {{- if .Values.metrics.username }} + - name: MONGODB_METRICS_PASSWORD + valueFrom: + secretKeyRef: + name: {{ include "mongodb.secretName" . }} + key: mongodb-metrics-password + {{- end }} - name: MONGODB_ROOT_PASSWORD valueFrom: secretKeyRef: @@ -401,6 +412,7 @@ spec: {{- end }} env: {{- if .Values.auth.enabled }} + {{- if not .Values.metrics.username }} - name: MONGODB_ROOT_USER value: {{ .Values.auth.rootUser | quote }} - name: MONGODB_ROOT_PASSWORD @@ -408,6 +420,15 @@ spec: secretKeyRef: name: {{ include "mongodb.secretName" . }} key: mongodb-root-password + {{- else }} + - name: MONGODB_METRICS_USERNAME + value: {{ .Values.metrics.username | quote }} + - name: MONGODB_METRICS_PASSWORD + valueFrom: + secretKeyRef: + name: {{ include "mongodb.secretName" . }} + key: mongodb-metrics-password + {{- end }} {{- end }} volumeMounts: {{- if .Values.tls.enabled }} diff --git a/bitnami/mongodb/templates/replicaset/statefulset.yaml b/bitnami/mongodb/templates/replicaset/statefulset.yaml index ed9f5da90..32cca4ce1 100644 --- a/bitnami/mongodb/templates/replicaset/statefulset.yaml +++ b/bitnami/mongodb/templates/replicaset/statefulset.yaml @@ -249,6 +249,10 @@ spec: - name: MONGODB_DATABASE value: {{ .Values.auth.database | quote }} {{- end }} + {{- if .Values.metrics.username }} + - name: MONGODB_METRICS_USERNAME + value: {{ .Values.metrics.username | quote }} + {{- end }} {{- if .Values.auth.enabled }} {{- if and .Values.auth.username .Values.auth.database }} - name: MONGODB_PASSWORD @@ -257,6 +261,13 @@ spec: name: {{ include "mongodb.secretName" . }} key: mongodb-password {{- end }} + {{- if .Values.metrics.username }} + - name: MONGODB_METRICS_PASSWORD + valueFrom: + secretKeyRef: + name: {{ include "mongodb.secretName" . }} + key: mongodb-metrics-password + {{- end }} - name: MONGODB_ROOT_USER value: {{ .Values.auth.rootUser | quote }} - name: MONGODB_ROOT_PASSWORD @@ -437,6 +448,7 @@ spec: {{- end }} env: {{- if .Values.auth.enabled }} + {{- if not .Values.metrics.username }} - name: MONGODB_ROOT_USER value: {{ .Values.auth.rootUser | quote }} - name: MONGODB_ROOT_PASSWORD @@ -444,6 +456,15 @@ spec: secretKeyRef: name: {{ include "mongodb.secretName" . }} key: mongodb-root-password + {{- else }} + - name: MONGODB_METRICS_USERNAME + value: {{ .Values.metrics.username | quote }} + - name: MONGODB_METRICS_PASSWORD + valueFrom: + secretKeyRef: + name: {{ include "mongodb.secretName" . }} + key: mongodb-metrics-password + {{- end }} {{- end }} volumeMounts: {{- if .Values.tls.enabled }} diff --git a/bitnami/mongodb/templates/secrets.yaml b/bitnami/mongodb/templates/secrets.yaml index 93d31b513..73f7d5b20 100644 --- a/bitnami/mongodb/templates/secrets.yaml +++ b/bitnami/mongodb/templates/secrets.yaml @@ -26,6 +26,13 @@ data: mongodb-password: {{ randAlphaNum 10 | b64enc | quote }} {{- end }} {{- end }} + {{- if .Values.metrics.username }} + {{- if .Values.metrics.password }} + mongodb-metrics-password: {{ .Values.metrics.password | toString | b64enc | quote }} + {{- else }} + mongodb-metrics-password: {{ randAlphaNum 10 | b64enc | quote }} + {{- end }} + {{- end }} {{- if eq .Values.architecture "replicaset" }} {{- if .Values.auth.replicaSetKey }} mongodb-replica-set-key: {{ .Values.auth.replicaSetKey | toString | b64enc | quote }} diff --git a/bitnami/mongodb/templates/standalone/dep-sts.yaml b/bitnami/mongodb/templates/standalone/dep-sts.yaml index 9f1b209b6..bd8302bcc 100644 --- a/bitnami/mongodb/templates/standalone/dep-sts.yaml +++ b/bitnami/mongodb/templates/standalone/dep-sts.yaml @@ -203,6 +203,10 @@ spec: - name: MONGODB_DATABASE value: {{ .Values.auth.database | quote }} {{- end }} + {{- if .Values.metrics.username }} + - name: MONGODB_METRICS_USERNAME + value: {{ .Values.metrics.username | quote }} + {{- end }} {{- if .Values.auth.enabled }} {{- if and .Values.auth.username .Values.auth.database }} - name: MONGODB_PASSWORD @@ -211,6 +215,13 @@ spec: name: {{ include "mongodb.secretName" . }} key: mongodb-password {{- end }} + {{- if .Values.metrics.username }} + - name: MONGODB_METRICS_PASSWORD + valueFrom: + secretKeyRef: + name: {{ include "mongodb.secretName" . }} + key: mongodb-metrics-password + {{- end }} - name: MONGODB_ROOT_USER value: {{ .Values.auth.rootUser | quote }} - name: MONGODB_ROOT_PASSWORD @@ -375,6 +386,7 @@ spec: /bin/mongodb_exporter --web.listen-address ":{{ .Values.metrics.containerPort }}" --mongodb.uri "{{ include "mongodb.mongodb_exporter.uri" . }}" {{ .Values.metrics.extraFlags }} env: {{- if .Values.auth.enabled }} + {{- if not .Values.metrics.username }} - name: MONGODB_ROOT_USER value: {{ .Values.auth.rootUser | quote }} - name: MONGODB_ROOT_PASSWORD @@ -382,6 +394,15 @@ spec: secretKeyRef: name: {{ include "mongodb.secretName" . }} key: mongodb-root-password + {{- else }} + - name: MONGODB_METRICS_USERNAME + value: {{ .Values.metrics.username | quote }} + - name: MONGODB_METRICS_PASSWORD + valueFrom: + secretKeyRef: + name: {{ include "mongodb.secretName" . }} + key: mongodb-metrics-password + {{- end }} {{- end }} volumeMounts: {{- if .Values.tls.enabled }} diff --git a/bitnami/mongodb/values.yaml b/bitnami/mongodb/values.yaml index 22cb4762b..01beddf63 100644 --- a/bitnami/mongodb/values.yaml +++ b/bitnami/mongodb/values.yaml @@ -1512,6 +1512,13 @@ metrics: ## - myRegistryKeySecretName ## pullSecrets: [] + + ## @param metrics.username String with username for the metrics exporter + ## If undefined the root user will be used for the metrics exporter + username: "" + ## @param metrics.password String with password for the metrics exporter + ## If undefined but metrics.username is defined, a random password will be generated + password: "" ## @param metrics.extraFlags String with extra flags to the metrics exporter ## ref: https://github.com/percona/mongodb_exporter/blob/master/mongodb_exporter.go ##