Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can you publish a Kubernetes Service without using the type LoadBalancer (on GCP)

I would like to avoid using type: "LoadBalancer" for a certain Kubernetes Service, but still to be able to publish it on the Internet. I am using Google Cloud Platform (GCP) to run a Kubernetes cluster currently running on a single node.

I tried to us the externalIPs Service configuration and to give at turns, the IPs of:

  • the instance hosting the Kubernetes cluster (External IP; which also conincides with the IP address of the Kubernetes node as reported by kubernetes describe node)
  • the Kubernetes cluster endpoint (as reported by the Google Cloud Console in the details of the cluster)
  • the public/external IP of another Kubernetes Service of type LoadBalancer running on the same node.

None of the above helped me reach my application using the Kubernetes Service with an externalIPs configuration.

So, how can I publish a service on the Internet without using a LoadBalancer-type Kubernetes Service.

like image 893
4 revs, 2 users 76% Avatar asked Jun 13 '16 14:06

4 revs, 2 users 76%


1 Answers

There's another option: set the hostNetwork flag on your pod.

For example, you can use helm3 to install nginx this way:

 helm install --set controller.hostNetwork=true nginx-ingress nginx-stable/nginx-ingress

The nginx is then available at port 80 & 443 on the IP address of the node that runs the pod. You can use node selectors or affinity or other tools to influence this choice.

like image 181
Bryan Larsen Avatar answered Oct 20 '22 04:10

Bryan Larsen