Reputation: 2610
Running the following opens a browser on service EndPoint but the mongo express page doesn't load giving "This site can’t be reached"
minikube.exe service mongo-express-service
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
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
apiVersion: v1
kind: ConfigMap
metadata:
name: mongodb-configmap
data:
database_url: mongodb-service
apiVersion: v1
kind: Secret
metadata:
name: mongodb-secret
type: Opaque
data:
mongo-root-username: cm9vdA==
mongo-root-password: ZXhhbXBsZQ==
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
pod/mongo-express-68c4748bd6-5qnnh 1/1 Running 2 (16h ago) 20h 172.17.0.3 minikube <none> <none>
pod/mongodb-deployment-7bb6c6c4c7-w2bdx 1/1 Running 1 (16h ago) 22h 172.17.0.4 minikube <none> <none>
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 8d <none>
service/mongo-express-service LoadBalancer 10.108.182.35 <pending> 8081:30000/TCP 20h app=mongo-express
service/mongodb-service ClusterIP 10.107.207.139 <none> 27017/TCP 21h app=mongodb
NAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR
deployment.apps/mongo-express 1/1 1 1 20h mongo-express mongo-express app=mongo-express
deployment.apps/mongodb-deployment 1/1 1 1 22h mongodb mongo app=mongodb
NAME DESIRED CURRENT READY AGE CONTAINERS IMAGES SELECTOR
replicaset.apps/mongo-express-68c4748bd6 1 1 1 20h mongo-express mongo-express app=mongo-express,pod-template-hash=68c4748bd6
replicaset.apps/mongo-express-6f76745c84 0 0 0 20h mongo-express mongo-express app=mongo-express,pod-template-hash=6f76745c84
replicaset.apps/mongodb-deployment-7bb6c6c4c7 1 1 1 22h mongodb mongo app=mongodb,pod-template-hash=7bb6c6c4c7
While executing minikube.exe service mongo-express-service the browser opens on http://192.168.49.2:30000/ and returns "This site can’t be reached 192.168.49.2 took too long to respond.", same happen if I use the loopback IP, what am I doing wrong ?
Upvotes: 0
Views: 922
Reputation: 2610
Well, it appears that I had to use minikube tunnel to enable access to the service, strangely, the mongo express service was accessible on port 8081 rather than 30000... I guess this is because it is bring access by the tunnel and not directly
kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 8d
mongo-express-service LoadBalancer 10.108.182.35 127.0.0.1 8081:30000/TCP 22h
mongodb-service ClusterIP 10.107.207.139 <none> 27017/TCP 23h
Upvotes: 1