kubernetes service exposed to host ip

12/8/2017

I created a kubernetes service something like this on my 4 node cluster:

kubectl expose deployment distcc-deploy --name=distccsvc --port=8080
 --target-port=3632 --type=LoadBalancer

The problem is how do I expose this service to an external ip. Without an external ip you can not ping or reach this service endpoint from outside network.

I am not sure if i need to change the kubedns or put some kind of changes. Ideally I would like the service to be exposed on the host ip. Like http://localhost:32876

hypothetically let's say i have a 4 node vm on which i am running let's say nginx service. i expose it as a lodabalancer service. how can i access the nginx using this service from the vm ?

let's say the service name is nginxsvc is there a way i can do http://:8080. how will i get this here for my 4 node vm ?

-- Stock
kubernetes

1 Answer

12/8/2017

LoadBalancer does different things depending on where you deployed kubernetes. If you deployed on AWS (using kops or some other tool) it'll create an elastic load balancer to expose the service. If you deployed on GCP it'll do something similar - Google terminology escapes me at the moment. These are separate VMs in the cloud routing traffic to your service. If you're playing around in minikube LoadBalancer doesn't really do anything, it does a node port with the assumption that the user understands minikube isn't capable of providing a true load balancer.

LoadBalancer is supposed to expose your service via a brand new IP address. So this is what happens on the cloud providers, they requisition VMs with a separate public IP address (GCP gives a static address and AWS a DNS). NodePort will expose as a port on kubernetes node running the pod. This isn't a workable solution for a general deployment but works ok while developing.

-- Lev Kuznetsov
Source: StackOverflow