Inter-Cluster Service Discovery in Bare Metal Kubernetes Machines

4/15/2020

I am exploring options for service discovery in my new project.

So here is how it is : I have multiple bare metal Kubernetes (Linux) machines, with no cloud providers. I have multiple Kubernetes clusters, for this example lets name them Cluster-1 and Cluster-2.

Now suppose I have 10 microservices (spring boot), I would want to deploy them in both the clusters. So all 10 microservices in both the clusters.

The service discovery mechanism that I need is like :

If a microservice ms-1 from Cluster-1 needs to call another microservice ms-2 then I want the communication preference to be within same cluster if ms-2 is up and healthy in Cluster-1. However, if ms-2 is not up/running in Cluster-1 then the call from ms-1 (Cluster-1) must go to ms-2 (Cluster-2).

This has to obviously be supported in order to be functional in a multi-cluster geographical network.

I cannot achieve this by the service discovery mechanisms that native Kubernetes offers.

I tried using Istio but I found that it uses native Kubernetes service discovery mechanism only. So Istio is out from the picture.

I am deciding to try out Consul and deploy my microservices with Kubernetes services of type NodePort hoping that Consul will be able to resolve the host and nodePort of the target service both inter and intra cluster. Fingers crossed !!

Now I have mainly 2 questions :

  1. Do I need to use spring-cloud-consul in every microservice in order to talk to Consul and get the host:port of the target service ?

    I see Linkerd does provide some capability by which microservices can talk to Linkerd and Linkerd talks to Consul and resolves the service on behalf of spring-cloud-consul client.

    I even saw this post --> https://discourse.linkerd.io/t/linkerd-with-springboot/638

    I want to know more details about how it can be done.

  2. Do I need Consul at all ? Does Linkerd offer a solution to my requirement ? If yes then please enlighten me how ?

Thanks for reading a long question. I hope I will get some prompt and positive guidance to proceed with my project.

-- ABhinav
bare-metal-server
consul
kubernetes
linkerd
spring-cloud-consul

1 Answer

4/28/2020

It sounds like you're trying to use a service mesh to solve this. If so, Consul can provide this natively with its service mesh. You do not need any additional software.

You would need to deploy Consul in each Kubernetes cluster, and federate two environments using WAN Federation. Once the clusters are federated, you can deploy Mesh Gateways (see tutorial) to enable service-to-service communication between the clusters. Then configure your failover policy within the L7 service-resolver configuration so that traffic is re-routed to the alternate cluster when local instances are unavailable.

I hope this helps. Please let me know if you need additional detail.

-- Blake C
Source: StackOverflow