使用 Helm 在 Kubernetes 中安装 Mongodb

Installing Mongodb in Kubernetes using Helm

我在我的 Kubernetes 集群中使用 Helm 安装了 mongodb。 https://github.com/kubernetes/charts/tree/master/stable/mongodb

它工作正常,让我连接到数据库。但是我一登录到mongo服务器就不能做任何操作了。这是我在尝试查看集合时遇到的错误。

    > show collections;
2018-04-19T18:03:59.818+0000 E QUERY    [js] Error: listCollections failed: {
    "ok" : 0,
    "errmsg" : "not authorized on test to execute command { listCollections: 1.0, filter: {}, $db: \"test\" }",
    "code" : 13,
    "codeName" : "Unauthorized"
} :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype._getCollectionInfosCommand@src/mongo/shell/db.js:942:1
DB.prototype.getCollectionInfos@src/mongo/shell/db.js:954:19
DB.prototype.getCollectionNames@src/mongo/shell/db.js:965:16
shellHelper.show@src/mongo/shell/utils.js:836:9
shellHelper@src/mongo/shell/utils.js:733:15
@(shellhelp2):1:1

我正在使用

作为 root 用户登录
mongo -p password

不知道为什么连root用户都没有权限做任何事

我发现了问题。默认情况下,MongoDB 使用 admin DB 进行身份验证,但在 helm chart 中,身份验证 DB 与您使用它创建的 DB 相同。所以如果我创建一个名为 test 的数据库,身份验证数据库也将是 test