Skip to content

Commit

Permalink
initial doc for traffic splitting (#1028)
Browse files Browse the repository at this point in the history
* initial doc for traffic splitting

Signed-off-by: jasmingacic <jasmin.gacic@gmail.com>

* extended traffic splitting docs added it to side bar

Signed-off-by: jasmingacic <jasmin.gacic@gmail.com>

Signed-off-by: jasmingacic <jasmin.gacic@gmail.com>
  • Loading branch information
jasmingacic authored Dec 15, 2022
1 parent 4aef646 commit 681fbe1
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
54 changes: 54 additions & 0 deletions docs/docs/guides/traffic_splitting.md
Original file line number Diff line number Diff line change
@@ -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
..
```
1 change: 1 addition & 0 deletions docs/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const sidebars = {
id: "guides/cors",
label: "CORS",
},
"guides/traffic_splitting",
"guides/mocking",
"guides/validation",
"guides/cache",
Expand Down

0 comments on commit 681fbe1

Please sign in to comment.