Raghav Boorgapally February 2016

How do I expose Kubernetes service to the internet?

I am running a kubernetes cluster with 1 master (also a node) and 2 nodes on Azure. I am using Ubuntu with Flannel overlay network. So far everything is working well. The only problem I have is exposing the service to the internet.

I am running the cluster on an azure subnet. The master has a NIC attached to it that has a public IP. This means if I run a simple server that listens on port 80, I can reach my server using a domain name (Azure gives an option to have a domain name for a public IP).

I am also able to reach the kubernetes guest book frontend service with some hack. What I did was check all the listening ports on the master and try each port with the public IP. I was able to hit the kubernetes service and get response. Based on my understanding this is directly going to the pod that is running on the master (which is also a node) rather than going through the service IP (which would have load balanced across any of the pods).

My question is how do I map the external IP to the service IP? I know kubernetes has a setting that works only on GCE (which I can't use right now). But is there some neat way of telling etcd/flannel to do this?

Answers


Joao Morais February 2016

If you use the kubectl expose command:

--external-ip="": External IP address to set for the service. The service can be accessed by this IP in addition to its generated service IP.

Or if you create from a json or yaml file, use the spec/externalIPs array.

Post Status

Asked in February 2016
Viewed 1,939 times
Voted 14
Answered 1 times

Search




Leave an answer