kubernetesminikube

How to expose kubernetes app from minikube outside of domain


I would want to host an app with kubernetes ( minikube ) and reach it from anywhere.

**My setup:**
Physical router:                       192.168.0.1
Physical server (ubuntu server):       192.168.0.69
Docker network on my physical server:  172.17.0.1
Minikube's IP:                         172.17.0.2
Public IP ( for this example static )  84.84.84.84

I have the issue that on kubernetes I can use a simple NodePort to expose the app which works great if I do try to curl it on the physical server e.g: ( lets say 123456 port got exposed by NodePort )

curl 172.17.0.2:123456

I can reach the physical server by portforwarding to 192.168.0.69 in the router and that works.

My issue is that I don't see how could I magically go from

84.84.84.84:123456 --> portforwards --> 192.168.0.69 ---> ?????? ---> 172.17.0.2:123456

and reach the app.


Solution

  • As larks Mentioned absolutely right! To resolve your issue, setting up a DNAT rule on your ubuntu server is the correct in forwarding traffic coming from the public interface to Minikube Nodeport service.

    This DNAT rule forwards traffic that arrives on port 123456 of the public IP address to the Minikube and Nodeport. Hence external clients will be able to use the public IP and push port for the access of your kubernetes application.

    See Sophos Firewall Help page and Alibaba Cloud Help page about how to add a DNAT RULE.