How to specify region for loadBalancer in GCE Kubernetes

10/10/2016

When trying to expose a load balancer using kubectl expose --type="loadBalancer", the IPs are defaulting to the Global region despite specifying the desired region and zone for the GCE cluster (us-central in this case). I am thus running into quota limitations for Global when I have plenty of free IPs in us-central (the IN_USE_ADDRESSES exceeded error)

How can I specify that I want the load balancer to use an IP address in the us-central1 range.

Additionally, I can find no way of listing the currently used Global IP addresses and what services are using them. I can only see that I'm using all available ones in Global.

-- dboshardy
google-kubernetes-engine
kubernetes

2 Answers

10/10/2016

If you simply expose, you get an ephemeral ip allocated to your forwarding rule, and it shows up in:

gcloud compute forwarding-rules list

If you want a static ip, you can allocate one in the same region as the cluster:

gcloud compute addresses create test-us-central --region us-central1

And expose the loadbalancer giving it that ip:

kubectl expose $RC-NAME --type=LoadBalancer --load-balancer-ip=$IP

You can't allocate an ip in another region with Services of type=LoadBalancer. Meaning:

gcloud compute forwarding-rules create $NAME --address $ADDRESS --target-pool $TARGET-POOL --region $REGION

$REGION needs to match the region where the vms in $TARGET-POOL are, and $ADDRESS must be from that region too.

If you want to use an ip from another region, you need to setup a new cluster in that region, or make use of the multi-region federation cluster (alpha in 1.4). Note that you can federate a multi-zone cluster, and that exists within a single region (http://kubernetes.io/docs/admin/federation/).

-- Prashanth B
Source: StackOverflow

10/12/2016

It looks like load balancers must be global to talk across regions/zones. The issue was it seems when tearing down a cluster, the load balancers are retained in the Networking section of the cloud console. You have to go in and delete those separately to prevent more and more unused load balancers from being created.

-- dboshardy
Source: StackOverflow