简体   繁体   English

尝试连接 MongoDB Kubernetes 集群(使用 MongoDB 社区 Z301136395F0181737 创建)时,mongo-express 的身份验证问题

[英]Authentication Problem with mongo-express when trying to connect with MongoDB Kubernetes Cluster (created with MongoDB Community Kubernetes Operator)

I set up a Minikube-Cluster with the MongoDB Community Kubernetes Operator.我使用 MongoDB 社区 Kubernetes 操作员设置了 Minikube-Cluster。 To view the content i want to set up a mongo-express Instance which connects to the Mongo-Cluster/ReplicaSet.要查看内容,我想设置一个连接到 Mongo-Cluster/ReplicaSet 的 mongo-express 实例。 But if I apply the Deployment the Container always fails with:但是,如果我应用部署,容器总是会失败:

mongo-express_1  | Waiting for localhost:27017...
mongo-express_1  | Welcome to mongo-express
mongo-express_1  | ------------------------
mongo-express_1  | 
mongo-express_1  | 
mongo-express_1  | Mongo Express server listening at http://0.0.0.0:8081
mongo-express_1  | Server is open to allow connections from anyone (0.0.0.0)
mongo-express_1  | basicAuth credentials are "admin:pass", it is recommended you change this in your config.js!
mongo-express_1  | Database connected
mongo-express_1  | Admin Database connected
mongo-express_1  | Error [MongoError]: Authentication failed.
mongo-express_1  |     at Function.MongoError.create (/node_modules/mongodb-core/lib/error.js:31:11)
mongo-express_1  |     at /node_modules/mongodb-core/lib/connection/pool.js:483:72
mongo-express_1  |     at authenticateStragglers (/node_modules/mongodb-core/lib/connection/pool.js:429:16)
mongo-express_1  |     at Connection.messageHandler (/node_modules/mongodb-core/lib/connection/pool.js:463:5)
mongo-express_1  |     at Socket.<anonymous> (/node_modules/mongodb-core/lib/connection/connection.js:319:22)
mongo-express_1  |     at Socket.emit (events.js:314:20)
mongo-express_1  |     at addChunk (_stream_readable.js:297:12)
mongo-express_1  |     at readableAddChunk (_stream_readable.js:272:9)
mongo-express_1  |     at Socket.Readable.push (_stream_readable.js:213:10)
mongo-express_1  |     at TCP.onStreamRead (internal/stream_base_commons.js:188:23) {
mongo-express_1  |   operationTime: Timestamp { _bsontype: 'Timestamp', low_: 1, high_: 1611234788 },
mongo-express_1  |   ok: 0,
mongo-express_1  |   errmsg: 'Authentication failed.',
mongo-express_1  |   code: 18,
mongo-express_1  |   codeName: 'AuthenticationFailed',
mongo-express_1  |   '$clusterTime': {
mongo-express_1  |     clusterTime: Timestamp { _bsontype: 'Timestamp', low_: 1, high_: 1611234788 },
mongo-express_1  |     signature: { hash: [Binary], keyId: [Long] }
mongo-express_1  |   }
mongo-express_1  | }
mongo-express_1  | unable to list databases
mongo-express_1  | Error [MongoError]: command listDatabases requires authentication
mongo-express_1  |     at Function.MongoError.create (/node_modules/mongodb-core/lib/error.js:31:11)
mongo-express_1  |     at /node_modules/mongodb-core/lib/connection/pool.js:483:72
mongo-express_1  |     at authenticateStragglers (/node_modules/mongodb-core/lib/connection/pool.js:429:16)
mongo-express_1  |     at Connection.messageHandler (/node_modules/mongodb-core/lib/connection/pool.js:463:5)
mongo-express_1  |     at Socket.<anonymous> (/node_modules/mongodb-core/lib/connection/connection.js:319:22)
mongo-express_1  |     at Socket.emit (events.js:314:20)
mongo-express_1  |     at addChunk (_stream_readable.js:297:12)
mongo-express_1  |     at readableAddChunk (_stream_readable.js:272:9)
mongo-express_1  |     at Socket.Readable.push (_stream_readable.js:213:10)
mongo-express_1  |     at TCP.onStreamRead (internal/stream_base_commons.js:188:23) {
mongo-express_1  |   operationTime: Timestamp { _bsontype: 'Timestamp', low_: 1, high_: 1611234788 },
mongo-express_1  |   ok: 0,
mongo-express_1  |   errmsg: 'command listDatabases requires authentication',
mongo-express_1  |   code: 13,
mongo-express_1  |   codeName: 'Unauthorized',
mongo-express_1  |   '$clusterTime': {
mongo-express_1  |     clusterTime: Timestamp { _bsontype: 'Timestamp', low_: 1, high_: 1611234788 },
mongo-express_1  |     signature: { hash: [Binary], keyId: [Long] }
mongo-express_1  |   }
mongo-express_1  | }

For the ease of testing I used docker-compose to start mango-express and created a Port-Forwarding to access the cluster.为了便于测试,我使用 docker-compose 启动 mango-express 并创建了一个端口转发来访问集群。

Versions:版本:

  • MongoDB Cluster: tried 4.2.6 and 4.4.3 MongoDB 集群:试过 4.2.6 和 4.4.3
  • mongo-express: 0.54.0蒙戈快递:0.54.0

Here the Deployment/Service I use for MongoDB Cluster creation:这里是我用于 MongoDB 集群创建的部署/服务:

---
apiVersion: mongodb.com/v1
kind: MongoDB
metadata:
  name: example-mongodb
spec:
  members: 3
  type: ReplicaSet
  version: "4.4.3"
  security:
    authentication:
      modes: ["SCRAM"]
  users:
    - name: mongoadmin
      db: admin
      passwordSecretRef: # a reference to the secret that will be used to generate the user's password
        name: mongoadmin-password
      roles:
        - name: root
          db: admin
      scramCredentialsSecretName: my-scram

# the user credentials will be generated from this secret
# once the credentials are generated, this secret is no longer required
---
apiVersion: v1
kind: Secret
metadata:
  name: mongoadmin-password
type: Opaque
stringData:
  password: mongoadmin                                 

And here the compose-file i use for mongo-express:这里是我用于 mongo-express 的 compose-file:

version: '3.8'

services:
  mongo-express:
    image: mongo-express
    restart: on-failure
    ports:
      - 8081:8081
    network_mode: host
    environment:
      ME_CONFIG_MONGODB_SERVER: localhost
      ME_CONFIG_MONGODB_ADMINUSERNAME: mongoadmin
      ME_CONFIG_MONGODB_ADMINPASSWORD: mongoadmin

The thing is, that if I setup up a mongo (4.4.3) container with mongo-express via docker-compose everything works fine...问题是,如果我通过 docker-compose 使用 mongo-express 设置一个 mongo (4.4.3) 容器,一切正常......

Does anybody have a clue whats going on?有人知道发生了什么吗?

I have build the docker image from the alpha version of mongo-express https://github.com/mongo-express/mongo-express/tree/v1.0.0-alpha.1我已经从 mongo-express https://github.com/mongo-express/mongo-express/tree/v1.0.0-alpha.1的 alpha 版本构建了 docker 图像

Here is the image uncl3mar1k/mongo-express:v1.0.0-alpha.1这是图像uncl3mar1k/mongo-express:v1.0.0-alpha.1

It seems to work well with authentication, but I noticed that it has an issue with pagening.它似乎与身份验证配合得很好,但我注意到它在分页方面存在问题。 (if you have a lot of collections and try to go through pages, you will notice that data about collections did not changes) (如果您有很多 collections 并尝试通过页面访问 go,您会注意到有关 collections 的数据没有变化)

Update: there is a newer version v1.0.0-alpha.3 looks like all issues was fixed here.更新:有一个更新的版本v1.0.0-alpha.3看起来所有问题都在这里修复了。 Please take a look to new image: staslb/mongo-express:v1.0.0-alpha.3请看一下新图像: staslb/mongo-express:v1.0.0-alpha.3

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我如何在Kubernetes集群上使用mongo-express或RockMongo之类的MongoDB GUI工具 - How I can use MongoDB GUI tool like mongo-express or RockMongo on Kubernetes cluster mongo-express 没有连接到 mongodb - mongo-express does not connect to mongodb MongoDB 社区 Kube.netes 运营商连接 - MongoDB Community Kubernetes Operator Connection 在 k8s 中连接 mongo-express 到 mongoDb 失败 - Failed to connect mongo-express to mongoDb in k8s 如何在 docker 中连接 linux-host 和 mongo-express 上的 mongodb - How to connect mongodb on linux-host and mongo-express in docker Mongo-Express 容器可以通过 TLS 连接到 MongoDB 吗? - Can a Mongo-Express container connect to MongoDB with TLS? MongoDB Community Kubernetes Operator 和自定义持久卷 - MongoDB Community Kubernetes Operator and Custom Persistent Volumes 如果凭据存储为 Kubernetes 机密,Mongo-express 基本 Web 身份验证不起作用 - Mongo-express base web authentication not working if credentials are stored as Kubernetes secrets 如何从 Kubernetes 集群外部连接到 Mongodb - How to connect to Mongodb from outside Kubernetes cluster 无法连接到Kubernetes群集中的mongodb服务 - Cannot connect to a mongodb service in a Kubernetes cluster
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM