Creating an Inter-Kubernetes-Cluster services using an Internal LoadBalancer
So, say you’ve got two Kubernetes clusters running on GCP and you need to expose a service from Cluster A to Cluster B.
Google Cloud Platform has several ways of doing this but my favorite by far is to use their internal load balancer.
Note: You must have VPC-native (alias IP) enabled when creating your kubernetes cluster on in order for this to work!
Also, the kubernetes clusters and the internal loadbalancers need to be in the same region, so make sure it’s both
us-east-1c or whatever you use.
And the critical part here is to create a service that is a LoadBalancer like any other LoadBalancer but use an annotation that essentially allows you to talk between the clusters.
- name: your-awesome-app
After you run this, you’ll be able to see an EXTERNAL-IP under services:
And from the other cluster always check and you should be able to hit that endpoint!
> kub exec -it debug-6675b9bd8-84fvh bash
root@debug-6675b9bd8-84fvh:/# http http://10.x.x.x:<your port>
Hope this helps!
Sign up for GCP using the link below for an additional $50! ($350 total for new users).