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

1/6/2020

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

-- Chandu
kubernetes
kubernetes-service

1 Answer

1/6/2020

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
-- Shashank V
Source: StackOverflow