<p>I have multiple instances of MongoDB deployed inside my Kubernetes cluster through <a href="https://en.wikipedia.org/wiki/Kubernetes#History" rel="nofollow noreferrer">Helm</a> packages.
They are running as a service, in NodePort.</p>
<p>How do I connect to those MongoDB instances through UI tools like MongoDB Compass and RoboMongo from outside the cluster?</p>

Shruthi Bhaskar
<p>You can use <code>kubectl port-forward</code> to connect to MongoDB from outside the cluster.</p>

<p>Run <code>kubectl port-forward &lt;&lt; name of a mongodb pod &gt;&gt;   --namespace &lt;&lt; mongodb namespace &gt;&gt; 27018:27018</code>.<br>
Now point your UI tool to <code>localhost:27018</code> and <code>kubectl</code> will forward all connections to the pod inside the cluster.</p>

<p>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):<br>
<code>kubectl port-forward svc/&lt;&lt; mongodb service name &gt;&gt; 27018:27018 --namespace &lt;&lt; mongodb namespace&gt;&gt;</code> </p>
