docs: Remove YAML service registration examples (#18877)

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.
pull/18898/head^2
Blake Covarrubias 2023-09-19 11:41:16 -07:00 committed by GitHub
parent 70e738ce20
commit a62c75f43c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 246 additions and 137 deletions

View File

@ -103,6 +103,17 @@ spec:
meshGateway: meshGateway:
mode: local mode: local
``` ```
```json
{
"Kind": "proxy-defaults",
"Name": "global",
"MeshGateway": {
"Mode": "local"
}
}
```
</CodeTabs> </CodeTabs>
### Enabling Gateways Per Service ### Enabling Gateways Per Service
@ -129,6 +140,16 @@ spec:
mode: local mode: local
``` ```
```json
{
"Kind": "service-defaults",
"Name": "web",
"MeshGateway": {
"Mode": "local"
}
}
```
</CodeTabs> </CodeTabs>
### Enabling Gateways for a Service Instance ### Enabling Gateways for a Service Instance
@ -167,7 +188,7 @@ service {
sidecar_service { sidecar_service {
proxy { proxy {
mesh_gateway { mesh_gateway {
mode = "remote" mode = "remote"
} }
upstreams = [ upstreams = [
{ {
@ -182,19 +203,27 @@ service {
} }
``` ```
```yaml ```json
service: {
- kind: connect-proxy "service": {
name: web-sidecar-proxy "kind": "connect-proxy",
port: 8181 "name": "web-sidecar-proxy",
proxy: "port": 8181,
- destination_service_name: web "proxy": {
mesh_gateway: "destination_service_name": "web",
- mode: remote "mesh_gateway": {
upstreams: "mode": "remote"
- datacenter: secondary },
destination_name: api "upstreams": [
local_bind_port: 100 {
"destination_name": "api",
"datacenter": "secondary",
"local_bind_port": 10000
}
]
}
}
}
``` ```
</CodeTabs> </CodeTabs>
@ -241,25 +270,39 @@ service {
} }
} }
``` ```
```yaml ```json
service: {
- kind: connect-proxy "service": {
name: web-sidecar-proxy "kind": "connect-proxy",
port: 8181 "name": "web-sidecar-proxy",
proxy: "port": 8181,
- destination_service_name: web "proxy": {
upstreams: "destination_service_name": "web",
- destination_name: api "upstreams": [
local_bind_port: 10000 {
mesh_gateway: "destination_name": "api",
- mode: remote "local_bind_port": 10000,
- destination_name: db "mesh_gateway": {
local_bind_port: 10001 "mode": "remote"
mesh_gateway: }
- mode: local },
- destination_name: logging {
local_bind_port: 10002 "destination_name": "db",
mesh_gateway: "local_bind_port": 10001,
- mode: none "mesh_gateway": {
``` "mode": "local"
}
},
{
"destination_name": "logging",
"local_bind_port": 10002,
"mesh_gateway": {
"mode": "none"
}
}
]
}
}
}
```
</CodeTabs> </CodeTabs>

View File

@ -98,6 +98,16 @@ spec:
mode: local mode: local
``` ```
```json
{
"Kind": "proxy-defaults",
"Name": "global",
"MeshGateway": {
"Mode": "local"
}
}
```
</CodeTabs> </CodeTabs>
### Enabling Gateways Per Service ### Enabling Gateways Per Service
@ -123,6 +133,17 @@ spec:
meshGateway: meshGateway:
mode: local mode: local
``` ```
```json
{
"Kind": "service-defaults",
"Name": "web",
"MeshGateway": {
"Mode": "local"
}
}
```
</CodeTabs> </CodeTabs>
### Enabling Gateways for a Service Instance ### Enabling Gateways for a Service Instance
@ -130,7 +151,7 @@ spec:
The following [proxy service configuration](/consul/docs/connect/proxies/deploy-service-mesh-proxies) The following [proxy service configuration](/consul/docs/connect/proxies/deploy-service-mesh-proxies)
enables gateways for `web` service instances in the `finance` partition. 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 ```hcl
service { service {
@ -155,21 +176,29 @@ service {
} }
``` ```
```yaml ```json
service: {
- kind: connect-proxy "service": {
name: web-sidecar-proxy "kind": "connect-proxy",
port: 8181 "name": "web-sidecar-proxy",
proxy: "port": 8181,
- destination_service_name: web "proxy": {
mesh_gateway: "destination_service_name": "web",
- mode: local "mesh_gateway": {
upstreams: "mode": "local"
- destination_name: billing },
destination_namespace: default "upstreams": [
destination_partition: finance {
destination_type: service "destination_name": "billing",
local_bind_port: 9090 "destination_namespace": "default",
"destination_partition": "finance",
"destination_type": "service",
"local_bind_port": 9090
}
]
}
}
}
``` ```
</CodeTabs> </CodeTabs>
@ -177,7 +206,7 @@ service:
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. 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 ```hcl
service { service {
@ -219,31 +248,45 @@ service {
} }
``` ```
```yaml ```json
service: {
- kind: connect-proxy "service": {
name: web-sidecar-proxy "kind": "connect-proxy",
port: 8181 "name": "web-sidecar-proxy",
proxy: "port": 8181,
- destination_service_name: web "proxy": {
upstreams: "destination_service_name": "web",
- destination_name: api "upstreams": [
destination_namespace: dev {
destination_partition: api "destination_name": "api",
local_bind_port: 10000 "destination_namespace": "dev",
mesh_gateway: "destination_partition": "api",
- mode: local "local_bind_port": 10000,
- destination_name: db "mesh_gateway": {
destination_namespace: dev "mode": "local"
destination_partition: db }
local_bind_port: 10001 },
mesh_gateway: {
- mode: local "destination_name": "db",
- destination_name: logging "destination_namespace": "dev",
destination_namespace: dev "destination_partition": "db",
destination_partition: logging "local_bind_port": 10001,
local_bind_port: 10002 "mesh_gateway": {
mesh_gateway: "mode": "local"
- mode: local }
},
{
"destination_name": "logging",
"destination_namespace": "dev",
"destination_partition": "logging",
"local_bind_port": 10002,
"mesh_gateway": {
"mode": "local"
}
}
]
}
}
}
``` ```
</CodeTabs> </CodeTabs>

View File

@ -113,6 +113,16 @@ spec:
meshGateway: meshGateway:
mode: local mode: local
``` ```
```json
{
"Kind": "proxy-defaults",
"Name": "global",
"MeshGateway": {
"Mode": "local"
}
}
```
</CodeTabs> </CodeTabs>
### Enabling Gateways Per Service ### Enabling Gateways Per Service
@ -139,6 +149,15 @@ spec:
mode: local mode: local
``` ```
```json
{
"Kind": "service-defaults",
"Name": "web",
"MeshGateway": {
"Mode": "local"
}
}
</CodeTabs> </CodeTabs>
### Enabling Gateways for a Service Instance ### Enabling Gateways for a Service Instance
@ -192,19 +211,27 @@ service {
} }
``` ```
```yaml ```json
service: {
- kind: connect-proxy "service": {
name: web-sidecar-proxy "kind": "connect-proxy",
port: 8181 "name": "web-sidecar-proxy",
proxy: "port": 8181,
- destination_service_name: web "proxy": {
mesh_gateway: "destination_service_name": "web",
- mode: remote "mesh_gateway": {
upstreams: "mode": "remote"
- datacenter: secondary },
destination_name: api "upstreams": [
local_bind_port: 100 {
"destination_name": "api",
"datacenter": "secondary",
"local_bind_port": 10000
}
]
}
}
}
``` ```
</CodeTabs> </CodeTabs>
@ -248,25 +275,39 @@ service {
} }
} }
``` ```
```yaml ```json
service: {
- kind: connect-proxy "service": {
name: web-sidecar-proxy "kind": "connect-proxy",
port: 8181 "name": "web-sidecar-proxy",
proxy: "port": 8181,
- destination_service_name: web "proxy": {
upstreams: "destination_service_name": "web",
- destination_name: api "upstreams": [
local_bind_port: 10000 {
mesh_gateway: "destination_name": "api",
- mode: remote "local_bind_port": 10000,
- destination_name: db "mesh_gateway": {
local_bind_port: 10001 "mode": "remote"
mesh_gateway: }
- mode: local },
- destination_name: logging {
local_bind_port: 10002 "destination_name": "db",
mesh_gateway: "local_bind_port": 10001,
- mode: none "mesh_gateway": {
``` "mode": "local"
</CodeTabs> }
},
{
"destination_name": "logging",
"local_bind_port": 10002,
"mesh_gateway": {
"mode": "none"
}
}
]
}
}
}
```
</CodeTabs>

View File

@ -110,26 +110,6 @@ service {
} }
``` ```
</CodeBlockConfig> </CodeBlockConfig>
<CodeBlockConfig heading="service.yaml">
```yaml
service:
- id: redis
meta:
- custom_meta_key: custom_meta_value
name: redis
port: 80
tagged_addresses:
- lan:
- address: 192.168.0.55
port: 8000
wan:
- address: 198.18.0.23
port: 80
tags:
- primary
```
</CodeBlockConfig>
</CodeTabs> </CodeTabs>
### Health checks ### Health checks
@ -427,10 +407,12 @@ service {
``` ```
```json ```json
"service": { {
## ... "service": {
"enable_tag_override": true, ## ...
## ... "enable_tag_override": true,
## ...
}
} }
``` ```