我正在我的 kubernetes 集群中部署一个 mongo-express pod,以便快速查看我的数据库数据。
如果我不配置基本身份验证,我可以正常使用 mongo-express。
但是,当我将基本身份验证配置添加到我的部署 yaml 文件时。它有以下错误直接显示在网站上。
Error: Server Error
The server encountered a temporary error and could not complete your request.
Please try again in 30 seconds.
我正在使用 Kubernetes 集群,并使用Ingress公开 mongo-express。因此,我使用以下网址访问它:db.myapp.com
这是我的部署 yml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: mongo-express
labels:
app: mongo-express
spec:
replicas: 1
selector:
matchLabels:
app: mongo-express
template:
metadata:
labels:
app: mongo-express
spec:
containers:
- name: mongo-express
image: mongo-express
ports:
- containerPort: 8081
env:
- name: ME_CONFIG_MONGODB_SERVER
valueFrom:
configMapKeyRef:
name: mongodb-configmap
key: database_url
- name: ME_CONFIG_BASICAUTH_USERNAME
value: admin
- name: ME_CONFIG_BASICAUTH_PASSWORD
value: mypassword
---
apiVersion: v1
kind: Service
metadata:
name: mongo-express-service
annotations:
cloud.google.com/neg: '{"ingress": true}'
spec:
ports:
- port: 8081
protocol: TCP
selector:
app: mongo-express
type: NodePort
---
My ingress:
...
- host: db.myapp.com
http:
paths:
- backend:
serviceName: mongo-express-service
servicePort: 8081
如果我添加了ME_CONFIG_BASICAUTH_USERNAME和ME_CONFIG_BASICAUTH_PASSWORD,它将成为上述错误。
即使存在基本身份验证配置和错误,我也会检查此 pod 的日志:
Welcome to mongo-express
------------------------
Mongo Express server listening at http://0.0.0.0:8081
Server is open to allow connections from anyone (0.0.0.0)
basicAuth credentials are "admin:pass", it is recommended you change this in your config.js!
Database connected
Admin Database connected
所以pod中没有错误