Consul Meshgateway Queries

Hi,

I’ve started exploring mesh-gateway, i was able to get gateway up and running and do cross DC calls between service from the example

the above example uses centralized service defaults configuration i.e., enable gateways for the services by default and then setup the service-resolver to route the services to specific datacenter

however i’m more interested in enabling and configuring the gateway per upstream mentioned under
https://www.consul.io/docs/connect/mesh_gateway.html

i tried the configuration mentioned

i was getting
Error communicating with upstream service: Get http://localhost:9091/: read tcp 127.0.0.1:55980->127.0.0.1:9091: read: connection reset by peer error
do i need to any additional step

Service Configuration Example :

service {
  name = "web"
  port = 8181
  connect {
    sidecar_service {
      proxy {
        mesh_gateway {
         mode = "remote"
        }
        upstreams = [
          {
            destination_name = "api"
            datacenter = "secondary"
            local_bind_port = 10000
          }
        ]
      }
    }
  }
}

would like to know the additional steps/configurations needs to be done to enable gateway per upstream?

Two thoughts that I have immediately.

  1. I think you want to use mode = "local" for your mesh gateways. The setup in the demo looks like it requires the local mode of MeshGateways. That is, the web service needs to forward traffic to it’s local mesh gateway, which will then forward it to the remote gateway, which will finally send it to your api service.

  2. In order to declare mesh gateways per upstream, you have to set the mesh_gateway block inside of the upstreams array, like the example here

All that said, I would try something like this, ensuring that your port numbers and service names are correct:

service {
  name = "web"
  port = 8181
  connect {
    sidecar_service {
      proxy {
        upstreams = [
          {
            destination_name = "api"
            datacenter = "secondary"
            local_bind_port = 10000
            mesh_gateway {
               mode = "local"
            }
          }
        ]
      }
    }
  }
}
1 Like