Access kubernetes cluster from outside of the host machine via port 80

1/5/2019

So, instead of explaining the architecture I draw you a picture today :) I know, it's 1/10.

Forgot to paint this as well, it is a single node cluster

Hope this will save you some time. Probably it's also easier to see where my struggles are, as I expose the lack of understandings.

So, in a nutshell:

What is working:

  • I can curl each ingress via virtual hosts from inside of the server using curl -vH 'host: host.com' http://192.168.1.240/articleservice/system/ipaddr

  • I can access the server


What's not working:

  • I can not access the cluster from outside.

Somehow I am not able to solve this myself, even tho I read quite a lot and had lots of help. As I am having issues with this for a period of time now explicit answers are really appreciated.

architecture

-- elp
bare-metal-server
kubernetes
kubernetes-ingress

1 Answer

1/6/2019

Generally you cannot access your cluster from outside without exposing a service. You should change your "Ingress Controller" service type to NodePort and let kubernetes assign a port to that service.
you can see ports assigned to a service using kubectl get service ServiceName.
now it's possible to access that service from out side on http://ServerIP:NodePort but if you need to use standard HTTP and HTTPS ports you should use a reverse proxy outside of your cluster to flow traffic from port 80 to NodePort assigned to Ingress Controller Service.
If you don't like to add reverse proxy, it is possible to add externalIPs to Ingress controller service but in this way you lose RemoteAddr in your Endpoints and you get ingress controller pod IP instead. externalIPs can be list of your public IPs

you can find useful information about services and ingress in following links:
Kubernetes Services

Nginx Ingress - Bare-metal considerations

-- Mozafar Gholami
Source: StackOverflow