<p>I would like to avoid using <code>type: "LoadBalancer"</code> 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.</p>

<p>I tried to us the <code>externalIPs</code> Service configuration and to give at turns, the IPs of:</p>

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

<p>None of the above helped me reach my application using the Kubernetes Service with an <code>externalIPs</code> configuration.</p>

<p>So, how can I publish a service on the Internet without using a <code>LoadBalancer</code>-type Kubernetes Service.</p>

<p>If you don't want to use a <code>LoadBalancer</code> service, other options for exposing your service publicly are:</p>

<h2>Type <code>NodePort</code></h2>

<p>Create your service with <code>type</code> set to <code>NodePort</code>, and Kubernetes will allocate a port on all of your node VMs on which your service will be exposed (<a href="http://kubernetes.io/docs/user-guide/services/#type-nodeport" rel="noreferrer">docs</a>). E.g. if you have 2 nodes, w/ public IPs <code>12.34.56.78</code> and <code>23.45.67.89</code>, and Kubernetes assigns your service port 31234, then the service will be available publicly on both <code>12.34.56.78:31234</code> &amp; <code>23.45.67.89:31234</code></p>

<h2>Specify <code>externalIPs</code></h2>

<p>If you have the ability to route public IPs to your nodes, you can specify <code>externalIPs</code> in your service to tell Kubernetes "If you see something come in destined for that IP w/ my service port, route it to me." (<a href="http://kubernetes.io/docs/user-guide/services/#external-ips" rel="noreferrer">docs</a>)</p>

<p>The cluster endpoint won't work for this because that is only the IP of your Kubernetes master. The public IP of another <code>LoadBalancer</code> service won't work because the LoadBalancer is only configured to route the port of that original service. I'd expect the node IP to work, but it may conflict if your service port is a privileged port.</p>

<h2>Use the <code>/proxy/</code> endpoint</h2>

<p>The Kubernetes API includes a <code>/proxy/</code> endpoint that allows you to access services on the cluster endpoint IP. E.g. if your cluster endpoint is <code>1.2.3.4</code>, you could reach <code>my-service</code> in namespace <code>my-ns</code> by accessing <code>https://1.2.3.4/api/v1/proxy/namespaces/my-ns/services/my-service</code> with your cluster credentials. This should really only be used for testing/debugging, as it takes all traffic through your Kubernetes master on the way to the service (extra hops, SPOF, etc.).</p>
