GKE in cluster load balancing between 2 backend applications

12/3/2019

I have 2 applications running on my cluster : G and C. G is only one pod and C is on 2 pods.

G is exposed to external connection and C is not. G first receive requests that he then process and sends to C.

So I was wondering how can I load balance the requests that G sends to C between the 2 pods of C.

I am currently using Kubernetes native service for C but I'm not sure if it is load balancing between my 2 pods. Everything I'm reading seems to expose the service externally and I don't want that

Thank you

-- Marc-Antoine Caron
google-kubernetes-engine
kubernetes
load-balancing

1 Answer

12/3/2019

Create a Kubernetes Service of type ClusterIP for application C's Deployment. Such Service gets an internal IP which isn't exposed outside of the cluster. The Service does a simple round-robin routing of the traffic among the pods it targets (from the Deployment).

Use this to reference application C from G via the Service:

<k8s-service-name>.<namespace>.svc.cluster.local

The above assumes that there's DNS running on the cluster (there usually is).

-- gears
Source: StackOverflow