<p>I know minikube should be used for local only, but i'd like to create a test environment for my applications.<br />
In order to do that, I wish to expose my applications running inside the minikube cluster to external access (from any device on public internet - like a 4G smartphone).</p>
<p><strong>note :</strong> I run minikube with <code>--driver=docker</code></p>
<p><strong>kubectl get services</strong></p>
<pre><code>NAME      TYPE       CLUSTER-IP     EXTERNAL-IP   PORT(S)          AGE
web8080   NodePort   10.99.39.162   &lt;none&gt;        8080:31613/TCP   3d1h
</code></pre>
<p><strong>minikube ip</strong></p>
<pre><code>192.168.49.2
</code></pre>
<p>One way to do it is as follows :</p>
<pre><code>firewall-cmd --add-port=8081/tcp
kubectl port-forward --address 0.0.0.0 services/web8080 8081:8080
</code></pre>
<p>then I can access it using :</p>
<pre><code>curl localhost:8081      (directly from the machine running the cluster inside a VM)
curl 192.168.x.xx:8081   (from my Mac in same network - this is the private ip of the machine running the cluster inside a VM)
curl 84.xxx.xxx.xxx:8081 (from a phone connected in 4G - this is the public ip exposed by my router)
</code></pre>
<p>I don't want to use this solution because <code>kubectl port-forward</code> is weak and need to be run every time the port-forwarding is no longer active.</p>
<p>How can I achieve this ?</p>
<p><strong>(EDITED) - USING LOADBALANCER</strong></p>
<p>when using <code>LoadBalancer</code> type and <code>minikube tunnel</code>, I can expose the service only inside the machine running the cluster.</p>
<p><strong>kubectl get services</strong></p>
<pre><code>NAME         TYPE           CLUSTER-IP      EXTERNAL-IP     PORT(S)          AGE
my-service   LoadBalancer   10.111.61.218   10.111.61.218   8080:31831/TCP   3d3h
</code></pre>
<p><code>curl 10.111.61.218:8080</code> (inside the machine running the cluster) is working<br />
but <code>curl 192.168.x.xx:8080</code> (from my Mac on same LAN) is not working</p>
<p>Thanks</p>

samasoulé
<p><code>Minikube</code> as a development tool for a single node Kubernetes cluster provides inherent isolation layer between Kubernetes and the external devices (being specific the <strong>inbound</strong> traffic to your cluster from <code>LAN</code>/<code>WAN</code>).</p>
<p>Different <a href="https://minikube.sigs.k8s.io/docs/drivers/" rel="nofollow noreferrer">--drivers</a> are allowing for flexibility when it comes to the place where your Kubernetes cluster will be spawned and how it will behave network wise.</p>
<blockquote>
<p>A side note (workaround)!</p>
<p>As your <code>minikube</code> already resides in a <code>VM</code> and uses <code>--driver=docker</code> you could try to use <code>--driver=none</code> (you will be able to <code>curl VM_IP:NodePort</code> from the <code>LAN</code>). It will spawn your Kubernetes cluster directly on the <code>VM</code>.</p>
<p>Consider checking it's documentation as there are some certain limitations/disadvantages:</p>
<ul>
<li><em><a href="https://minikube.sigs.k8s.io/docs/drivers/none/" rel="nofollow noreferrer">Minikube.sigs.k8s.io: Docs: Drivers: None</a></em></li>
</ul>
</blockquote>
<hr />
<p>As this setup is already basing on the <code>VM</code> (with unknown hypervisor) <strong>and the cluster is intended to be exposed outside of your LAN</strong>, I suggest you going with the production-ready setup. This will inherently eliminate the connectivity issues you are facing. Kubernetes cluster will be provisioned directly on a <code>VM</code> and not in the <code>Docker</code> container.</p>
<p>Explaining the <code>--driver=docker</code> used: It will spawn a container on a host system with Kubernetes inside of it. Inside of this container, <code>Docker</code> will be used once again to spawn the necessary <code>Pods</code> to run the Kubernetes cluster.</p>
<p>As for the tools to provision your Kubernetes cluster you will need to chose the option that suits your needs the most. <strong>Some</strong> of them are the following:</p>
<ul>
<li><em><a href="https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/" rel="nofollow noreferrer">Kubeadm</a></em></li>
<li><em><a href="https://github.com/kubernetes-sigs/kubespray" rel="nofollow noreferrer">Kubespray</a></em></li>
<li><em><a href="https://microk8s.io/" rel="nofollow noreferrer">MicroK8S</a></em></li>
</ul>
<p>After you created your Kubernetes cluster on a <code>VM</code> you could forward the traffic from your router directly to your <code>VM</code>.</p>
<hr />
<p>Additional resources that you might find useful:</p>
<ul>
<li><em><a href="https://stackoverflow.com/questions/62559281/expose-kubernetes-cluster-to-internet/62697373#62697373">Stackoverflow.com: Questions Expose Kubernetes cluster to the Internet (Virtualbox with minikube)</a></em></li>
</ul>
