Skip to content

Commit

Permalink
docs: Remove YAML service registration examples (#18877)
Browse files Browse the repository at this point in the history
Remove YAML service registration examples and replace them with JSON.
This is because YAML is not a supported configuration format for the
Consul's agent configuration, nor is it supported by the HTTP API.

This commit replaces the YAML examples with JSON and adds additional
JSON examples where they were missing.
  • Loading branch information
blake authored Sep 19, 2023
1 parent 70e738c commit a62c75f
Show file tree
Hide file tree
Showing 4 changed files with 246 additions and 137 deletions.
113 changes: 78 additions & 35 deletions website/content/docs/connect/gateways/mesh-gateway/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,17 @@ spec:
meshGateway:
mode: local
```
```json
{
"Kind": "proxy-defaults",
"Name": "global",
"MeshGateway": {
"Mode": "local"
}
}
```

</CodeTabs>

### Enabling Gateways Per Service
Expand All @@ -129,6 +140,16 @@ spec:
mode: local
```
```json
{
"Kind": "service-defaults",
"Name": "web",
"MeshGateway": {
"Mode": "local"
}
}
```

</CodeTabs>

### Enabling Gateways for a Service Instance
Expand Down Expand Up @@ -167,7 +188,7 @@ service {
sidecar_service {
proxy {
mesh_gateway {
mode = "remote"
mode = "remote"
}
upstreams = [
{
Expand All @@ -182,19 +203,27 @@ 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
```json
{
"service": {
"kind": "connect-proxy",
"name": "web-sidecar-proxy",
"port": 8181,
"proxy": {
"destination_service_name": "web",
"mesh_gateway": {
"mode": "remote"
},
"upstreams": [
{
"destination_name": "api",
"datacenter": "secondary",
"local_bind_port": 10000
}
]
}
}
}
```

</CodeTabs>
Expand Down Expand Up @@ -241,25 +270,39 @@ service {
}
}
```
```yaml
service:
- kind: connect-proxy
name: web-sidecar-proxy
port: 8181
proxy:
- destination_service_name: web
upstreams:
- destination_name: api
local_bind_port: 10000
mesh_gateway:
- mode: remote
- destination_name: db
local_bind_port: 10001
mesh_gateway:
- mode: local
- destination_name: logging
local_bind_port: 10002
mesh_gateway:
- mode: none
```
```json
{
"service": {
"kind": "connect-proxy",
"name": "web-sidecar-proxy",
"port": 8181,
"proxy": {
"destination_service_name": "web",
"upstreams": [
{
"destination_name": "api",
"local_bind_port": 10000,
"mesh_gateway": {
"mode": "remote"
}
},
{
"destination_name": "db",
"local_bind_port": 10001,
"mesh_gateway": {
"mode": "local"
}
},
{
"destination_name": "logging",
"local_bind_port": 10002,
"mesh_gateway": {
"mode": "none"
}
}
]
}
}
}
```
</CodeTabs>
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@ spec:
mode: local
```
```json
{
"Kind": "proxy-defaults",
"Name": "global",
"MeshGateway": {
"Mode": "local"
}
}
```

</CodeTabs>

### Enabling Gateways Per Service
Expand All @@ -123,14 +133,25 @@ spec:
meshGateway:
mode: local
```
```json
{
"Kind": "service-defaults",
"Name": "web",
"MeshGateway": {
"Mode": "local"
}
}
```

</CodeTabs>

### Enabling Gateways for a Service Instance

The following [proxy service configuration](/consul/docs/connect/proxies/deploy-service-mesh-proxies)
enables gateways for `web` service instances in the `finance` partition.

<CodeTabs heading="Example: Enabling gateways for a service instance.">
<CodeTabs heading="Example: Enabling gateways for a service instance">

```hcl
service {
Expand All @@ -155,29 +176,37 @@ 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
```json
{
"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 namespace, but are separated by admin partition.

<CodeTabs heading="Example: Enabling gateways for a proxy upstream.">
<CodeTabs heading="Example: Enabling gateways for a proxy upstream">

```hcl
service {
Expand Down Expand Up @@ -219,31 +248,45 @@ service {
}
```

```yaml
service:
- kind: connect-proxy
name: web-sidecar-proxy
port: 8181
proxy:
- destination_service_name: web
upstreams:
- destination_name: api
destination_namespace: dev
destination_partition: api
local_bind_port: 10000
mesh_gateway:
- mode: local
- destination_name: db
destination_namespace: dev
destination_partition: db
local_bind_port: 10001
mesh_gateway:
- mode: local
- destination_name: logging
destination_namespace: dev
destination_partition: logging
local_bind_port: 10002
mesh_gateway:
- mode: local
```json
{
"service": {
"kind": "connect-proxy",
"name": "web-sidecar-proxy",
"port": 8181,
"proxy": {
"destination_service_name": "web",
"upstreams": [
{
"destination_name": "api",
"destination_namespace": "dev",
"destination_partition": "api",
"local_bind_port": 10000,
"mesh_gateway": {
"mode": "local"
}
},
{
"destination_name": "db",
"destination_namespace": "dev",
"destination_partition": "db",
"local_bind_port": 10001,
"mesh_gateway": {
"mode": "local"
}
},
{
"destination_name": "logging",
"destination_namespace": "dev",
"destination_partition": "logging",
"local_bind_port": 10002,
"mesh_gateway": {
"mode": "local"
}
}
]
}
}
}
```
</CodeTabs>
Loading

0 comments on commit a62c75f

Please sign in to comment.