I am deploying a mongo-express pod in my kubernetes cluster in order to have a quick view of my db data.
I can use mongo-express normally if I do not config basic auth.
However, when I add the basic auth configuration to my Deployment yaml file. It has the below error that showing on website directly.
Error: Server Error
The server encountered a temporary error and could not complete your request.
Please try again in 30 seconds.
I am using Kubernetes cluster and I use Ingress to expose mongo-express. Therefore, I access it with this url: db.myapp.com
This is my Deployment 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
If I added ME_CONFIG_BASICAUTH_USERNAME and ME_CONFIG_BASICAUTH_PASSWORD, it will become the above error.
And even if the basic auth config and error exist, I check the logs for this pod are:
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
so there is no error in the pod