Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does the mongo-express-service external service in my browser require a username and password?

I am currently working through the following Kubernetes tutorial: https://www.youtube.com/watch?v=X48VuDVv0do&t=2437s&ab_channel=TechWorldwithNana

I am using an 2022 Macbook Air with an M2 chip, so Hyperkit is not compatible, so instead I am using Qemu. My problem is this: when I run the external service 'mongo-express-service' with Minikube, the browswer opens, but I am asked to sign in. See 1:44:40 of the video above to see which step I am on. I am using the exact files from Nana's repo, so I think it has something to do with me using Qemu and having to install socket_vmnet to run the external service. This is what I get in the browser when I run the external service. This is what I get in my terminal when I run the external service.

These are my files:

mongo.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: mongodb-deployment
  labels:
    app: mongodb
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mongodb
  template:
    metadata:
      labels:
        app: mongodb
    spec:
      containers:
      - name: mongodb
        image: mongo
        ports:
        - containerPort: 27017
        env:
        - name: MONGO_INITDB_ROOT_USERNAME
          valueFrom:
            secretKeyRef:
              name: mongodb-secret
              key: mongo-root-username
        - name: MONGO_INITDB_ROOT_PASSWORD
          valueFrom: 
            secretKeyRef:
              name: mongodb-secret
              key: mongo-root-password
---
apiVersion: v1
kind: Service
metadata:
  name: mongodb-service
spec:
  selector:
    app: mongodb
  ports:
    - protocol: TCP
      port: 27017
      targetPort: 27017

mongo-express.yaml

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_ADMINUSERNAME
          valueFrom:
            secretKeyRef:
              name: mongodb-secret
              key: mongo-root-username
        - name: ME_CONFIG_MONGODB_ADMINPASSWORD
          valueFrom: 
            secretKeyRef:
              name: mongodb-secret
              key: mongo-root-password
        - name: ME_CONFIG_MONGODB_SERVER
          valueFrom: 
            configMapKeyRef:
              name: mongodb-configmap
              key: database_url
---
apiVersion: v1
kind: Service
metadata:
  name: mongo-express-service
spec:
  selector:
    app: mongo-express
  type: LoadBalancer  
  ports:
    - protocol: TCP
      port: 8081
      targetPort: 8081
      nodePort: 30000

mongo-configmap.yaml

apiVersion: v1
kind: ConfigMap
metadata:
  name: mongodb-configmap
data:
  database_url: mongodb-service

mongo-secret.yaml

apiVersion: v1
kind: Secret
metadata:
    name: mongodb-secret
type: Opaque
data:
    mongo-root-username: dXNlcm5hbWU=
    mongo-root-password: cGFzc3dvcmQ=

I have tried using 'username' and 'password' as well as their base64 encoded versions but that does not work. I have also tried going into the Qemu documentation to no avail.

It looks like everything is set up correctly and running, I just don't know why it is asking for authorization.

like image 957
Jackson Boyett Avatar asked Oct 21 '25 12:10

Jackson Boyett


1 Answers

You need to enter credentials for the web login of the mongo-express container.

The default values for the first login are "admin" for username and "pass" for password. You can read it in mongo-express documentation here.

like image 192
Noy Wolfson Avatar answered Oct 24 '25 13:10

Noy Wolfson