Search code examples
mongodbkuberneteskubernetes-helm

Can't login to mongo using root password after installing from helm


I installed mongodb on kubernetes using helm:

helm install mongo bitnami/mongodb

now i'm trying to connect using the root password I got using this command

# kubectl get secret --namespace default mongo-mongodb -o jsonpath="{.data.mongodb-root-pa
ssword}" | base64 --decode
AXMCSkdNm6

using the root password, with the user root, i can't login. I get Authentication Failed error. trying in my mongodb desktop client, also tried inside of mongo pod:

$ mongo admin --username root --password AXMCSkdNm6
MongoDB shell version v4.4.1
connecting to: mongodb://127.0.0.1:27017/admin?compressors=disabled&gssapiServiceName=mongodb
Error: Authentication failed. :
connect@src/mongo/shell/mongo.js:374:17
@(connect):2:6
exception: connect failed
exiting with code 1

What am I doing wrong?

Update:

I managed to reproduce it always on clean install of k8s/helm:

  1. install mongo the first time - authentication works perfectly
  2. delete mongo via helm delete mongo
  3. install mongo now - authentication fails

Solution

  • OK, I found out the issue after a very long time...

    MongoDB authentication stopped working after I deleted the release and created a new release. The reason was that I used the same persistent storage for both releases. So, when I deleted the first release the data was not deleted, and when I started a new release, it got confused, since it used the old data from the previous release...

    When I delete all the data in the persistent storage when deleting the release - everything worked correctly.