Can't connect with any user to any db


first of all, i am a completely newbie whit mongo and kubernetes. Sorry if i miss important info!

I installed all using this manual Install Percona server for MongoDB on Kubernetes

I only change, cluster name from my-cluster-name on avery *.yaml file to mongo-bo. Also, i change passwords on secrets.yaml and from cr.yaml the option to make a load balancer.

I ended installation with no errors, load balancer works fine, i can access from an external computer using mongo --host xx.xx.xx.xx

But when i tried to list dbs, i get this error
mongos> use admin
switched to db admin
mongos> show users
2022-03-18T09:05:05.582+0100 E QUERY [thread1] Error: command usersInfo requires authentication :

if i use mongo --host xx.xx.xx.xx -u userAdmin -p anypassword
mongo ask me again form password. But i can write anything, rigth password or ramdom characters and always get the same error

$ mongo -host XX.XX.XX.XX -u useradmin -p asdasdas
MongoDB shell version: 3.2.11
Enter password:
connecting to: XX.XX.XX.XX:27017/asdasdas
2022-03-18T09:07:13.209+0100 E QUERY [thread1] Error: Authentication failed. :

exception: login failed

and finally i found this part of manual, Users

i can start percona-client, but i cant connect

kubectl run -i --rm --tty percona-client --image=percona/percona-server-mongodb:4.4.10-11 --restart=Never – bash -il

percona-client:/$ mongo “mongodb://userAdmin:userAdmin123456@my-cluster-name-mongos..svc.cluster.local/admin?ssl=false”
If you don’t see a command prompt, try pressing enter.
[mongodb@percona-client /]$ mongo
Percona Server for MongoDB shell version v4.4.10-11
connecting to: mongodb://
Error: couldn’t connect to server, connection attempt failed: SocketException: Error connecting to :: caused by :: Connection refused :
exception: connect failed
exiting with code 1

don’t matter which user/pass i use.

Any help please???

Thanks in advance

1 Like

Hello @jpuntas ,

we create two system users that you can use to connect to MongoDB and do something:

userAdmin can create new users granting access to databases and other magic.

About connecting to DB, first of I see the typo in here:

percona-client:/$ mongo “mongodb://userAdmin:userAdmin123456@my-cluster-name-mongos..svc.cluster.local/admin?ssl=false”

I think you skipped the namespace and also should use your cluster name (is it mongo-bo)?. So it should be something like this for default namespace:

percona-client:/$ mongo “mongodb://userAdmin:userAdmin123456@mongo-bo-mongos.default.svc.cluster.local/admin?ssl=false”

If it does not help - please show me your kubectl get services and I will try to help more.

1 Like