pkdone / minikube-mongodb-demo

Demo project showing how to deploy MongoDB in a local Minikube Kubernetes environment
MIT License
87 stars 61 forks source link

How to access from outside minikube? #10

Open petertirrell opened 5 years ago

petertirrell commented 5 years ago

How would you configure this to access from outside minikube? Otherwise, the tutorial seems to have worked - it looks like things are up and running. But I'd like to be able to hook up Robo3T from my workstation to poke at the mongo database.

akaila commented 5 years ago

Ya without this information this is completely useless repo IMO. Here is what I had to do to get it to connect externally:

Change the service config within mongodb-service.yaml to:

apiVersion: v1
kind: Service
metadata:
  name: mongodb-service
  labels:
    name: mongo
spec:
  ports:
    - port: 27017
      targetPort: 27017
      nodePort: 30000
  type: NodePort
  selector:
    role: mongo

Run the cluster as instructed in README.md

Then at the prompt:

$./configure_repset_auth.sh abc123

$minikube service mongodb-service --url http://192.168.99.101:30000

Use the above IP and port to connect to mongo with user as main_admin and password as abc123

vincentpham13 commented 3 years ago

Ya without this information this is completely useless repo IMO. Here is what I had to do to get it to connect externally:

Change the service config within mongodb-service.yaml to:

apiVersion: v1
kind: Service
metadata:
  name: mongodb-service
  labels:
    name: mongo
spec:
  ports:
    - port: 27017
      targetPort: 27017
      nodePort: 30000
  type: NodePort
  selector:
    role: mongo

Run the cluster as instructed in README.md

Then at the prompt:

$./configure_repset_auth.sh abc123

$minikube service mongodb-service --url http://192.168.99.101:30000

Use the above IP and port to connect to mongo with user as main_admin and password as abc123

My approach is the same as yours, but do we connect to mongo replicaset using just one host and port? In this case, I think we have to expose totally 3 mongo services. How do you think?

ProbStub commented 2 years ago

I have proposed a fix using port-forwarding to the service. Your milage may vary but I find it more flexible than the minikube option.