英文:
What is difference between load balancing using Service type ClusterIP and Service type of LoadBalancer?
问题
当我使用类型为ClusterIP且有2个POD的服务时,流量分布在这2个POD之间。
我发现还有另一种服务类型LoadBalancer。这两种服务类型之间有什么区别?LoadBalancer和ClusterIP有什么不同?
谢谢
英文:
When I use Service with type ClusterIP and 2 PODS, the traffic is distributed accross the 2 PODs.
I found another Service type LoadBalancer. What is the difference between the 2 types of Services? How is LoadBalancer different from ClusterIP ?
Thanks
答案1
得分: 2
ClusterIP 将服务公开在集群内部的 IP 上。您无法从集群外部访问此服务。
LoadBalancer 除了集群内部 IP 外,还为服务分配了外部 IP。外部 IP 可用于从集群外部访问服务。要使 LoadBalancer 正常工作,您需要一个分配这些外部 IP 的控制器。大多数云提供商支持 LoadBalancer 服务。
请观察下面输出中的 TYPE 和 EXTERNAL-IP 列。只有 LoadBalancer 服务分配了 EXTERNAL-IP。此 IP 可用于从集群外部连接到服务。
# kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
jaeger-collector ClusterIP 10.111.127.254 <none> 14267/TCP,14268/TCP,9411/TCP 36d
jaeger-query LoadBalancer 10.106.69.234 10.92.70.150 80:32131/TCP
英文:
ClusterIP exposes the service on a cluster-internal IP. You cannot access this service from outside the cluster.
LoadBalancer assigns an external IP to the service in addition to cluster-internal IP. The external IP can be used to reach the service from outside the cluster. For LoadBalancer to work, you need a controller which assigns these external IP. Most cloud providers support LoadBalancer services.
Observe the TYPE and EXTERNAL-IP columns in the below output. Only LoadBalancer service has an EXTERNAL-IP assigned. This IP can be used to connect to the service from outside the cluster.
# kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
jaeger-collector ClusterIP 10.111.127.254 <none> 14267/TCP,14268/TCP,9411/TCP 36d
jaeger-query LoadBalancer 10.106.69.234 10.92.70.150 80:32131/TCP
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论