Oleg Antonyan
Oleg Antonyan

Reputation: 3113

Consul: get address of a service from a request

When registering a service in Consul I need to pass Address. But to do so I need to know this address in the first place. This is not always a trivial task if you have multiple network interfaces.

Is there a way to use the source address from the request itself? Wherever it came from just take the source address and use it

Upvotes: 0

Views: 348

Answers (1)

Gal Ben-Haim
Gal Ben-Haim

Reputation: 17803

The service catalog is a... catalog, the address that services are registered should be accessible by whoever queries the catalog.

I don't believe there's an automatic solution for this, but you can:

  1. register the service multiple times with different tags for the different network interfaces, query the relevant tag.

  2. register the service multiple times with different service names for the different network interfaces. e.g. (myservice-lan1, myservice-lan2). query the relevant service name.

  3. run multiple consul clusters, set with different datacenters and use each subnet as a different datacenter.

Upvotes: 1

Related Questions