hashicorp / hashicorp/consul

consul service mesh sidecar proxy - how to globally configure sidecar?

Open
#21,241 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
30.1k
Forks
4.6k
Avg merge
2d 6h
Merged PRs (30d)
43

Description

In the configuration of Consul service mesh sidecar proxies, I have an example (serviceA.json):

```
{
  "service": {
    "name": "serviceA",
    "port": 8001,
    "connect": {
      "sidecar_service": {
        "proxy": {
          "upstreams": [
            {
              "destination_name": "serviceB",
              "local_bind_port": 9001
            },
            {
              "destination_name": "serviceC",
              "local_bind_port": 9003
            }
          ]
        }
      }
    },
    "check": {
      "http": "http://localhost:8001/health",
      "interval": "10s"
    }
  }
}
```

This configuration file indicates that the service serviceA listens on port 8001, and it needs to access serviceB through the sidecar proxy on port 9001, and access serviceC through the sidecar proxy on port 9003. However, if I have many services, writing the upstreams configuration in each service would be cumbersome. Is there a way to configure a global sidecar proxy ports so that it applies to each service?

I tried to create a file: proxy-defaults.json in consul.d dir(consul config dir):
```
{
"Kind": "proxy-defaults",
"Name": "global",
"Config": {
"Proxy": {
"Config": {
"local_service_address": "127.0.0.1",
"upstreams": [
{
"destination_name": "serviceA",
"local_bind_port": 9001
},
{
"destination_name": "serviceC",
"local_bind_port": 9003
}
]
}
}
}
}
```

But I still can't request serviceC through sidecar port in serviceA, what can I do next?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.