pkdone/minikube-mongodb-demo

Authentication failure

Opened this issue · 10 comments

After running generate.sh and when I try to run,
db.getSiblingDB('admin').auth("main_admin", "abc123");
I get,
"Error: Authentication failed."
But the pod is in running state.

Any updates? I'm having the same problem!

Have you ran ./configure_repset_auth.sh abc123(step 3 here)? The description just says you ran generate.sh?

I get the same error: Error: Authentication failed.

I ran ./generate.sh and then ./configure_repset_auth.sh abc123
Generate ran fine and pods and service were generated. But configure_repset_auth had this following output:

Configuring the MongoDB Replica Set
MongoDB shell version v4.0.0
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 4.0.0
{
	"ok" : 0,
	"errmsg" : "No host described in new configuration 1 for replica set MainRepSet maps to this node",
	"code" : 93,
	"codeName" : "InvalidReplicaSetConfig"
}
Waiting for the Replica Set to initialise...
MongoDB shell version v4.0.0
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 4.0.0
{
	"ok" : 0,
	"errmsg" : "no replset config has been received",
	"code" : 94,
	"codeName" : "NotYetInitialized"
}
Creating user: 'main_admin'
MongoDB shell version v4.0.0
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 4.0.0
2018-07-29T23:37:05.131+0000 E QUERY    [js] Error: couldn't add user: not master :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.createUser@src/mongo/shell/db.js:1491:15
@(shell eval):1:1
command terminated with exit code 252


I'm also facing this issue and maybe found a solution. https://stackoverflow.com/questions/41783700/when-creating-first-admin-user-on-mongdb-cluster-getting-error-couldnt-add-use/41789745

But how could this be applied to the config file?

@ariel123 @Ninerian Did you found any solution?

I have the same issue.

I had the same problem as @ariel123 @Ninerian and think I worked through it. I ended up, via kubectl and minikube, opening bash on one of the mongodb pods

kubectl exec -it mongod-0 -c mongod-container bash

Once in there, per the stackoverflow link (https://stackoverflow.com/a/41789745/278763) I disabled authorization by editing the mongo.conf file (I think I had to copy the .orig file to just mongo.conf) and stopped/started the mongo service. I also had to apt-get install an editor - nothing seemed to be installed by default.

After that came back up I tried runinng the configure script again and it seemed to work. Somewhere in there I think I also ran just rs.initiate() by itself to try and init something and I think that did something, but then it let me run the whole configure repset script in general.

fzhan commented

This means the image used has to be updated. Or could we leverage ConfigMap?

@laurogripa Maybe you created the cluster on a different namespace. I had this issue for ./configure_repset_auth.sh script, Just change default to your namespace. As Repset Members need your services.
Change host to host: "mongod-1.mongodb-service.**mongodb**.svc.cluster.local:27017 where mongodb is your namespace

@laurogripa Maybe you created the cluster on a different namespace. I had this issue for ./configure_repset_auth.sh script, Just change default to your namespace. As Repset Members need your services. Change host to host: "mongod-1.mongodb-service.**mongodb**.svc.cluster.local:27017 where mongodb is your namespace

I was facing the same issue. I just changed the default namespace to mynamespace as follows: host : "mongod-0.mongodb-service.default.svc.cluster.local:27017" to host : "mongod-0.mongodb-service.mynamespace.svc.cluster.local:27017"