I have a values.yaml file to deploy mongo pod like below:
mongodb:
replicaCount: 1
image:
repository: bitnami/mongodb
tag: "5.0"
pullPolicy: IfNotPresent
service:
port: 27017
architecture: standalone
persistence:
enabled: true
existingClaim: "mongo-volume-claim"
# Additional pod annotations
podAnnotations: {}
# MongoDB credentials
auth:
enabled: true
rootPassword: pass@123
I exec to MongoDB pod, and then I run command to connect, I get issue like below:
mongodb-5c4b9b4659-8chzx:/$ mongosh --host 127.0.0.1 --authenticationDatabase admin -u root -p pass@123
Current Mongosh Log ID: 65a02b66abc6a4a15bd3535e
Connecting to: mongodb://<credentials>@127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&authSource=admin&appName=mongosh+2.1.1
MongoServerError: Authentication failed.
Any suggestions, please let me know!
You might not have specified the root username in your values.yaml file for the MongoDB Helm chart. The username is often set to root by default, but it's good practice to define it explicitly in your configuration.
Update your values.yaml by adding the rootUser field under the auth section:
After updating the file, redeploy your MongoDB instance with the updated configuration.