User Segmentation¶
Scenario: SLO validation with user segmentation
User segmentation is the ability to carve out a specific segment of users for an experiment, leaving the rest of the users unaffected by the experiment.
In this tutorial, we will segment users into two groups: those from Wakanda, and others. Users from Wakanda will participate in the experiment: specifically, requests originating in Wakanda may be routed to baseline or candidate; requests that are originating from Wakanda will not participate in the experiment and are routed only to the baseline The experiment is depicted below.
Before you begin...
This tutorial is available for the following K8s stacks.
Please choose the same K8s stack consistently throughout this tutorial. If you wish to switch K8s stacks between tutorials, start from a clean K8s cluster, so that your cluster is correctly setup.
Steps 1 to 3¶
Please follow steps 1 through 3 of the quick start tutorial.
4. Create versions¶
kubectl apply -f $ITER8/samples/knative/user-segmentation/services.yaml
Look inside services.yaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
|
5. Create routing rule¶
kubectl apply -f $ITER8/samples/knative/user-segmentation/routing-rule.yaml
Look inside routing-rule.yaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
|
6. Generate traffic¶
TEMP_DIR=$(mktemp -d)
cd $TEMP_DIR
curl -L https://istio.io/downloadIstio | ISTIO_VERSION=1.8.2 sh -
istio-1.8.2/bin/istioctl kube-inject -f $ITER8/samples/knative/user-segmentation/curl.yaml | kubectl create -f -
cd $ITER8
Look inside curl.yaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
|
7. Create Iter8 experiment¶
kubectl wait --for=condition=Ready ksvc/sample-app-v1
kubectl wait --for=condition=Ready ksvc/sample-app-v2
kubectl apply -f $ITER8/samples/knative/user-segmentation/experiment.yaml
Look inside experiment.yaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
8. Observe experiment¶
Please follow Step 8 of the quick start tutorial to observe the experiment in realtime. Note that the experiment in this tutorial uses a different name from the quick start one. Replace the experiment name quickstart-exp
with request-routing
in your commands. You can also observe traffic by suitably modifying the commands for observing traffic.
Understanding what happened
-
You configured two Knative services corresponding to two versions of your app in
services.yaml
. -
You used
example.com
as the HTTP host in this tutorial.- Note: In your production cluster, use domain(s) that you own in the setup of the virtual service.
-
You set up an Istio virtual service which mapped the Knative services to this custom domain. The virtual service specified the following routing rules: all HTTP requests to
example.com
with their Host header or :authority pseudo-header not set towakanda
would be routed to thebaseline
; those withwakanda
Host header or :authority pseudo-header may be routed tobaseline
andcandidate
. -
The percentage of
wakandan
requests sent tocandidate
is 0% at the beginning of the experiment. -
You generated traffic for
example.com
using acurl
-job with twocurl
-containers to simulate user requests. You injected Istio sidecar injected into it to simulate traffic generation from within the cluster. The sidecar was needed in order to correctly route traffic. One of thecurl
-containers sets thecountry
header field towakanda
, and the other togondor
.- Note: You used Istio version 1.8.2 to inject the sidecar. This version of Istio corresponds to the one installed in Step 3 of the quick start tutorial. If you have a different version of Istio installed in your cluster, change the Istio version during sidecar injection appropriately.
-
You created an Iter8
Canary
experiment withProgressive
deployment pattern to evaluate thecandidate
. In each iteration, Iter8 observed the mean latency, 95th percentile tail-latency, and error-rate metrics collected by Prometheus, and verified that thecandidate
version satisfied all theobjectives
specified in the experiment. It progressively increased the proportion of traffic withcountry: wakanda
header that is routed to thecandidate
.
9. Cleanup¶
kubectl delete -f $ITER8/samples/knative/user-segmentation/experiment.yaml
kubectl delete -f $ITER8/samples/knative/user-segmentation/curl.yaml
kubectl delete -f $ITER8/samples/knative/user-segmentation/routing-rule.yaml
kubectl delete -f $ITER8/samples/knative/user-segmentation/services.yaml