Habitat services with external load balancers


#1

Hey,

I found some information that service discovery is built-in inside supervisor and it says that there is no need to use external tool for that like consul etc… In this case I’m a bit unsure how this built-in feature could be useful in real life scenario ? For example if I want to send traffic only to the services which are healthy from external load balancer then what would be the way to do that ?

{{~#eachAlive bind.backend.members as |member|}}
server ip {{member.sys.ip}}:{{member.cfg.port}}
{{~/eachAlive}}

this is partial answer, but I still can’t get my head around on how let say external load balancer should know where to send traffic to if let say there is a ring of multiple supervisors ?

Currently I assume there are only couple of ways:

  1. write some kind of script/service and integrate it inside ring which will update external load balancers configuration
  2. hard code ip addresses into external load balancers configuration and maintain this configuration manually

Thanks


#2

Service discovery is built in, but I believe when it mentions no need to use external tools for it, its not considering a mixed environment where some services are outside the habitat ring. What I’ve done in this situation is to register consul services that match the habitat launched services, and in some cases queried the API for service information.

With loadbalancers external to the ring, you’re going to have to write something to update the configuration.

You can integrate with the HTTP API to grab some pretty useful information. Here’s a link to the HTTP API doc: