So trying to create database in a replicaset using helm, using the following values in values.yaml
mongodb:
architecture: replicaset
auth:
rootPassword: "admin"
usernames:
- "user1"
passwords:
- "password1"
databases:
- "mydatabase"
replicaSetKey: myreplicaKey
Installing the chart using the following command:
helm install sam bitnami/mongodb --set architecture="replicaset",auth.rootPassword=password123 --values values.yaml
Log into my database:
export MONGODB_ROOT_PASSWORD=$(kubectl get secret --namespace default sam-mongodb -o jsonpath="{.data.mongodb-root-password}" | base64 --decode)
kubectl exec -ti sam-mongodb-0 -- mongo --authenticationDatabase admin -u root -p $MONGODB_ROOT_PASSWORD
But cannot see my database called "mydatabase" or specific user "user1" created, I can authenticate with admin user but trying to authenticate to "mydatabase" says failed, so unsure why this is happening, as it works in standalone but not a replicaset.
rs0:PRIMARY> show dbs
admin 0.000GB
config 0.000GB
local 0.000GB
rs0:PRIMARY> use admin
switched to db admin
rs0:PRIMARY> show users
{
"_id" : "admin.root",
"userId" : UUID("2b74bb99-5e18-434f-8350-9d54eb562230"),
"user" : "root",
"db" : "admin",
"roles" : [
{
"role" : "root",
"db" : "admin"
}
],
"mechanisms" : [
"SCRAM-SHA-1",
"SCRAM-SHA-256"
]
}
Was wondering if anyone knew what I might be doing wrong. Thanks
CodePudding user response:
Thought I might have resolved it, as noticed when i did this
helm install sam bitnami/mongodb --set architecture="replicaset",auth.rootPassword=password123 --values values.yaml --dry-run --debug
The computed values came back empty, so changed to the following and computed values were evaluated, going to test and ensure it works, but gives me a little confidence that values are now visible.
architecture: replicaset
replicaCount: 1
auth:
rootPassword: "admin"
username: "user1"
password: "password1"
database: "mydatabase"
replicaSetKey: capability123Key
did try to connect again and failed
rs0:PRIMARY> use mydatabase
switched to db mydatabase
rs0:PRIMARY> db.auth('user1','password1')
Error: Authentication failed.
CodePudding user response:
deleted the pvc and re-authenticated, and worked.
rs0:PRIMARY> use mydatabase
switched to db mydatabase
rs0:PRIMARY> db.auth('user1','password1')
1