[bitnami/mongodb] Configurable admin/root user name (#7229)

* Configurable admin/root user name

* Adjust exporter uri

* Update bitnami/mongodb/values.yaml

Co-authored-by: Juan Ariza Toledano <juanariza@vmware.com>

* Adding readme metadata

Co-authored-by: Juan Ariza Toledano <juanariza@vmware.com>
This commit is contained in:
Axel Köhler
2021-09-13 15:55:10 +02:00
committed by GitHub
co-authored by Juan Ariza Toledano
parent 7ca2a4bb91
commit d7ef3be579
10 changed files with 26 additions and 2 deletions
+1 -1
View File
@@ -26,4 +26,4 @@ name: mongodb
sources:
- https://github.com/bitnami/bitnami-docker-mongodb
- https://mongodb.org
version: 10.25.2
version: 10.26.0
+1
View File
@@ -97,6 +97,7 @@ Refer to the [chart documentation for more information on each of these architec
| `architecture` | MongoDB&reg; architecture (`standalone` or `replicaset`) | `standalone` |
| `useStatefulSet` | Set to true to use a StatefulSet instead of a Deployment (only when `architecture=standalone`) | `false` |
| `auth.enabled` | Enable authentication | `true` |
| `auth.rootUser` | MongoDB&reg; root user | `root` |
| `auth.rootPassword` | MongoDB&reg; root password | `""` |
| `auth.username` | MongoDB&reg; custom user (mandatory if `auth.database` is set) | `""` |
| `auth.password` | MongoDB&reg; custom user password | `""` |
+1 -1
View File
@@ -346,7 +346,7 @@ Validate values of MongoDB&reg; 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 "root:$(echo $MONGODB_ROOT_PASSWORD | sed -r \"s/@/%40/g;s/:/%3A/g\")@" "" .Values.auth.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 -}}
{{- end -}}
@@ -166,6 +166,8 @@ spec:
- name: MONGODB_ADVERTISED_HOSTNAME
value: "$(MY_POD_NAME).$(K8S_SERVICE_NAME).$(MY_POD_NAMESPACE).svc.{{ .Values.clusterDomain }}"
{{- if .Values.auth.enabled }}
- name: MONGODB_INITIAL_PRIMARY_ROOT_USER
value: {{ .Values.auth.rootUser | quote }}
- name: MONGODB_INITIAL_PRIMARY_ROOT_PASSWORD
valueFrom:
secretKeyRef:
@@ -401,6 +401,8 @@ spec:
{{- end }}
env:
{{- if .Values.auth.enabled }}
- name: MONGODB_ROOT_USER
value: {{ .Values.auth.rootUser | quote }}
- name: MONGODB_ROOT_PASSWORD
valueFrom:
secretKeyRef:
@@ -87,6 +87,7 @@ data:
else
echo "Pod name doesn't match initial primary pod name, configuring node as a secondary"
export MONGODB_REPLICA_SET_MODE="secondary"
export MONGODB_INITIAL_PRIMARY_ROOT_USER="$MONGODB_ROOT_USER"
export MONGODB_INITIAL_PRIMARY_ROOT_PASSWORD="$MONGODB_ROOT_PASSWORD"
export MONGODB_INITIAL_PRIMARY_PORT_NUMBER="$MONGODB_PORT_NUMBER"
export MONGODB_ROOT_PASSWORD="" MONGODB_USERNAME="" MONGODB_DATABASE="" MONGODB_PASSWORD=""
@@ -118,6 +119,7 @@ data:
echo "Advertised Hostname: $MONGODB_ADVERTISED_HOSTNAME"
echo "Configuring node as a hidden node"
export MONGODB_REPLICA_SET_MODE="hidden"
export MONGODB_INITIAL_PRIMARY_ROOT_USER="$MONGODB_ROOT_USER"
export MONGODB_INITIAL_PRIMARY_ROOT_PASSWORD="$MONGODB_ROOT_PASSWORD"
export MONGODB_INITIAL_PRIMARY_PORT_NUMBER="$MONGODB_PORT_NUMBER"
export MONGODB_ROOT_PASSWORD="" MONGODB_USERNAME="" MONGODB_DATABASE="" MONGODB_PASSWORD=""
@@ -257,6 +257,8 @@ spec:
name: {{ include "mongodb.secretName" . }}
key: mongodb-password
{{- end }}
- name: MONGODB_ROOT_USER
value: {{ .Values.auth.rootUser | quote }}
- name: MONGODB_ROOT_PASSWORD
valueFrom:
secretKeyRef:
@@ -435,6 +437,8 @@ spec:
{{- end }}
env:
{{- if .Values.auth.enabled }}
- name: MONGODB_ROOT_USER
value: {{ .Values.auth.rootUser | quote }}
- name: MONGODB_ROOT_PASSWORD
valueFrom:
secretKeyRef:
@@ -211,6 +211,8 @@ spec:
name: {{ include "mongodb.secretName" . }}
key: mongodb-password
{{- end }}
- name: MONGODB_ROOT_USER
value: {{ .Values.auth.rootUser | quote }}
- name: MONGODB_ROOT_PASSWORD
valueFrom:
secretKeyRef:
@@ -373,6 +375,8 @@ 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 }}
- name: MONGODB_ROOT_USER
value: {{ .Values.auth.rootUser | quote }}
- name: MONGODB_ROOT_PASSWORD
valueFrom:
secretKeyRef:
+6
View File
@@ -18,6 +18,12 @@
"title": "Enable Authentication",
"form": true
},
"rootUser": {
"type": "string",
"title": "MongoDB&reg; admin user",
"form": true,
"description": "Name of the admin user. Default is root"
},
"rootPassword": {
"type": "string",
"title": "MongoDB&reg; admin password",
+3
View File
@@ -133,6 +133,9 @@ auth:
## ref: https://docs.mongodb.com/manual/tutorial/enable-authentication/
##
enabled: true
## @param auth.rootUser MongoDB&reg; root user
##
rootUser: root
## @param auth.rootPassword MongoDB&reg; root password
## ref: https://github.com/bitnami/bitnami-docker-mongodb/blob/master/README.md#setting-the-root-password-on-first-run
##