From c6d95c44880ed3b6eb36669eebbbdabe58937192 Mon Sep 17 00:00:00 2001 From: Stavros Kois <47820033+stavros-k@users.noreply.github.com> Date: Mon, 25 Apr 2022 14:23:57 +0300 Subject: [PATCH] fix(mongodb): set advertised hostname (#2560) * test * print hostname * change probe * check * check * again * ry * check * test * try again * again * again * localhost * test * test something * one more tet * publish address * emtpy * tets --- charts/dependency/mongodb/Chart.yaml | 2 +- .../mongodb/templates/create-oplog-user.yaml | 1 + charts/dependency/mongodb/values.yaml | 16 ++++++++++------ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/charts/dependency/mongodb/Chart.yaml b/charts/dependency/mongodb/Chart.yaml index 9a74729161d..7c563e26247 100644 --- a/charts/dependency/mongodb/Chart.yaml +++ b/charts/dependency/mongodb/Chart.yaml @@ -23,7 +23,7 @@ sources: - https://github.com/bitnami/bitnami-docker-mongodb - https://www.mongodb.com type: application -version: 0.1.5 +version: 0.1.6 annotations: truecharts.org/catagories: | - database diff --git a/charts/dependency/mongodb/templates/create-oplog-user.yaml b/charts/dependency/mongodb/templates/create-oplog-user.yaml index 5b229416ce6..e3c8823703b 100644 --- a/charts/dependency/mongodb/templates/create-oplog-user.yaml +++ b/charts/dependency/mongodb/templates/create-oplog-user.yaml @@ -15,6 +15,7 @@ data: # '.script' extension is just to avoid the bitnami init script to executing it. (bitnami executes .sh and .js files automatically) echo 'use '$MONGODB_DATABASE > /docker-entrypoint-initdb.d/createOpLogUser.script; echo 'db.createUser({user: "'$MONGODB_USERNAME'-oplog", pwd: "'$MONGODB_PASSWORD'", roles: [ { role: "read", db: "local" } ]})' >> /docker-entrypoint-initdb.d/createOpLogUser.script; + echo 'hostname()' >> /docker-entrypoint-initdb.d/createOpLogUser.script; echo "Command Generated!"; echo "Creating the user..."; diff --git a/charts/dependency/mongodb/values.yaml b/charts/dependency/mongodb/values.yaml index af9b34c235f..cb5b0fbaa62 100644 --- a/charts/dependency/mongodb/values.yaml +++ b/charts/dependency/mongodb/values.yaml @@ -26,6 +26,7 @@ controller: service: main: + publishNotReadyAddresses: true ports: main: port: 27017 @@ -61,7 +62,7 @@ probes: command: - /bin/bash - -ec - - echo "db.runCommand(\"ping\")" | mongo --host localhost --port 27017 ${MONGODB_DATABASE} --quiet + - echo "rs.status().ok" | mongo --host "${MONGODB_ADVERTISED_HOSTNAME}" -u root -p ${MONGODB_ROOT_PASSWORD} --port 27017 --quiet # -- Redainess probe configuration # @default -- See below @@ -78,7 +79,8 @@ probes: command: - /bin/bash - -ec - - echo "db.runCommand(\"ping\")" | mongo --host localhost --port 27017 ${MONGODB_DATABASE} --quiet + - echo "rs.status().ok" | mongo --host "${MONGODB_ADVERTISED_HOSTNAME}" -u root -p ${MONGODB_ROOT_PASSWORD} --port 27017 --quiet + # -- Startup probe configuration # @default -- See below startup: @@ -93,7 +95,7 @@ probes: command: - /bin/bash - -ec - - echo "db.runCommand(\"ping\")" | mongo --host localhost --port 27017 ${MONGODB_DATABASE} --quiet + - echo "rs.status().ok" | mongo --host "${MONGODB_ADVERTISED_HOSTNAME}" -u root -p ${MONGODB_ROOT_PASSWORD} --port 27017 --quiet mongodbPassword: "testpass" mongodbUsername: "test" @@ -102,7 +104,6 @@ mongodbRootPassword: "testroot" mongodbReplicasetMode: "primary" mongodbReplicasetName: "rs0" mongodbReplicasetKey: "testreplicasetkey" -mongodbAdvertisedHostname: "localhost" existingSecret: "" envValueFrom: @@ -124,5 +125,8 @@ env: MONGODB_DATABASE: "{{ .Values.mongodbDatabase }}" MONGODB_REPLICA_SET_MODE: "{{ .Values.mongodbReplicasetMode }}" MONGODB_REPLICA_SET_NAME: "{{ .Values.mongodbReplicasetName }}" - MONGODB_ADVERTISED_HOSTNAME: "{{ .Values.mongodbAdvertisedHostname }}" - MONGODB_ADVERTISED_PORT_NUMBER: "27017" + MONGODB_ADVERTISED_HOSTNAME: "{{ .Release.Name }}" + MONGODB_ADVERTISED_PORT_NUMBER: 27017 + MONGODB_INITIAL_PRIMARY_HOST: "{{ .Release.Name }}" + MONGODB_INITIAL_PRIMARY_PORT_NUMBER: 27017 + MONGODB_ENABLE_JOURNAL: true