Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Consul Service definition Address and Service Address

Tags:

consul

Consul service definition json 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 as per the documentation provided at https://www.consul.io/docs/agent/http/catalog.html#catalog_service

the definition of address and service address is as follows:

  1. Address: IP address of the Consul node on which the service is registered
  2. ServiceAddress: IP address of the service host — if empty, node address should be used

A. Does this mean Address is the address of consul server node and service address is address of the node where service resides?

OR

B. Does this mean Address is the address of consul agent residing with the service. If this is the case does this mean address and service address are same?

which of the above is correct?

like image 230
Swapnil17 Avatar asked Nov 23 '16 04:11

Swapnil17


People also ask

What is a Consul service?

Consul is the control plane of the service mesh. Consul is a multi-networking tool that offers a fully-featured service mesh solution that solves the networking and security challenges of operating microservices and cloud infrastructure. Consul offers a software-driven approach to routing and segmentation.

Is Consul a DNS server?

By default, the Consul agent runs a DNS server listening on port 8600. By submitting DNS requests to the Consul agent's DNS server, you can get the IP address of a node running the service in which you are interested. The Consul DNS interface makes the port information for a service available via the SRV records.

Is Consul a service mesh?

Consul is a service mesh solution that offers a software-driven approach to: Security (mTLS & ACLs) Observability. Traffic management.

How does service discovery Consul work?

One of the major use cases for Consul is service discovery. Consul provides a DNS interface that downstream services can use to find the IP addresses of their upstream dependencies. Consul knows where these services are located because each service registers with its local Consul client.

How do I use consul service definitions?

Consul can load service definitions saved as .json or .hcl files. Send a SIGHUP to the running agent or use consul reload to check for new service definitions or to update existing services. Alternatively, the service can be registered dynamically using the HTTP API.

What is an internal service in consulate?

Internal services are those provided by nodes where the Consul agent can run directly. They are registered with service definitions via the local Consul agent. The local Consul agent on the node is responsible for running any health checks registered for the service and updating the catalog accordingly.

Why do consular services have to be registered directly with catalogs?

They must be registered directly with the catalog because, by definition, they don't have a local Consul agent to register with. Both internal and external services can have health checks associated with them. Health checking in Consul uses a push-based model where agents send events only upon status changes.

What is the difference between billing address and service address?

Service Address: The service address is where you will primarily be using the phone. This can be the same as your billing address, or it can be different. Billing Address: The billing address is the address associated with your credit card—it is used to verify your credit card information.


1 Answers

I suppose, that Address is the address of consul agent and ServiceAddress is the address which is used to access this service. This can be the same addresses, but they can also differ.

For example, you can have a single host with a number of interfaces, one of them is used to make Consul agents interact with each other, and another one is used to access your service.

Or you can have a single node with a number of microservices deployed with Docker. You can start a single Consul Agent with this node's address, and register a number of microservices running in containers and communicated with each other by container inner IP-addresses. In that case, you will get service info where Address is equals to node's IP and ServiceAddress is equals to the IP of the container with service.

like image 199
Stanislav Avatar answered Oct 25 '22 01:10

Stanislav