Service Splitter

    The service-splitter config entry kind (ServiceSplitter on Kubernetes) controls how to split incoming Connect requests across different subsets of a single service (like during staged canary rollouts), or perhaps across different services (like during a v2 rewrite or other type of codebase migration).

    If no splitter config is defined for a service it is assumed 100% of traffic flows to a service with the same name and discovery continues on to the resolution stage.

    • Service splitter config entries are a component of L7 Traffic Management.

    • Service splitter config entries are restricted to only services that define their protocol as http-based via a corresponding config entry or globally via proxy-defaults .

    • Any split destination that specifies a different Service field and omits the ServiceSubset field is eligible for further splitting should a splitter be configured for that other service, otherwise resolution proceeds according to any configured .

    Split traffic between two subsets of the same service:

    HCL

    • HCL
    • Kubernetes YAML
    • JSON
    1. apiVersion: consul.hashicorp.com/v1alpha1
    2. kind: ServiceSplitter
    3. metadata:
    4. name: web
    5. spec:
    6. splits:
    7. - weight: 90
    8. - weight: 10
    9. serviceSubset: v2

    Two different services

    Split traffic between two services:

    Service Splitter - 图2

    • HCL
    • Kubernetes YAML
    • JSON
    1. Kind = "service-splitter"
    2. Name = "web"
    3. Splits = [
    4. Weight = 50
    5. # will default to service with same name as config entry ("web")
    6. },
    7. {
    8. Weight = 10
    9. Service = "web-rewrite"
    10. },
    11. ]
    1. {
    2. "Kind": "service-splitter",
    3. "Splits": [
    4. {
    5. "Weight": 50
    6. },
    7. {
    8. "Weight": 50,
    9. }
    10. ]
    11. }

    Service Splitter - 图4

    • - Must be set to service-splitter

    • Name (string: <required>) - Set to the name of the service being configured.

    • (string: "default")

      Enterprise

      - Specifies the namespace the config entry will apply to.

    • Meta (map<string|string>: nil) - Specifies arbitrary KV metadata pairs. Added in Consul 1.8.4.

      • (float32: 0) - A value between 0 and 100 reflecting what portion of traffic should be directed to this split. The smallest representable eight is 1/10000 or .01%

      • Service (string: "") - The service to resolve instead of the default.

      • (string: "") - A named subset of the given service to resolve instead of one defined as that service’s DefaultSubset. If empty the default subset is used.

      • Namespace (string: "")

        Enterprise

        - The namespace to resolve the service from instead of the current namespace. If empty the current namespace is assumed.

    Configuration entries may be protected by .

    Reading a service-splitter config entry requires service:read on the resource.

    Creating, updating, or deleting a service-splitter config entry requires service:write on the resource and on any other service referenced by name in these fields: