From 4e5edc4f95c5fcecbbc285b0aeee20c24183bef5 Mon Sep 17 00:00:00 2001 From: Steven Sheehy Date: Fri, 26 Oct 2018 11:34:45 -0500 Subject: [PATCH] [stable/mongodb-replicaset] Fix regression when using passwords with spaces (#8668) * Fix regression when using passwords with spaces Signed-off-by: Steven Sheehy * Changes from code review Signed-off-by: Steven Sheehy * Add terminationGracePeriodSeconds to README Signed-off-by: Steven Sheehy --- stable/mongodb-replicaset/Chart.yaml | 2 +- stable/mongodb-replicaset/README.md | 7 +++++++ stable/mongodb-replicaset/init/on-start.sh | 9 +++++---- .../templates/mongodb-statefulset.yaml | 1 + stable/mongodb-replicaset/values.yaml | 2 ++ 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/stable/mongodb-replicaset/Chart.yaml b/stable/mongodb-replicaset/Chart.yaml index da51322ce9..fbc86c48e4 100644 --- a/stable/mongodb-replicaset/Chart.yaml +++ b/stable/mongodb-replicaset/Chart.yaml @@ -1,6 +1,6 @@ name: mongodb-replicaset home: https://github.com/mongodb/mongo -version: 3.6.2 +version: 3.6.3 appVersion: 3.6 description: NoSQL document-oriented database that stores JSON-like documents with dynamic schemas, simplifying the integration of data in content-driven applications. diff --git a/stable/mongodb-replicaset/README.md b/stable/mongodb-replicaset/README.md index 0fb73fde51..53b0b56f98 100644 --- a/stable/mongodb-replicaset/README.md +++ b/stable/mongodb-replicaset/README.md @@ -51,6 +51,7 @@ The following table lists the configurable parameters of the mongodb chart and t | `persistentVolume.accessMode` | Persistent volume access modes | `[ReadWriteOnce]` | | `persistentVolume.size` | Persistent volume size | `10Gi` | | `persistentVolume.annotations` | Persistent volume annotations | `{}` | +| `terminationGracePeriodSeconds` | Duration in seconds the pod needs to terminate gracefully | `30` | | `tls.enabled` | Enable MongoDB TLS support including authentication | `false` | | `tls.cacert` | The CA certificate used for the members | Our self signed CA certificate | | `tls.cakey` | The CA key used for the members | Our key for the self signed CA certificate | @@ -117,6 +118,12 @@ keys `user` and `password`, that for the key file must contain `key.txt`. The u full `root` permissions but is restricted to the `admin` database for security purposes. It can be used to create additional users with more specific permissions. +To connect to the mongo shell with authentication enabled, use a command similar to the following (substituting values as appropriate): + +```shell +kubectl exec -it mongodb-replicaset-0 -- mongo mydb -u admin -p password --authenticationDatabase admin +``` + ## TLS support To enable full TLS encryption set `tls.enabled` to `true`. It is recommended to create your own CA by executing: diff --git a/stable/mongodb-replicaset/init/on-start.sh b/stable/mongodb-replicaset/init/on-start.sh index ba1bd3aa15..6a5a1bc440 100644 --- a/stable/mongodb-replicaset/init/on-start.sh +++ b/stable/mongodb-replicaset/init/on-start.sh @@ -43,15 +43,14 @@ retry_until() { local host="${1}" local command="${2}" local expected="${3}" - local creds="${admin_creds[@]}" + local creds=("${admin_creds[@]}") # Don't need credentials for admin user creation and pings that run on localhost if [[ "${host}" =~ ^localhost ]]; then - creds= + creds=() fi - until [[ $(mongo admin --host "${host}" ${creds} "${ssl_args[@]}" --quiet --eval "${command}") == "${expected}" ]]; do - log "Retrying ${command}" + until [[ $(mongo admin --host "${host}" "${creds[@]}" "${ssl_args[@]}" --quiet --eval "${command}") == "${expected}" ]]; do sleep 1 if (! ps "${pid}" &>/dev/null); then @@ -62,6 +61,8 @@ retry_until() { log "Timed out after ${timeout}s attempting to bootstrap mongod" exit 1 fi + + log "Retrying ${command} on ${host}" done } diff --git a/stable/mongodb-replicaset/templates/mongodb-statefulset.yaml b/stable/mongodb-replicaset/templates/mongodb-statefulset.yaml index df7947033d..9fadb580d1 100644 --- a/stable/mongodb-replicaset/templates/mongodb-statefulset.yaml +++ b/stable/mongodb-replicaset/templates/mongodb-statefulset.yaml @@ -38,6 +38,7 @@ spec: spec: securityContext: {{ toYaml .Values.securityContext | indent 8 }} + terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }} initContainers: - name: copy-config image: busybox diff --git a/stable/mongodb-replicaset/values.yaml b/stable/mongodb-replicaset/values.yaml index de7b0f78ce..8390ffd91b 100644 --- a/stable/mongodb-replicaset/values.yaml +++ b/stable/mongodb-replicaset/values.yaml @@ -93,6 +93,8 @@ persistentVolume: # Annotations to be added to the service serviceAnnotations: {} +terminationGracePeriodSeconds: 30 + tls: # Enable or disable MongoDB TLS support enabled: false