0

I created a cluster in google cloud, deployed mongodb using help:

helm install my-release \
    --set auth.rootPassword=password,auth.databases[0]="database",auth.usernames[0]="root",architecture=replicaset,auth.replicaSetKey="keykfjhewq",auth.enabled=true \
    bitnami/mongodb

All is up, but when I exec into the pods and do rs.status() I get:

{
    "ok" : 0,
    "errmsg" : "command replSetGetStatus requires authentication",
    "code" : 13,
    "codeName" : "Unauthorized",
    "$clusterTime" : {
        "clusterTime" : Timestamp(1653254244, 1),
        "signature" : {
            "hash" : BinData(0,"EZ4IdSOklvKSvSmWVYU6Rr/VcaM="),
            "keyId" : NumberLong("7100667090272518150")
        }
    },
    "operationTime" : Timestamp(1653254244, 1)
}

What am I doing wrong?

1 Answer 1

5

This error is stating that everything is running correctly, however in order to access the replica sets you need to first authenticate (you told it to use auth in your --set values with auth.enabled=true). To authenticate you need to tell mongo to use admin privileges and log in with the username and password you set up:

use admin
db.auth(username, password)

This will get you authenticated and allowed to use the shell.

Sign up to request clarification or add additional context in comments.

2 Comments

Hey, firstly thanks for your help - once I exec into the pod and did the command it did init the rs, but is there a way to have it done in advanced with helm? it is not the best way to log manually inside it.. ;)
you might start with looking at a script template akin to this bitnami template where they configure replicaset configs at startup

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.