Service 类型 ClusterIP 和 Service 类型 LoadBalancer 在负载均衡方面有什么区别?

huangapple go评论66阅读模式
英文:

What is difference between load balancing using Service type ClusterIP and Service type of LoadBalancer?

问题

当我使用类型为ClusterIP且有2个POD的服务时,流量分布在这2个POD之间。

我发现还有另一种服务类型LoadBalancer。这两种服务类型之间有什么区别?LoadBalancerClusterIP有什么不同?

谢谢

英文:

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 服务。

请观察下面输出中的 TYPEEXTERNAL-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

huangapple
  • 本文由 发表于 2020年1月6日 16:24:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/59608809.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定