From 681fbe189158b547c600aca3b63909e17780e8d8 Mon Sep 17 00:00:00 2001 From: Jasmin Gacic Date: Thu, 15 Dec 2022 13:06:53 +0100 Subject: [PATCH] initial doc for traffic splitting (#1028) * initial doc for traffic splitting Signed-off-by: jasmingacic * extended traffic splitting docs added it to side bar Signed-off-by: jasmingacic Signed-off-by: jasmingacic --- docs/docs/guides/traffic_splitting.md | 54 +++++++++++++++++++++++++++ docs/sidebars.js | 1 + 2 files changed, 55 insertions(+) create mode 100644 docs/docs/guides/traffic_splitting.md diff --git a/docs/docs/guides/traffic_splitting.md b/docs/docs/guides/traffic_splitting.md new file mode 100644 index 000000000..f9bbcf8b1 --- /dev/null +++ b/docs/docs/guides/traffic_splitting.md @@ -0,0 +1,54 @@ +# Traffic splitting + +Traffic splitting in Kusk allows for traffic to be routed to 2 or more targets for the same API. The traffic to the API or API path will be split between services running different version of the same service. + +## How does Traffic splitting work? + +Setting property `x-kusk.upstreams` allows users to configure several endpoints for the API to which traffic will be split according to the value of `service.weight`. + +```yaml +openapi: 3.0.0 +info: + title: simple-api + version: 0.1.0 +x-kusk: + upstreams: + service: + name: simple-api-servicev1 + namespace: default + port: 80 + weight: 50 + service: + name: simple-api-servicev2 + namespace: test-namespace + port: 80 + weight: 50 +.. +``` + +The sum of the weights must be equal to 100. In this example traffic will be split equaly between services. Any number of services can be used as long the total weight equals to 100. + +To debug easily Kusk will set response header `x-kusk-weighted-cluster:[service_name]` for each weighted service. + +The property `x-kusk.upstreams` is mutually exclusive with `x-kusk.upstream` as well with `x-kusk.validation` will not accept multiple upstreams. + +Upstreams can be combination `service` and `host` where each must have weight value assinged. + +```yaml +openapi: 3.0.0 +info: + title: simple-api + version: 0.1.0 +x-kusk: + upstreams: + service: + name: simple-api-servicev1 + namespace: default + port: 80 + weight: 50 + host: + hostname: simple-api-servicev2 + port: 80 + weight: 50 +.. +``` \ No newline at end of file diff --git a/docs/sidebars.js b/docs/sidebars.js index 668df9883..4f579b428 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -70,6 +70,7 @@ const sidebars = { id: "guides/cors", label: "CORS", }, + "guides/traffic_splitting", "guides/mocking", "guides/validation", "guides/cache",