You only need to declare upstream service dependencies in a service’s proxy registration.
For example, lets say we have a service called Dashboard which communicates with a backend service called Counting. You will first need to register the Dashboard service in Consul and declare Counting as an upstream dependency.
name = "dashboard"
# Local port where Dashboard service is listening
port = 9002
upstreams = [
destination_name = "counting"
# Local port where sidecar proxy receives connection
# requests to route to any available instance of the
# counting service
local_bind_port = 5000
When you add a new instance of Service B (in this example, counting) you will register this instance with Consul and also start the service’s sidecar proxy.
# Example counting service registration file
name = "counting"
id = "counting"
# The counting service is accessible by the proxy on port 9003
port = 9003
# This declares the counting service as being Connect-enabled.
# It does not have any upstream dependencies itself.
$ consul services register counting.hcl
Registered service: counting
You will also start the service’s associated sidecar proxy.
consul connect envoy -sidecar-for=counting > counting-proxy.log &
(If you’re running in Kubernetes, the process of registering a service & starting its sidecar can be automated using annotations. See Connect Service Mesh on Kubernetes).
Once the new counting instance is registered and the sidecar is started, Consul will automatically notify the downstream services sidecar proxies of this new instance. No manual updates are necessary.
I hope this is a bit more clear. Check out Secure Service Communication with Consul Service Mesh and Envoy for a more complete guide which walks through this upstream & downstream service registration process.