I setup mongo-express
in my local cluster and when connecting to it from localhost:8081
after successful authentication I see the message Turn on admin in config.js to view server stats
on the page. Searching for the issue I saw that it was related to the mongo-express:latest
image I was using, and that mongo-express:0.54.0
should be used instead from SO question Turn on admin in config.js to view server stats, but with it it doesn't connect to it at all.
I also tried mongo-express:0.54
image but still not connecting, mongo-express:1.0.0-alpha.4
authorise fince but still shows the Turn on ...
message.
mongo-express:latest logs
Welcome to mongo-express
------------------------
(node:7) [MONGODB DRIVER] Warning: Current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
Mongo Express server listening at http://0.0.0.0:8081
Server is open to allow connections from anyone (0.0.0.0)
mongo-express:0.54.0 logs
Waiting for mongo:27017...
/docker-entrypoint.sh: line 14: mongo: Name does not resolve
/docker-entrypoint.sh: line 14: /dev/tcp/mongo/27017: Invalid argument
Sun Jan 15 17:37:59 UTC 2023 retrying to connect to mongo:27017 (2/5)
/docker-entrypoint.sh: line 14: mongo: Name does not resolve
/docker-entrypoint.sh: line 14: /dev/tcp/mongo/27017: Invalid argument
Sun Jan 15 17:38:00 UTC 2023 retrying to connect to mongo:27017 (3/5)
/docker-entrypoint.sh: line 14: mongo: Name does not resolve
/docker-entrypoint.sh: line 14: /dev/tcp/mongo/27017: Invalid argument
Sun Jan 15 17:38:01 UTC 2023 retrying to connect to mongo:27017 (4/5)
/docker-entrypoint.sh: line 14: mongo: Name does not resolve
/docker-entrypoint.sh: line 14: /dev/tcp/mongo/27017: Invalid argument
Sun Jan 15 17:38:02 UTC 2023 retrying to connect to mongo:27017 (5/5)
/docker-entrypoint.sh: line 14: mongo: Name does not resolve
/docker-entrypoint.sh: line 14: /dev/tcp/mongo/27017: Invalid argument
I set ME_CONFIG_MONGODB_URL
, ME_CONFIG_BASICAUTH_USERNAME
and ME_CONFIG_BASICAUTH_PASSWORD
mongo-express values getting them from the mongo-rs-fixit-admin-user
secret that the operator creates by default which are correct as use them for connecting the node.js app to mongo. ME_CONFIG_MONGODB_ENABLE_ADMIN
is set to true.
I deploy mongo db replica set with the community operator and by not specifying a service it will use the one that the operator creates by default. The operator also creates a secret containing the connection strings for mongo. Is there something I'm doing wrong? Many thanks for your time and help. Cheers
mongo service created by the operator
vincenzocalia@vincenzos-MacBook-Air kubernetes_yaml_files % kubectl describe svc mongo-rs-svc
Name: mongo-rs-svc
Namespace: default
Labels: app=mongo-rs-svc
Annotations: <none>
Selector: app=mongo-rs-svc
Type: ClusterIP
IP Family Policy: SingleStack
IP Families: IPv4
IP: None
IPs: None
Port: mongodb 27017/TCP
TargetPort: 27017/TCP
Endpoints: 10.1.0.79:27017,10.1.0.80:27017
Session Affinity: None
Events: <none>
mongo secret created by the operator
Name: mongo-rs-fixit-admin-user
Namespace: default
Labels: <none>
Annotations: <none>
Type: Opaque
Data
====
connectionString.standardSrv: 108 bytes
password: 8 bytes
username: 10 bytes
connectionString.standard: 177 bytes
mongo deployment
apiVersion: mongodbcommunity.mongodb.com/v1
kind: MongoDBCommunity
metadata:
name: mongo-rs
namespace: default
spec:
members: 2
type: ReplicaSet
# mongo version
version: '5.0.5'
security:
authentication:
modes:
- SCRAM
users:
- name: admin-user
db: fixit
passwordSecretRef:
name: mongo-secret
roles:
- name: clusterAdmin
db: fixit
- name: userAdminAnyDatabase
db: fixit
scramCredentialsSecretName: my-scram-mg-fixit
additionalMongodConfig:
storage.wiredTiger.engineConfig.journalCompressor: zlib
statefulSet:
spec:
# You can specify a name for the service object created by the operator
# if specified no connection strings are generated !!??
# serviceName: mongo-rs-svc
# get them with kubectl -n default get secret mongo-rs-fixit-admin-user -o json and then decode them with echo "value" | base64 -d
template:
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- mongo-replicaset
topologyKey: 'kubernetes.io/hostname'
volumeClaimTemplates:
- metadata:
name: data-volume
spec:
accessModes:
- ReadWriteOnce
# - ReadWriteMany
storageClassName: mongo-sc-data
resources:
requests:
storage: 10Gi
- metadata:
name: logs-volume
spec:
accessModes:
- ReadWriteOnce
# - ReadWriteMany
storageClassName: mongo-sc-logs
resources:
requests:
storage: 2Gi
mongo-express deployment
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: mongo-express
name: mongo-express
namespace: default
spec:
selector:
matchLabels:
app: mongo-express
template:
metadata:
labels:
app: mongo-express
spec:
containers:
- name: mongo-express
# image: mongo-express # connects but Turn on admin in config.js to view server stats!
# image: mongo-express:latest # connects but Turn on admin in config.js to view server stats!
image: mongo-express:0.54.0
# image: mongo-express:0.54
imagePullPolicy: 'Always'
ports:
- containerPort: 8081
protocol: TCP
resources:
limits:
memory: '1Gi'
cpu: '100m'
env:
# - name: ME_CONFIG_MONGODB_SERVER
# value: mongo-rs-0.mongo-rs-svc.default.svc.cluster.local
- name: ME_CONFIG_MONGODB_URL
valueFrom:
secretKeyRef:
name: mongo-rs-fixit-admin-user
key: connectionString.standard
- name: ME_CONFIG_MONGODB_ENABLE_ADMIN
value: 'true'
- name: ME_CONFIG_BASICAUTH_USERNAME
valueFrom:
secretKeyRef:
name: mongo-rs-fixit-admin-user
key: username
- name: ME_CONFIG_BASICAUTH_PASSWORD
valueFrom:
secretKeyRef:
name: mongo-rs-fixit-admin-user
key: password
restartPolicy: 'Always'
mongo-express service
apiVersion: v1
kind: Service
metadata:
labels:
app: mongo-express
name: mongo-express
namespace: default
spec:
ports:
- name: http
port: 8081
targetPort: 8081
protocol: TCP
selector:
app: mongo-express
type: LoadBalancer
``