Difference between Consul Service Definition Address and Service Address

The json consul service definition is as follows

{ "Address": "192.168.10.10", "TaggedAddresses": { "lan": "192.168.10.10", "wan": "10.0.10.10" }, "CreateIndex": 51, "ModifyIndex": 51, "Node": "foobar", "ServiceAddress": "172.17.0.3", "ServiceEnableTagOverride": false, "ServiceID": "32a2a47f7992:nodea:5000", "ServiceName": "foobar", "ServicePort": 5000, "ServiceTags": [ "tacos" ] } 

Now according to the documentation provided at https://www.consul.io/docs/agent/http/catalog.html#catalog_service

The definition of the address and business address is as follows:

  • Address : The IP address of the Consul node on which the service is registered
  • ServiceAddress : service host IP address - if empty, node address should be used

a. Does this mean that the address is the address of the consul node server, and the service address is the address of the node where the service is located?

OR

Q. Does this mean that the address is the address of the agent of the consul living with the service. If so, is this address and business address the same?

which of the above is true?

+6
source share
1 answer

I believe that Address is the address of the consul agent, and ServiceAddress is the address that is used to access this service. These may be the same addresses, but they may also be different.

For example, you can have one host with several interfaces, one of which is used to interact with each other Consul agents, and the other to access your service.

Or you can have one node with several microservices deployed with Docker. You can run one Consul agent with this node address and register several microservices running in containers and inform each other by the internal IP addresses of the container. In this case, you will receive information about the service, where the Address is node IP and ServiceAddress is equal to the IP address of the container with the service.

+3
source

Source: https://habr.com/ru/post/1012575/


All Articles