Skip to content

Commit

Permalink
link and tab fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
boruszak committed Apr 26, 2023
1 parent dae246f commit 3f5c146
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 17 deletions.
100 changes: 84 additions & 16 deletions website/content/docs/connect/config-entries/service-resolver.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,8 @@ The following examples demonstrate common service resolver configuration pattern

The following example creates service subsets based on version metadata:

<CodeTabs tabs={[ "HCL", "Kubernetes YAML", "JSON" ]}>
<Tabs>
<Tab heading="HCL" group="hcl">

```hcl
Kind = "service-resolver"
Expand All @@ -898,6 +899,10 @@ Subsets = {
}
```

</Tab>

<Tab heading="YAML" group="yaml">

```yaml
apiVersion: consul.hashicorp.com/v1alpha1
kind: ServiceResolver
Expand All @@ -912,6 +917,10 @@ spec:
filter: 'Service.Meta.version == v2'
```

</Tab>

<Tab heading="JSON" group="json">

```json
{
"Kind": "service-resolver",
Expand All @@ -928,13 +937,15 @@ spec:
}
```

</CodeTabs>
</Tab>
</Tabs>

### Resolve virtual upstreams

The folowing example uses the [`Redirect` parameter](#redirect) to expose a set of services to another datacenter as a virtual service:

<CodeTabs tabs={[ "HCL", "Kubernetes YAML", "JSON" ]}>
<Tabs>
<Tab heading="HCL" group="hcl">

```hcl
Kind = "service-resolver"
Expand All @@ -945,6 +956,10 @@ Redirect {
}
```

</Tab>

<Tab heading="YAML" group="yaml">

```yaml
apiVersion: consul.hashicorp.com/v1alpha1
kind: ServiceResolver
Expand All @@ -956,6 +971,10 @@ spec:
datacenter: dc2
```

</Tab>

<Tab heading="JSON" group="json">

```json
{
"Kind": "service-resolver",
Expand All @@ -967,13 +986,15 @@ spec:
}
```

</CodeTabs>
</Tab>
</Tabs>

### Failover

The following example enables failover for subset `v2` to `dc2`. All other subsets attempt failover to `dc3`, and when it is not available, to `dc4`:

<CodeTabs tabs={[ "HCL", "Kubernetes YAML", "JSON" ]}>
<Tabs>
<Tab heading="HCL" group="hcl">

```hcl
Kind = "service-resolver"
Expand All @@ -989,6 +1010,10 @@ Failover = {
}
```

</Tab>

<Tab heading="YAML" group="yaml">

```yaml
apiVersion: consul.hashicorp.com/v1alpha1
kind: ServiceResolver
Expand All @@ -1003,6 +1028,10 @@ spec:
datacenters: ['dc3', 'dc4']
```

</Tab>

<Tab heading="JSON" group="json">

```json
{
"Kind": "service-resolver",
Expand All @@ -1019,13 +1048,15 @@ spec:
}
```

</CodeTabs>
</Tab>
</Tabs>

#### Failover targets for federation and cluster peering

The following example enables failover to target a WAN federated datacenter for all service subsets. If the connection to `dc3` times out after 15 seconds, the service failover targets the peer with the establish cluster peering connection instead.

<CodeTabs tabs={[ "HCL", "Kubernetes YAML", "JSON" ]}>
<Tabs>
<Tab heading="HCL" group="hcl">

```hcl
Kind = "service-resolver"
Expand All @@ -1041,6 +1072,10 @@ Failover = {
}
```

</Tab>

<Tab heading="YAML" group="yaml">

```yaml
apiVersion: consul.hashicorp.com/v1alpha1
kind: ServiceResolver
Expand All @@ -1055,6 +1090,10 @@ spec:
- peer: "peer-01"
```

</Tab>

<Tab heading="JSON" group="json">

```json
{
"Kind": "service-resolver",
Expand All @@ -1071,13 +1110,15 @@ spec:
}
```

</CodeTabs>
</Tab>
</Tabs>

#### Failover for all service subsets <EnterpriseAlert inline />

The following example enables failover to the `secondary` namespace in another datacenter for all service subsets.

<CodeTabs tabs={[ "HCL", "Kubernetes YAML", "JSON" ]}>
<Tabs>
<Tab heading="HCL" group="hcl">

```hcl
Kind = "service-resolver"
Expand All @@ -1092,6 +1133,10 @@ Failover = {
}
```

</Tab>

<Tab heading="YAML" group="yaml">

```yaml
apiVersion: consul.hashicorp.com/v1alpha1
kind: ServiceResolver
Expand All @@ -1105,6 +1150,10 @@ spec:
datacenters: ['dc2']
```

</Tab>

<Tab heading="JSON" group="json">

```json
{
"Kind": "service-resolver",
Expand All @@ -1120,15 +1169,15 @@ spec:
}
```

</CodeTabs>

</Tab>
</Tabs>

#### Failover to a namespace <EnterpriseAlert inline />

The following example enables failover to a different namespace in the same datacenter.


<CodeTabs tabs={[ "HCL", "Kubernetes YAML", "JSON" ]}>
<Tabs>
<Tab heading="HCL" group="hcl">

```hcl
Kind = "service-resolver"
Expand All @@ -1143,6 +1192,10 @@ Failover = {
}
```

</Tab>

<Tab heading="YAML" group="yaml">

```yaml
apiVersion: consul.hashicorp.com/v1alpha1
kind: ServiceResolver
Expand All @@ -1156,6 +1209,10 @@ spec:
namespace: 'secondary'
```

</Tab>

<Tab heading="JSON" group="json">

```json
{
"Kind": "service-resolver",
Expand All @@ -1171,13 +1228,15 @@ spec:
}
```

</CodeTabs>
</Tab>
</Tabs>

### Consistent load balancing

The following example applies a Maglev load balancing policy for requests with an `x-user-id` header:

<CodeTabs tabs={[ "HCL", "Kubernetes YAML", "JSON" ]}>
<Tabs>
<Tab heading="HCL" group="hcl">

```hcl
Kind = "service-resolver"
Expand All @@ -1194,6 +1253,10 @@ LoadBalancer = {
}
```

</Tab>

<Tab heading="YAML" group="yaml">

```yaml
apiVersion: consul.hashicorp.com/v1alpha1
kind: ServiceResolver
Expand All @@ -1207,6 +1270,10 @@ spec:
fieldValue: x-user-id
```

</Tab>

<Tab heading="JSON" group="json">

```json
{
"Kind": "service-resolver",
Expand All @@ -1223,4 +1290,5 @@ spec:
}
```

</CodeTabs>
</Tab>
</Tabs>
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ When matching on the HTTP request path, you can only match on one path at a time
| `PathExact` | Specifies the exact path to match on the HTTP request path. When using this field, do not configure `PathPrefix` or `PathRegex` in the same HTTP object. | String | None |
| `PathPrefix` | Specifies the path prefix to match on the HTTP request path. When using this field, do not configure `PathExact` or `PathRegex` in the same HTTP object. | String | None |
| `PathRegex` | Specifies a regular expression to match on the HTTP request path. When using this field, do not configure `PathExact` or `PathPrefix` in the same HTTP object. The syntax for the regular expression field is proxy-specific. When [using Envoy](/consul/docs/connect/proxies/envoy), refer to [the documentation for Envoy v1.11.2 or newer](https://github.com/google/re2/wiki/Syntax) or [the documentation for Envoy v1.11.1 or older](https://en.cppreference.com/w/cpp/regex/ecmascript), depending on the version of Envoy you use. | String | None |
| `Methods` | Specifies HTTP methods that the match applies to. Refer to [`Routes[].Match{}.HTTP{}.Methods`](#routes-march-http-methods) for additional configuration parameters. | List | None |
| `Methods` | Specifies HTTP methods that the match applies to. Refer to [`Routes[].Match{}.HTTP{}.Methods`](#routes-match-http-methods) for additional configuration parameters. | List | None |
| `Header` | Specifies information to match to in the HTTP request header. When using this field, do not configure `Present`, `Exact`, `Prefix`, `Suffix`, or `Regex` in the same HTTP object. You can use only one of these fields at a time when configuring match criteria for HTTP headers, as they are mutually exclusive with one another. Refer to [`Routes[].Match{}.HTTP{}.Header`](#routes-match-http-header) for additional configuration parameters. | List | None |
| `QueryParam` | Specifies information to match to on HTTP query parameters. When using this field, do not configure `Present`, `Exact`, or `Regex` in the same HTTP object. Refer to [`Routes[].Match{}.HTTP{}.QueryParam](#routes-match-http-queryparam) for additional configuration parameters. | List | None |

Expand Down

0 comments on commit 3f5c146

Please sign in to comment.