<p>How do I achieve cross-region load balancing on Google Container Engine?</p>

<p>I will have one Kubernetes cluster per region in several regions and I need to route traffic from a single domain name to the geographically closest cluster.</p>

<p>Some options I've investigated:</p>

<ul>
<li><strong>Kubernetes LoadBalancers</strong> seem to be restricted to one cluster.</li>
<li>I'm not sure how you get <strong>Kubernetes Ingress</strong> to talk to different clusters. (It sounds like this object is backed by Compute Engine HTTP load balancers though.)</li>
<li><strong>Compute Engine HTTP Load Balancers</strong> talking to exposed clusters <a href="https://www.ianlewis.org/en/cross-region-http-services-container-engine" rel="nofollow">sounds right</a>, but the link I referenced seems to have some old terms like <code>gcloud beta</code>.</li>
<li>Instead of all this, can I actually get a Kubernetes cluster to span different regions?</li>
</ul>

<p>Now if I want to route different URL paths to different containers within a pod, where do I do that? If it's at the Ingress or HTTP Load Balancer level, then I don't have enough granularity to address particular containers. Does that mean I would have to use a different pod + service for each different URL path?</p>

<p>Google's <a href="https://cloud.google.com/compute/docs/load-balancing/network/" rel="nofollow noreferrer">Network load balancing</a> (L3) load balancing is specifically per-region (these are the load balancers that are automatically configured if you create a service of type <code>LoadBalancer</code>). As Alex mentioned in his answer, if you use network load balancing you will need to configure one load balancer per region and then use DNS to spread user requests to each of your load balancers. </p>

<p>Google's <a href="https://cloud.google.com/compute/docs/load-balancing/http/" rel="nofollow noreferrer">HTTP(S) load balancing</a> is cross-region (e.g. global). This means that you get a single IP that will balance across all of your HTTP(S) backends, which can be spread across multiple clusters in multiple regions. For cross cluster load balancing, you must configure the HTTP(S) load balancer yourself as described in <a href="https://stackoverflow.com/questions/35446512/is-it-possible-to-use-1-kubernetes-ingress-object-to-route-traffic-to-k8s-servic/35447985#35447985">Is it possible to use 1 Kubernetes ingress object to route traffic to k8s services in different clusters?</a>. </p>

<p>In either case, you will need to create a different service for for each URL path that you want to route to a unique backend. The services don't have to use different pods, although you may want to if they receive different amounts of traffic and you want to scale them independently. </p>

<p>If you use the HTTP(S) load balancer, you can define these services and the URL mapping as part of the load balancer configuration and let the HTTP(S) balancer do the request inspection / routing for you. If you use the network load balancer, then you will need to run an HTTP(S) server yourself that terminates the connection, inspects the request, and routes it to the appropriate service. </p>

<blockquote>
  <p>Instead of all this, can I actually get a Kubernetes cluster to span different regions?</p>
</blockquote>

<p>Not out of the box. You can configure a multi-zone cluster (within a region), but we don't offer explicit support for configuring a cluster than spans regions. While you could do this manually yourself, we don't recommend it as there are many parameters baked into the cluster management software that have been tuned with the assumption of low-latency communication between the master and nodes within the cluster. </p>
