mongodb-function
mongodb-function copied to clipboard
MongoError: command insert requires authentication
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