Google Container Engine上的跨区域负载平衡+路由 [英] Cross-region load balancing + routing on Google Container Engine

查看:75
本文介绍了Google Container Engine上的跨区域负载平衡+路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Google Container Engine上实现跨区域负载平衡?

How do I achieve cross-region load balancing on Google Container Engine?

我将在几个区域中的每个区域拥有一个Kubernetes集群,我需要将流量从单个域名路由到地理位置最接近的集群.

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.

我研究过的一些选项:

  • Kubernetes LoadBalancers 似乎仅限于一个群集.
  • 我不确定您如何让 Kubernetes Ingress 与不同的集群交流. (听起来这对象是由Compute Engine HTTP负载平衡器支持的.)
  • Compute Engine HTTP负载平衡器与暴露的群集进行通话
  • Kubernetes LoadBalancers seem to be restricted to one cluster.
  • I'm not sure how you get Kubernetes Ingress to talk to different clusters. (It sounds like this object is backed by Compute Engine HTTP load balancers though.)
  • Compute Engine HTTP Load Balancers talking to exposed clusters sounds right, but the link I referenced seems to have some old terms like gcloud beta.
  • Instead of all this, can I actually get a Kubernetes cluster to span different regions?

现在,如果我想将不同的URL路径路由到Pod中的不同容器,该在哪里做?如果它是Ingress或HTTP负载平衡器级别,则我没有足够的粒度来解决特定的容器.这是否意味着我必须为每个不同的URL路径使用不同的pod +服务?

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?

推荐答案

Google的网络负载平衡(L3)负载平衡专门针对每个区域(如果创建类型为LoadBalancer的服务,则这些负载平衡器会自动配置).正如Alex在他的回答中提到的那样,如果您使用网络负载平衡,则需要在每个区域配置一个负载平衡器,然后使用DNS将用户请求传播到每个负载平衡器.

Google's Network load balancing (L3) load balancing is specifically per-region (these are the load balancers that are automatically configured if you create a service of type LoadBalancer). 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.

Google的 HTTP(S)负载平衡区域(例如全球).这意味着您将获得一个将在所有HTTP(S)后端之间保持平衡的IP,该IP可分布在多个区域的多个群集中.对于跨集群负载平衡,您必须按照

Google's HTTP(S) load balancing 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 Is it possible to use 1 Kubernetes ingress object to route traffic to k8s services in different clusters?.

无论哪种情况,您都需要为要路由到唯一后端的每个URL路径创建一个不同的服务.这些服务不必使用不同的Pod,尽管您可能希望它们接收不同的流量,并且希望独立扩展它们.

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.

如果使用HTTP(S)负载均衡器,则可以将这些服务和URL映射定义为负载均衡器配置的一部分,并让HTTP(S)均衡器为您执行请求检查/路由.如果使用网络负载平衡器,则需要自己运行HTTP(S)服务器,以终止连接,检查请求并将其路由到适当的服务.

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.

代替所有这些,我真的可以得到一个Kubernetes集群来跨越不同的区域吗?

Instead of all this, can I actually get a Kubernetes cluster to span different regions?

不是开箱即用的.您可以配置多区域集群(在一个区域内),但是除跨区域外,我们不提供对配置集群的明确支持.尽管您可以自己手动执行此操作,但我们不建议您这样做,因为在群集管理软件中包含了许多参数,这些参数已在假设群集中的主节点与节点之间的通信延迟较低的情况下进行了调整.

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.

这篇关于Google Container Engine上的跨区域负载平衡+路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆