简体   繁体   English

Kubernetes集群内部负载平衡

[英]Kubernetes cluster internal load balancing

Playing a bit with Kubernetes (v1.3.2) I'm checking the ability to load balance calls inside the cluster (3 on-premise CentOS 7 VMs). 玩弄Kubernetes(v1.3.2),我正在检查是否可以在集群(3个本地CentOS 7 VM)中负载均衡呼叫的能力。
If I understand correctly the documentation in http://kubernetes.io/docs/user-guide/services/ 'Virtual IPs and service proxies' paragraph, and as I see in my tests, the load balance is per node (VM). 如果我正确理解http://kubernetes.io/docs/user-guide/services/ “虚拟IP和服务代理”段落中的文档,并且正如我在测试中所见,则负载平衡是按节点(VM)进行的。 Ie, if I have a cluster of 3 VMs and deployed a service with 6 pods (2 per VM), the load balancing will only be between the pods of the same VM which is somehow disappointing. 即,如果我有一个由3个VM组成的集群,并且部署了一个具有6个Pod(每个VM 2个)的服务,则负载平衡将仅位于同一VM的Pod之间,这令人失望。
At least this is what I see in my tests: Calling the service from within the cluster using the service's ClusterIP, will load-balance between the 2 pods that reside in the same VM that the call was sent from. 至少这是我在测试中看到的结果:使用服务的ClusterIP从群集中调用服务将在驻留该呼叫的同一VM中的2个Pod之间进行负载平衡。 (BTW, the same goes when calling the service from out of the cluster (using NodePort) and then the request will load-balance between the 2 pods that reside in the VM which was the request target IP address). (顺便说一句,当从群集外部(使用NodePort)调用服务时,情况也是如此,然后请求将在VM中驻留的两个Pod(即请求目标IP地址)之间进行负载平衡)。
Is the above correct? 以上正确吗?
If yes, how can I make internal cluster calls load-balance between all the 6 replicas? 如果是,如何在所有6个副本之间进行内部群集调用负载平衡? (Must I employ a load balancer like nginx for this?) (为此,我是否必须使用像nginx这样的负载均衡器?)

No, the statement is not correct. 不,该说法不正确。 The loadbalancing should be across nodes (VMs). 负载平衡应跨节点(VM)。 This demo demonstrates it. 演示对此进行了演示 I have run this demo on a k8s cluster with 3 nodes on gce. 我已经在具有gce上的3个节点的k8s集群上运行了该演示。 It first creates a service with 5 backend pods, then it ssh into one gce node and visits the service.ClusterIP, and the traffic is loadbalanced to all 5 pods. 它首先创建一个具有5个后端Pod的服务,然后将其SSH到一个gce节点并访问该服务。ClusterIP,流量将负载均衡到所有5个Pod。 I see you have another question "not unique ip per pod" open, it seems you hadn't set up your cluster network properly, which might caused what you observed. 我看到您还有另一个问题“每个Pod的唯一IP不可用”,似乎您没有正确设置群集网络,这可能导致您观察到了问题。

在您的情况下,每个节点都将运行服务的副本-并在各个节点之间实现负载平衡。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM