The following `service-defaults` configuration will enable gateways for all Connect services with the name `web`.
The following `service-defaults` configuration will enable gateways for all Connect services with the name "web".
<CodeTabs heading="Example: Enabling gateways per service.">
```hcl
Kind = "service-defaults"
@ -115,11 +127,22 @@ MeshGateway {
}
```
```yaml
Kind: service-defaults
MeshGateway:
- Mode: local
Name: web
```
</CodeTabs>
### Enabling Gateways for a Service Instance
The following [Proxy Service Registration](/docs/connect/registration/service-registration)
definition will enable gateways for the service instance in the `remote` mode.
<CodeTabs heading="Example: Enabling gateways for a service instance.">
```hcl
service {
name = "web-sidecar-proxy"
@ -139,11 +162,9 @@ service {
]
}
}
```
Or alternatively inline with the service definition:
# Or alternatively inline with the service definition:
```hcl
service {
name = "web"
port = 8181
@ -166,10 +187,28 @@ service {
}
```
```yaml
service:
- kind: connect-proxy
name: web-sidecar-proxy
port: 8181
proxy:
- destination_service_name: web
mesh_gateway:
- mode: remote
upstreams:
- datacenter: secondary
destination_name: api
local_bind_port: 100
```
</CodeTabs>
### Enabling Gateways for a Proxy Upstream
The following service definition will enable gateways in the `local` mode for one upstream, the `remote` mode
for a second upstream and will disable gateways for a third upstream.
The following service definition will enable gateways in the `local` mode for one upstream, the `remote` mode for a second upstream and will disable gateways for a third upstream.
<CodeTabs heading="Example: Enabling gateways for a proxy upstream.">
The following `service-defaults` configuration will enable gateways for all Connect services with the name `web`.
<CodeTabs heading="Example: Enabling gateways per service.">
```hcl
Kind = "service-defaults"
Name = "web"
@ -99,11 +110,21 @@ MeshGateway {
}
```
```yaml
Kind: service-defaults
MeshGateway:
- Mode: local
Name: web
```
</CodeTabs>
### Enabling Gateways for a Service Instance
The following [Proxy Service Registration](/docs/connect/registration/service-registration)
definition will enable gateways for `web` service instances in the `finance` partition.
<CodeTabs heading="Example: Enabling gateways for a service instance.">
```hcl
service {
name = "web-sidecar-proxy"
@ -127,10 +148,30 @@ service {
}
```
```yaml
service:
- kind: connect-proxy
name: web-sidecar-proxy
port: 8181
proxy:
- destination_service_name: web
mesh_gateway:
- mode: local
upstreams:
- destination_name: billing
destination_namespace: default
destination_partition: finance
destination_type: service
local_bind_port: 9090
```
</CodeTabs>
### Enabling Gateways for a Proxy Upstream
The following service definition will enable gateways in `local` mode for three different partitions. Note that each service exists in the same namepace, but are separated by admin partition.
<CodeTabs heading="Example: Enabling gateways for a proxy upstream.">