Consul: Sidecar Service Registration doc incorrect?

Created on 2 Nov 2018  路  3Comments  路  Source: hashicorp/consul

The docs on https://www.consul.io/docs/connect/proxies/sidecar-service.html say that the proxy registered would have
"proxy": { "destination_service_name": "db", "destination_service_id": "db", "local_service_address": "127.0.0.1", "local_service_port": 9090, }

The example is talking about a "web" service that listens on port 8080. I think that proxy definition should also read "web" and the local_service_port should be pointing to 8080.

themconnect typdocs

Most helpful comment

I think this is similar confusion as pointed out in #4829 and we should potentially take a different approach here in the docs to help make it clearer. Going to leave this open.

All 3 comments

I think this is similar confusion as pointed out in #4829 and we should potentially take a different approach here in the docs to help make it clearer. Going to leave this open.

@pearkes, regarding this doc. I'm pretty convinced its incorrect after going through it and mapping out the work I'm planning on doing.

{
  "name": "web",
  "port": 8080,
  "connect": { "sidecar_service": {} }
}

The above definition _does not_ map to the definition below.

{
  "name": "web",
  "port": 8080,
}
{
  "name": "web-sidecar-proxy",
  "port": 20000,
  "kind": "connect-proxy",
  "checks": [
    {
      "Name": "Connect Sidecar Listening",
      "TCP": "127.0.0.1:20000",
      "Interval": "10s"
    },
    {
      "name": "Connect Sidecar Aliasing web",
      "alias_service": "web"
    }
  ],
  "proxy": {
    "destination_service_name": "db",
    "destination_service_id": "db",
    "local_service_address": "127.0.0.1",
    "local_service_port": 9090,
  }
}

The correct expansion looks like:

{
  "name": "web",
  "port": 8080,
}
{
  "name": "web-sidecar-proxy",
  "port": 20000,
  "kind": "connect-proxy",
  "checks": [
    {
      "Name": "Connect Sidecar Listening",
      "TCP": "127.0.0.1:20000",
      "Interval": "10s"
    },
    {
      "name": "Connect Sidecar Aliasing web",
      "alias_service": "web"
    }
  ],
  "proxy": {
    "destination_service_name": "web",
    "destination_service_id": "web",
    "local_service_address": "127.0.0.1",
    "local_service_port": 8080,
  }
}

I believe this means that a web-sidecar-proxy service will be created listening on port 20000 that will proxy requests going to it to web listening on port 8080 on 127.0.0.1. Other sources of documentation is conflicting with this and it has really caused me some trouble trying to design our system. If this really is incorrect, I ask that it be corrected ASAP to prevent others from experiencing the same confusion.

From your comment #4829, I understand that the sidecar_service defines both the source and destination functions, but the destination functions are clearly defined via the upstreams configuration. It is very clear in the proxies documentation that this section represents the service the sidecar_proxy should be routing to, which is not db on port 9090.

@djenriquez you are exactly right - the mistake is that local_service_port should be 8080 since it should default to the same port used by the _local_ (web) service registration, and that the registered proxy represents web and not db.

Thanks.

Fixed in https://github.com/hashicorp/consul/commit/1b9edd1ebfb1b22d34ee5be71afddc1c325aa27c

Should be live on the site shortly.

Was this page helpful?
0 / 5 - 0 ratings