Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Jeff Boruszak <104028618+boruszak@users.noreply.github.com>
  • Loading branch information
trujillo-adam and boruszak authored Feb 15, 2023
1 parent 71d98bc commit 9ad4c6d
Showing 1 changed file with 48 additions and 42 deletions.
90 changes: 48 additions & 42 deletions website/content/docs/connect/config-entries/service-splitter.mdx
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
---
Page_title: Service Splitter | Configuration Reference
Description: Service splitter config entries are L7 traffic management tools that enable Consul to redirect parts of incoming traffic requests for a specific service.
layout: docs
page_title: Service Splitter Configuration Entry Reference
description: >-
Service splitter configuration entries are L7 traffic management tools for redirecting requests for a service to
multiple instances. Learn how to write `service-splitter` config entries in HCL or YAML with a specification
reference, configuration model, a complete example, and example code by use case.
---

# Service Splitter Configuration Reference

This topic describes how to configure service splitter configuration entries. Configure and apply service splitters to redirect a percentage of incoming traffic requests for a specific service.
This reference page describes the structure and contents of service splitter configuration entries. Configure and apply service splitters to redirect a percentage of incoming traffic requests for a service to one or more specific service instances.

## Configuration model

The following list outlines field hierarchy, language-specific data types, and requirements in a service splitter configuration entry. Click on a property name to view details about the configuration.
The following list outlines field hierarchy, language-specific data types, and requirements in a service splitter configuration entry. Click on a property name to view additional details, including default values.

<Tabs>

Expand Down Expand Up @@ -224,17 +228,17 @@ Specifies the type of configuration entry to implement.
#### Values

- Default: none
- This field is required
- Data type: String value that must be set to `service-splitter` in HCL or `serviceSplitter` in YAML.
- This field is required.
- Data type: String value that must be set to `service-splitter`.

### `Name`

Specifies a name for the configuration entry. The name is metadata that you can use to reference the configuration entry when performing operations, such as reading or writing configuration entry configuration entry settings.
Specifies a name for the configuration entry. The name is metadata that you can use to reference the configuration entry when performing Consul operations, such as applying a configuration entry to a specific cluster.

#### Values

- Default: Name of the node
- This field is required
- Default: Defaults to the name of the node after writing the entry to the Consul server.
- This field is required.
- Data type: String


Expand All @@ -248,6 +252,7 @@ Specifies the [namespace](/consul/docs/enterprise/namespaces) to apply the confi
- Data type: String

### `Partition` <EnterpriseAlert inline />

Specifies the [admin partition](consul/docs/enterprise/admin-partitions) to apply the configuration entry.

#### Values
Expand All @@ -273,10 +278,10 @@ Defines how much traffic to send to sets of service instances during a traffic s
#### Values

- Default: None
- This field is required for defining service splits
- This field is required.
- Data type: list of objects that can contain the following fields:
- `Weight`: The sum of weights for a set of service instances must add up to 100.
- `Service`: This field is required to direct split traffic
- `Service`: This field is required.
- `ServiceSubset`
- `Namespace` <Enterprise inline/>
- `Partition` <Enterprise inline/>
Expand All @@ -290,21 +295,23 @@ Specifies the percentage of traffic sent to the set of service instances specifi
#### Values

- Default: `null`
- This field is required for defining service splits
- Data type: Floating integer from `.01` to `100`
- This field is required.
- Data type: Floating number from `.01` to `100`.

### `Splits[].Service`

Specifies the name of the service to resolve.

#### Values

- Default: The service matching the configuration entry [`Name`](#name) field.
- Default: Inherits the value of the [`Name`](#name) field.
- Data type: String

### `Splits[].ServiceSubset`

Specifies a subset of the service to resolve. This field overrides the `DefaultSubset`.
Specifies a subset of the service to resolve. A service subset assigns a name to a specific subset of discoverable service instances within a datacenter, such as `version2` or `canary`. All services have an unnamed default subset that returns all healthy instances.

You can define service subsets in a [service resolver configuration entry](/consul/docs/connect/config-entries/service-resolver), which are referenced by their names throughout the other configuration entries. This field overrides the default subset value in the service resolver configuration entry.

#### Values

Expand All @@ -313,16 +320,16 @@ Specifies a subset of the service to resolve. This field overrides the `DefaultS

### `Splits[].Namespace` <EnterpriseAlert inline />

Specifies which [namespace](/consul/docs/enterprise/namespaces) to use in the FQDN when resolving the service.
Specifies the [namespace](/consul/docs/enterprise/namespaces) to use in the FQDN when resolving the service.

#### Values

- Default: The namespace specified in the top-level configuration entry.
- Default: Inherits the value of [`Namespace`](#Namespace) from the top-level of the configuration entry.
- Data type: String

### `Splits[].Partition` <EnterpriseAlert inline />

Specifies which [admin partition](/consul/docs/enterprise/admin-partitions) to use in the FQDN when resolving the service.
Specifies the [admin partition](/consul/docs/enterprise/admin-partitions) to use in the FQDN when resolving the service.

#### Values

Expand All @@ -331,7 +338,7 @@ Specifies which [admin partition](/consul/docs/enterprise/admin-partitions) to u

### `Splits[].RequestHeaders`

Specifies a set of HTTP-specific header modification rules that apply to requests routed to the split. You cannot configure request headers if the listener protocol is set to `tcp`. Refer to [Set HTTP Headers](#set-http-headers) for an example configuration.
Specifies a set of HTTP-specific header modification rules applied to requests routed with the service split. You cannot configure request headers if the listener protocol is set to `tcp`. Refer to [Set HTTP Headers](#set-http-headers) for an example configuration.

#### Values

Expand All @@ -351,12 +358,12 @@ The following table describes how to configure values for request headers:

#### Use variable placeholders

For `Add` and `Set`, if the service is configured to use Envoy as the proxy, the value may contain variable placeholders, for example, `%DOWNSTREAM_REMOTE_ADDRESS%` to interpolate dynamic metadata into the value added.
For `Add` and `Set`, if the service is configured to use Envoy as the proxy, the value may contain variables to interpolate dynamic metadata into the value. For example, using the variable `%DOWNSTREAM_REMOTE_ADDRESS%` in your configuration entry allows you to pass a value that is generated when the split occurs.


### `Splits[].ResponseHeaders`

Specifies a set of HTTP-specific header modification rules that apply to responses from the split. You cannot configure request headers if the listener protocol is set to `tcp`. Refer to [Set HTTP Headers](#set-http-headers) for an example configuration.
Specifies a set of HTTP-specific header modification rules applied to responses routed with the service split. You cannot configure request headers if the listener protocol is set to `tcp`. Refer to [Set HTTP Headers](#set-http-headers) for an example configuration.

#### Values

Expand All @@ -376,7 +383,7 @@ The following table describes how to configure values for response headers:

#### Use variable placeholders

For `Add` and `Set`, if the service is configured to use Envoy as the proxy, the value may contain variable placeholders, for example, `%DOWNSTREAM_REMOTE_ADDRESS%` to interpolate dynamic metadata into the value added.
For `Add` and `Set`, if the service is configured to use Envoy as the proxy, the value may contain variables to interpolate dynamic metadata into the value. For example, using the variable `%DOWNSTREAM_REMOTE_ADDRESS%` in your configuration entry allows you to pass a value that is generated when the split occurs.

</Tab>

Expand All @@ -393,17 +400,17 @@ Specifies the type of configuration entry to implement.
#### Values

- Default: none
- This field is required
- Data type: String value that must be set to `serviceSplitter` in YAML.
- This field is required.
- Data type: String value that must be set to `serviceSplitter`.

### `metadata.name`

Specifies a name for the configuration entry. The name is metadata that you can use to reference the configuration entry when performing operations, such as reading or writing configuration entry configuration entry settings.
Specifies a name for the configuration entry. The name is metadata that you can use to reference the configuration entry when performing Consul operations, such as applying a configuration entry to a specific cluster.

#### Values

- Default: Name of the node
- This field is required
- Default: Inherits name from the host node
- This field is required.
- Data type: String


Expand All @@ -423,7 +430,7 @@ Kubernetes-only field that contains all of the configurations for service splitt
#### Values

- Default: none
- This field is required
- This field is required.
- Data type: Object containing [`spec.splits`](#spec-splits) configuration

### `spec.meta`
Expand All @@ -444,10 +451,10 @@ Defines how much traffic to send to sets of service instances during a traffic s
#### Values

- Default: None
- This field is required for defining service splits
- This field is required.
- Data type: list of objects that can contain the following fields:
- `weight`: The sum of weights for a set of service instances must add up to 100.
- `service`: This field is required to direct split traffic
- `weight`: The sum of weights for a set of service instances. The total defined value must add up to 100.
- `service`: This field is required.
- `serviceSubset`
- `namespace` <Enterprise inline/>
- `partition` <Enterprise inline/>
Expand All @@ -461,7 +468,7 @@ Specifies the percentage of traffic sent to the set of service instances specifi
#### Values

- Default: `null`
- This field is required for defining service splits
- This field is required.
- Data type: Floating integer from `.01` to `100`

### `spec.splits[].service`
Expand All @@ -479,12 +486,12 @@ Specifies a subset of the service to resolve. This field overrides the `DefaultS

#### Values

- Default: If empty, the `split` uses the default subset.
- Default: Inherits the name of the default subset.
- Data type: String

### `spec.splits[].namespace` <EnterpriseAlert inline />

Specifies which [namespace](/consul/docs/enterprise/namespaces) to use for resolving the service.
Specifies the [namespace](/consul/docs/enterprise/namespaces) to use when resolving the service.

#### Values

Expand All @@ -497,13 +504,12 @@ Specifies which [admin partition](/consul/docs/enterprise/admin-partitions) to u

#### Values

- Default: By default, the `service-splitter` uses the [admin partition specified in the top-level configuration entry](#spec-partition).
- Default: `default`
- Data type: String


### `spec.splits[].requestHeaders`

Specifies a set of HTTP-specific header modification rules that apply to requests routed to the split. You cannot configure request headers if the listener protocol is set to `tcp`. Refer to [Set HTTP Headers](#set-http-headers) for an example configuration.
Specifies a set of HTTP-specific header modification rules applied to requests routed with the service split. You cannot configure request headers if the listener protocol is set to `tcp`. Refer to [Set HTTP Headers](#set-http-headers) for an example configuration.

#### Values

Expand All @@ -523,11 +529,11 @@ The following table describes how to configure values for request headers:

#### Use variable placeholders

For `add` and `set`, if the service is configured to use Envoy as the proxy, the value may contain variable placeholders, for example, `%DOWNSTREAM_REMOTE_ADDRESS%` to interpolate dynamic metadata into the value added.
For `add` and `set`, if the service is configured to use Envoy as the proxy, the value may contain variables to interpolate dynamic metadata into the value. For example, using the variable `%DOWNSTREAM_REMOTE_ADDRESS%` in your configuration entry allows you to pass a value that is generated when the split occurs.

### `spec.splits[].responseHeaders`

Specifies a set of HTTP-specific header modification rules that apply to responses from the split. You cannot configure request headers if the listener protocol is set to `tcp`. Refer to [Set HTTP Headers](#set-http-headers) for an example configuration.
Specifies a set of HTTP-specific header modification rules applied to responses routed with the service split. You cannot configure request headers if the listener protocol is set to `tcp`. Refer to [Set HTTP Headers](#set-http-headers) for an example configuration.

#### Values

Expand All @@ -547,15 +553,15 @@ The following table describes how to configure values for response headers:

#### Use variable placeholders

For `add` and `set`, if the service is configured to use Envoy as the proxy, the value may contain variable placeholders, for example, `%DOWNSTREAM_REMOTE_ADDRESS%` to interpolate dynamic metadata into the value added.
For `add` and `set`, if the service is configured to use Envoy as the proxy, the value may contain variables to interpolate dynamic metadata into the value. For example, using the variable `%DOWNSTREAM_REMOTE_ADDRESS%` in your configuration entry allows you to pass a value that is generated when the split occurs.

</Tab>

</Tabs>

## Examples

The examples in this section demonstrate common configurations for `service-splitter` configuration entries.
The following examples demonstrate common service splitter configuration patterns for specific use cases.

### Two subsets of same service

Expand Down Expand Up @@ -677,7 +683,7 @@ metadata:
spec:
splits:
- weight: 50
# will default to service with same name as config entry ("web")
# defaults to the service with same name as the configuration entry ("web")
- weight: 50
service: web-rewrite
```
Expand Down

0 comments on commit 9ad4c6d

Please sign in to comment.