Accessing a webpage hosting on a pod

2/14/2018

I have deployment that hosts a website on port 9001 and a service attached to it. I want to allow anyone (from outside cluster) to be able to connect to that site.

Any help would be appreciated.

-- Ramboo19
kubernetes

2 Answers

2/14/2018

As you wrote that this is not a cloud deployment, you need to consider how to correctly expose this to the world in a decent fashion. First and formost, create a NodePort type service for your deployment. With this, your nodes will expose that service on a high port.

Depending on your network, at this point you either need to configure a loadbalancer in your network to forward traffic for some IP:80 to your node(s) high NodePort, or for example deploy HAProxy in a DeamonSet with hostNetwork: true that will proxy 80 to your NodePort.

A bit more complexity can be added by deployment of Nginx IngressController (exposed as above) and use of Ingress to make the Ingress Controller expose all your services without the need to fiddle with NodePort/LB/HAProxy for each of them individualy any more.

-- Radek 'Goblin' Pieczonka
Source: StackOverflow

2/14/2018

I want to allow anyone (from outside cluster) to be able to connect to that site

There are many ways to do this using kubernetes services to expose port 9001 of the website to the outside world:

  1. Service type LoadBalancer if you have an external, cloud-provider's load-balancer.
  2. ExternalIPs. The website can be hit at ExternalIP:Port.
  3. Service type NodePort if the cluster's nodes are reachable from the users. The website can be hit at NodeIP:NodePort.
  4. Ingress controller and ingress resource.
-- Vikram Hosakote
Source: StackOverflow