Install MongoDB on Kubernetes using bitnami Charts

Hello,

I am trying to install MongoDB using bitnami charts. Running into authentication error between arbiter and mongodb replicatset. Would appreciate any pointers or links to docs that walks through the process.
Using the following chart:

- name: mongodb
  version: "13.6.2"
  repository: https://charts.bitnami.com/bitnami

Values.yaml file:

resources: &resources
  limits:
    cpu: 100m
    memory: 500Mi
  requests:
    cpu: 100m
    memory: 100Mi

mongodb:
  architecture: replicaset
  setParameter:
    enableLocalhostAuthBypass: true
  auth:
    existingSecret: test-mongodb
    databases: [test-db1]
    usernames: [test-user1]
  replicaSetName: test-mongodb
  directoryPerDB: true
  resources: *resources
  persistence:
    storageClass: encrypted-gp2
    size: 20Gi
  pdb:
    create: true
  labels: &labels
    app: test-mongodb
    component: db
  podAnnotations:
    chaos.alpha.kubernetes.io/enabled: "false"
  podLabels: *labels
  arbiter:
    resources: *resources
    labels: *labels
    podLabels: *labels
    podAnnotations:
      chaos.alpha.kubernetes.io/enabled: "false"
  metrics:
    enabled: true
    resources: *resources
    serviceMonitor:
      additionalLabels: *labels

K8s secet:

Data
====
mongodb-passwords:        70 bytes
mongodb-replica-set-key:  668 bytes
mongodb-root-password:    68 bytes

I am getting the following error in arbiter-0:

MongoServerError: Authentication failed.

And the following error in mongodb-0:

{"msg":"Supported SASL mechanisms requested for unknown user","attr":{"user":{"user":"root","db":"admin"}}}
{"msg":"Authentication failed","attr":{"mechanism":"SCRAM-SHA-256","speculative":true,"principalName":"root","authenticationDatabase":"admin","remote":"127.0.0.1:55432","extraInfo":{},"error":"UserNotFound: Could not find user \"root\" for db \"admin\""}}
{"msg":"Authentication failed","attr":{"mechanism":"SCRAM-SHA-1","speculative":false,"principalName":"root","authenticationDatabase":"admin","remote":"127.0.0.1:55432","extraInfo":{},"error":"UserNotFound: Could not find user \"root\" for db \"admin\""}}

Can someone please help.

Thank you, Ahmed

Could the issue be the default DBs are not created, hence authentication is failng?

Hi @A_A11 and welcome to the MongoDB Community forum!!

The currect version you are using seems to be old while the latest version of the bitnami is 13.9.2, hence firstly would recommend you to upgrade to the latest version.
In addition, we do not have the right expertise and the ownership for the same, I would recommend you using the Bitnami Support is the issue persists.

However, Yes, it appears to be an authentication issue as the arbiter is trying to connect to db using the root user name which has not been defined but the admin, local, config databases are created by default as a part of the deployment process.

Please consider looking at the documentation for create user https://www.mongodb.com/docs/manual/reference/method/db.createUser/ for further information.

However, if you still encounter any issue after creating the user on the admin database, please share the referred documentation for deployment with the relevant yaml files to test it in my local environment.

You can also refer to the Bitnami documentation to more details.

Let us know if you have any further questions.

Best Regards
Aasawari