Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
liduan2000 opened this issue May 31, 2024 · 0 comments
Open

Comments

@liduan2000
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant