Last week I gave a presentation “When to use Serverless? When to use Kubernetes?” One of the weaknesses of Serverless platforms is that you currently cannot do things like A/B testing well since there is no notion of versions.
A/B testing allows running multiple variants of functionality in parallel, so that through analytics of user behavior the better variant can be determined. Similarly with ‘dark launches’ new features can be made available to only certain users to test features in production environments before these features will be released to the masses.
These traffic flow management capabilities are one of the advantages of Kubernetes and Istio. Istio is an open platform to manage microservices.
Some of my colleagues have documented how to do traffic flow management with Istio for the Book Info sample that is part of the Istio documentation. The current documentation is for Istio 0.1.6 and doesn’t work for the later version 0.5.0 which I use. I’ve sent a pull request, since some URLs have changed.
The diagram shows the architecture of the book info sample app. Books have reviews and can have ratings. The application has three versions of the review service. The gray components on the left hand side are the Istio components. When the sample application is deployed, further Istio components, the Envoy containers, are automatically added to each pod. These Envoy components are proxies (also called side cars) through which containers communicate with each other which is the basis for Istio’s traffic management capabilities.
Check out the bookinfo.yaml file how to define and deploy the three versions of the review service.
In order to route traffic to version 1 for 50% of the invocations and to version 3 for the other half, this route rule can be used.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
apiVersion: config.istio.io/v1alpha2
kind: RouteRule
metadata:
name: reviews-default
spec:
destination:
name: reviews
precedence: 1
route:
- labels:
version: v1
weight: 50
- labels:
version: v3
weight: 50
In order to expose version 2 to only users with the name ‘Jason’, a regular expression can be used.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
apiVersion: config.istio.io/v1alpha2
kind: RouteRule
metadata:
name: reviews-test-v2
spec:
destination:
name: reviews
precedence: 2
match:
request:
headers:
cookie:
regex: "^(.*?;)?(user=jason)(;.*)?$"
route:
- labels:
version: v2
To learn more about traffic management in Istio, check out the documentation. If you want to try out Kubernetes, you can get an account on the IBM Cloud.