Do Cluster IP and Node Port IP addresses load balance between different nodes?

3/23/2018

I have an app deployment called 'backend-app' running in pods that are on several different nodes. I also have a service that exposes the 'backend-app' to be accessed by other cluster internal pods as my 'frontend-app' pods.

If I use DNS to connect to the 'backend-app' from my different app deployment called 'frontend-app' will the requests be load balanced to each 'backend-app' pod on each node?

It sounds like a NodePort service will only connect to one node and not load balance my requests to others.

-- Dan
kubernetes

2 Answers

3/23/2018

Services automatically load balance to the pods that are assigned to them. See https://kubernetes.io/docs/concepts/services-networking/connect-applications-service/#creating-a-service.

The cluster IP address that is created with a service is the IP address that will automatically select an available pod on any node that is running the pod. You can find the service's cluster IP address by using a DNS lookup.

My confusion came because I didn't realise the cluster IP address was associated with a service, not with a specific Pod.

I'm currently not sure about how NodePort's work with this though.

-- Dan
Source: StackOverflow

3/23/2018

For each Service with type: NodePort a port is opened on all nodes (the same port on each). The port is open whether a pod of that service is running on a node or not. The load balancing is done among all pods of all nodes with no preference to a pod that happens to run on the same node to which you connected on the node port (if there is one there at all).

-- Janos Lenart
Source: StackOverflow