Best-Practice for layer7 clusterization

We setup a k8 cluster for our microservice product together with consul.

One of our services is a self-written message bus which supports clusterization. Therefor, every spawned instance needs to connect to all other alive instances (static tcp connection).
We want to be able to scale this service up and down quite heavily at any given time.

Is it best practice to request all alive services of the catalog via rest (…/catalog/services), loop through the restult, exclude ourselfs and connect to each server?
What about new/dropped servers? Is polling for available servers the only/best option?
Can connect help us here?

Thanks

That’s certainly one route you can take. It sounds like it might work well for your use case.

You can use Consul’s blocking query feature to be notified when new servers come online, become unhealthy, or are removed from the catalog. Take a look at this reply I left in another thread where I provided more info on this feature: Consul Service Discovery Questions - #2 by blake.

If you’re just looking to ensure your service has a current list of available upstreams, and don’t want to write your own code, you might want to consider using Consul Template. It can query Consul for service state changes, and update application configs based on the changed data. See the Service Configuration with Consul Template tutorial for a detailed walkthrough.

Connect can help if you want to better secure the connections between your services, gain visibility into application communication, and have more granular control over traffic routing. If you want to use it for your environment, you’ll need to enable an additional configuration option in order to allow proxying to headless services. See Transparent Proxy: Headless Services for more info.

1 Like