I have multiple instances of Mongo db deployed inside my kubernetes cluster through helm packages. They are running as a service, in NodePort. How do I connect to those Mongo db instances through UI tools like MongoDB Compass and RoboMongo from outside the cluster? Any help is appreciated.
You can use kubectl port-forward
to connect to MongoDB from outside the cluster.
Run kubectl port-forward << name of a mongodb pod >> --namespace << mongodb namespace >> 27018:27018
.
Now point your UI tool to localhost:27018
and kubectl
will forward all connections to the pod inside the cluster.
Starting with Kubernetes 1.10+ you can also use this syntax to connect to a service (you don't have to find a pod name first):kubectl port-forward svc/<< mongodb service name >> 27018:27018 --namespace << mongodb namespace>>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With