Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/alexsjones/smc2021-demo

A demonstration of traffic splitting
https://github.com/alexsjones/smc2021-demo

helm kubernetes linkerd servicemeshcon traffic

Last synced: about 1 month ago
JSON representation

A demonstration of traffic splitting

Awesome Lists containing this project

README

        

## Linkerd traffic splitting πŸ§™πŸΌ

This demonstrates Linkerd's traffic splitting with real code.

- This code deploys 3 Apps with 1 client
- `go-open-api-v2` will start rejecting the client creation calls as it has a change in it's spec.

This example deploys three backends that all operate slightly differently.
We can deploy traffic split to measure their performance...

![images](images/go-openapi.png)

![images](images/splitting.png)

As seen here...

![images](images/split1.png)

And now we see our split traffic ✨

![images](images/split2.png)

### Setup πŸ™‹

- `kind create cluster --image rossgeorgiev/kind-node-arm64:v1.20.0`
- `linkerd install | kubectl apply -f -`
- `linkerd viz install | kubectl apply -f -`
- `kubectl create ns apps`
- `kubectl annotate ns apps "linkerd.io/inject=enabled"`

```
cd demo
./deploy_with_helm.sh
```

```
❯ k get pods -n apps
NAME READY STATUS RESTARTS AGE
go-openapi-client-668b94dbf4-wp46d 2/2 Running 0 2m24s
go-openapi-v1-549c9cb676-kj7z7 2/2 Running 0 2m34s
go-openapi-v2-7bb874cf5b-qbtpf 2/2 Running 0 2m30s
go-openapi-v3-7d4dfcd8d4-fq7vd 2/2 Running 0 115s
```

Apply the traffic split `kubectl apply -f demo/traffic-split.yaml` πŸ’…

#### Code differences with go-openapi-v2

The V2 API decided all users need to state their food preferences for the international buffet. πŸ₯πŸ«‘πŸŒΆπŸ₯’πŸ₯¬

```
#go-openapi-v2
definitions:
User:
type: "object"
required:
- foodPreference
properties:
id:
type: "integer"
format: "int64"
username:
type: "string"
firstName:
type: "string"
lastName:
type: "string"
foodPreference:
type: "string"
```

Let's post to test that new API directly...

```
curl -X POST "http://localhost:8080/v2/user" -H "accept: application/xml" -H "Content-Type: application/json" -d "{ \"email\": \"string\", \"firstName\": \"string\", \"id\": 0, \"lastName\": \"string\", \"password\": \"string\", \"phone\": \"string\", \"userStatus\": 0, \"username\": \"alex\"}"
{"code":602,"message":"foodPreference in body is required"}%
```

Bummer! πŸ™…πŸ½

See that a bunch of stuff is erroring out due to missing field on the User object yay, it works! πŸ‘

```
β”‚ go-openapi-client &{[email protected] Matthew Harris 0 Wilson Cougarfir +243 56 11472 4389 0 Spiritshell} β”‚
β”‚ go-openapi-client Error: [POST /user][422] createUser default β”‚
β”‚ go-openapi-client &{[email protected] Addison Robinson 0 Thomas Painterrust +371 750 5343 155 2 0 Fishersleet} β”‚
β”‚ go-openapi-client Error: [POST /user][422] createUser default β”‚
β”‚ go-openapi-client &{[email protected] Olivia White 0 Thompson Whipwheat +241 665 6 0395302 0 Thiefdark} β”‚
β”‚ go-openapi-client &{[email protected] Madison Miller 0 Davis Touchplanet +972 037 3996359 5 0 Tradergravel} β”‚
β”‚ go-openapi-client Error: [POST /user][422] createUser default β”‚
β”‚ go-openapi-client &{[email protected] William Williams 0 Garcia Binderplume +880 304 77801444 0 Foxrowan} β”‚
β”‚ go-openapi-client Error: [POST /user][422] createUser default β”‚
β”‚ go-openapi-client &{[email protected] Olivia Wilson 0 Williams Salmonoasis +252 4 1543558433 0 Ladysplit} β”‚
β”‚ go-openapi-client Error: [POST /user][422] createUser default β”‚
β”‚ go-openapi-client &{[email protected] Matthew Miller 0 White Volescratch +506 201 753 611 52 0 Whipchrome} β”‚
β”‚ go-openapi-client Error: [POST /user][422] createUser default β”‚
β”‚ go-openapi-client &{[email protected] James Anderson 0 Taylor Butterflysugar +45 33 817 26608 55 0 Cowlbrick} β”‚
β”‚ go-openapi-client &{[email protected] Avery White 0 Thomas Napeshadow +33 73 9182632411 0 Servantharvest} β”‚
β”‚ go-openapi-client &{[email protected] Natalie Jones 0 Robinson Pixieglory +993 85 23550 92 3 2 0 Vulturetulip} β”‚
β”‚ go-openapi-client &{[email protected] Benjamin Thompson 0 White Slicerweak +963 717 1 6 124055 0 Shirttranslucent} β”‚
β”‚ go-openapi-client &{[email protected] Mia Williams 0 Miller Whaleolive +218 53 81547153 6 0 Princessbog}
```

#### Code differences with go-openapi-v3

This backend introduces heavy latency