mongodb-function icon indicating copy to clipboard operation
mongodb-function copied to clipboard

MongoError: command insert requires authentication

Open Qolzam opened this issue 6 years ago • 0 comments

Problem

Following instruction in README but I got MongoError: command insert requires authentication.

Suggesting a Solution

I tried to install mogodb with username/password following stable/mongodb chart documentation.

$ helm install --name openfaas-db \
  --namespace openfaas-fn \
  --set persistence.enabled=false,mongodbRootPassword=secretpassword,mongodbUsername=my-user,mongodbPassword=my-password,mongodbDatabase=clients \
    stable/mongodb

Change two lines of handle.js to:

const mongoURL = `mongodb://${username}:${password}@${url} + ":27017/clients`
....

MongoClient.connect(mongoURL,{useNewUrlParser: true, useUnifiedTopology: true} ,...

Change stack.yml:

      url: openfaas-db-mongodb.openfaas-fn.svc.cluster.local
      username: my-user
      password: my-password

Qolzam avatar Sep 02 '19 08:09 Qolzam