Kubernetes : Cluster IP, Nodeport, LoadBalancer - prabhav-thali/articles GitHub Wiki

How Cluster-IP, Nodeport, and Load-balancer differ?

ClusterIP:

ClusterIP is the default Kubernetes service. This service is created inside a cluster and can only be accessed by other pods in that cluster. So basically we use this type of service when we want to expose a service to other pods within the same cluster.  This service is accessed using Kubernetes proxy.

Nodeport:

NodePort opens a specific port on each node of the cluster and traffic on that node is forwarded directly to the service. There are a few limitations and hence it's not advised to use NodePort

  • Only one service per port
  • You can only use ports 30000-32767
  • Dealing with changing node/VM IP is difficult

LoadBalancer:

All the traffic on the port is forwarded to the service, there's no filtering, no routing. This is the standard way to expose service to the internet. All the traffic on the port is forwarded to the service. It's designed to assign an external IP to act as a load balancer for the service.  There's no filtering, no routing. LoadBalancer uses a cloud service ex. Few limitations with LoadBalancer:

  • Every service exposed will have it's own IP address 
  • It gets very expensive