Not able to connect to mongodb helm chart bitnamio

85 Views Asked by At

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!

1

There are 1 best solutions below

0
Ashwani Singh On

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:

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
    rootUser: root
    rootPassword: pass@123

After updating the file, redeploy your MongoDB instance with the updated configuration.