Closed Shilagrawal closed 2 years ago
@carrodher
I have referred #1655 however didnt get the initscript part completely as to where can i add the lines in values.yaml
You need to create an external k8s ConfigMap (CM) with the script you would like to execute, then use the common.initScriptsCM
parameter to pass the name of the CM you created to the Helm chart in order to be taken into account.
See https://github.com/bitnami/charts/tree/master/bitnami/mongodb-sharded#initialize-a-fresh-instance
Can user information be stored and accessed in a secret as well? Or just via a script in a configmap? @carrodher
There are several parameters such as
auth.existingSecret
to add existing secret with MongoDB(®) credentials (keys: mongodb-password
, mongodb-root-password
, mongodb-replica-set-key
)common.initScriptsSecret
which contains a ecret with init scripts to execute (for sensitive data)You can find all the parameters listed in the README or in the values.yaml
This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.
Due to the lack of activity in the last 5 days since it was marked as "stale", we proceed to close this Issue. Do not hesitate to reopen it later if necessary.
@carrodher Can you give an example for mongodb-passwords secrets and mongodb-databases values. I tried to initialize a database with config like this but it didn't work.
auth:
usernames: ["user"]
databases: ["init"]
Hi @leqduyvp,
Could you please provide more details about your issue?
Using those values and the latest value of the bitnami/mongodb
chart, I was able to access the init
database using the user
user:
I have no name!@test-mongodb-6b988f7799-skvhn:/$ mongosh mongodb://127.0.0.1:27017/init -u user -p 1QAzSVvf6l
Current Mongosh Log ID: 62d1671737d79147247ea3d6
Connecting to: mongodb://<credentials>@localhost/init?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.5.0
Using MongoDB: 5.0.9
Using Mongosh: 1.5.0
For mongosh info see: https://docs.mongodb.com/mongodb-shell/
init>
You can confirm the user creation by checking the MongoDB pod logs, you should see a message like this:
mongodb 13:02:12.35 INFO ==> Creating users...
mongodb 13:02:12.35 INFO ==> Creating root user...
mongodb 13:02:14.49 INFO ==> Creating user 'user'...
mongodb 13:02:16.63 INFO ==> Users created
If you have not provided a password using auth.passwords
, you can get the autogenerated password using the following command (replacing the values with <>
):
kubectl get secret --namespace <my_namespace> <my_release>-mongodb -o jsonpath="{.data.mongodb-passwords}" | base64 -d | awk -F',' '{print $1}'
Name and Version
Latest mongo db releae 4.1.12, 4..3
What steps will reproduce the bug?
I have been trying to see if I can create a database user in each pod during the helm install command itself earlier (2 months back ) I had used
mongodbUsername
,mongodbPassword
,mongodbaDatabase
which was easy to create a user in DB during the helm command itselfI am trying to find ways to create one in the most effective way so that if I have more shards (say 16 or all) all of them are taken care of.
MongoDB sharded deployment: the command I had been using is not working now for custom DB users:
What is the expected behavior?
Looking forward to a way to create a custom DB user, password, and database name for all pods in one go.
What do you see instead?
custom username /cred and details don't take effect at startup