Quick Start with Knative Tutorial¶
Perform an Iter8-Knative experiment with Canary
testing, Progressive
deployment, and kubectl
based version promotion.
You will create the following resources in this tutorial.
- A Knative app (service) with two versions (revisions).
- A fortio-based traffic generator that simulates user requests.
- An Iter8 experiment that:
- verifies that
candidate
satisfies mean latency, 95th percentile tail latency, and error rateobjectives
- progressively shifts traffic from
baseline
tocandidate
- eventually replaces
baseline
withcandidate
usingkubectl
- verifies that
Before you begin, you will need ...
- Kubernetes cluster. You can setup a local cluster using Minikube or Kind
- kubectl
- Kustomize v3, and
- Go 1.13+
1. Create Kubernetes cluster¶
Create a local Kubernetes cluster or use a managed Kubernetes service from your cloud provider. Ensure that the cluster has sufficient resources, for example, 2 cpus and 4GB of memory.
minikube start
kind create cluster
kubectl cluster-info --context kind-kind
2. Clone Iter8 repo¶
git clone https://github.com/iter8-tools/iter8.git
cd iter8
export ITER8=$(pwd)
3. Install Knative and Iter8¶
Choose a networking layer for Knative.
$ITER8/samples/knative/quickstart/platformsetup.sh istio
$ITER8/samples/knative/quickstart/platformsetup.sh contour
$ITER8/samples/knative/quickstart/platformsetup.sh kourier
This step requires Python. This will install glooctl
binary under $HOME/.gloo
folder.
$ITER8/samples/knative/quickstart/platformsetup.sh gloo
4. Create app versions¶
kubectl apply -f $ITER8/samples/knative/quickstart/baseline.yaml
kubectl apply -f $ITER8/samples/knative/quickstart/experimentalservice.yaml
Look inside baseline.yaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
Look inside experimentalservice.yaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
|
5. Generate requests¶
kubectl wait --for=condition=Ready ksvc/sample-app
URL_VALUE=$(kubectl get ksvc sample-app -o json | jq .status.address.url)
sed "s+URL_VALUE+${URL_VALUE}+g" $ITER8/samples/knative/quickstart/fortio.yaml | kubectl apply -f -
Look inside fortio.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 |
|
6. Create Iter8 experiment¶
kubectl apply -f $ITER8/samples/knative/quickstart/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 50 51 52 53 54 55 |
|
7. Observe experiment¶
Observe the experiment in realtime. Paste commands from the tabs below in separate terminals.
Install iter8ctl. You can change the directory where iter8ctl binary is installed by changing GOBIN below.
GO111MODULE=on GOBIN=/usr/local/bin go get github.com/iter8-tools/iter8ctl@v0.1.0
Periodically describe the experiment.
while clear; do
kubectl get experiment quickstart-exp -o yaml | iter8ctl describe -f -
sleep 4
done
iter8ctl output
iter8ctl output will be similar to the following.
****** Overview ******
Experiment name: quickstart-exp
Experiment namespace: default
Target: default/sample-app
Testing pattern: Canary
Deployment pattern: Progressive
****** Progress Summary ******
Experiment stage: Running
Number of completed iterations: 3
****** Winner Assessment ******
App versions in this experiment: [current candidate]
Winning version: candidate
Recommended baseline: candidate
****** Objective Assessment ******
+--------------------------------+---------+-----------+
| OBJECTIVE | CURRENT | CANDIDATE |
+--------------------------------+---------+-----------+
| mean-latency <= 50.000 | true | true |
+--------------------------------+---------+-----------+
| 95th-percentile-tail-latency | true | true |
| <= 100.000 | | |
+--------------------------------+---------+-----------+
| error-rate <= 0.010 | true | true |
+--------------------------------+---------+-----------+
****** Metrics Assessment ******
+--------------------------------+---------+-----------+
| METRIC | CURRENT | CANDIDATE |
+--------------------------------+---------+-----------+
| request-count | 429.334 | 16.841 |
+--------------------------------+---------+-----------+
| mean-latency (milliseconds) | 0.522 | 0.712 |
+--------------------------------+---------+-----------+
| 95th-percentile-tail-latency | 4.835 | 4.750 |
| (milliseconds) | | |
+--------------------------------+---------+-----------+
| error-rate | 0.000 | 0.000 |
+--------------------------------+---------+-----------+
Running
to Completed
. kubectl get experiment quickstart-exp --watch
kubectl get experiment output
kubectl output will be similar to the following.
NAME TYPE TARGET STAGE COMPLETED ITERATIONS MESSAGE
quickstart-exp Canary default/sample-app Running 1 IterationUpdate: Completed Iteration 1
quickstart-exp Canary default/sample-app Running 2 IterationUpdate: Completed Iteration 2
quickstart-exp Canary default/sample-app Running 3 IterationUpdate: Completed Iteration 3
quickstart-exp Canary default/sample-app Running 4 IterationUpdate: Completed Iteration 4
quickstart-exp Canary default/sample-app Running 5 IterationUpdate: Completed Iteration 5
quickstart-exp Canary default/sample-app Running 6 IterationUpdate: Completed Iteration 6
quickstart-exp Canary default/sample-app Running 7 IterationUpdate: Completed Iteration 7
quickstart-exp Canary default/sample-app Running 8 IterationUpdate: Completed Iteration 8
quickstart-exp Canary default/sample-app Running 9 IterationUpdate: Completed Iteration 9
Running
to Completed
. kubectl get ksvc sample-app -o json --watch | jq .status.traffic
kubectl get ksvc output
kubectl output will be similar to the following.
[
{
"latestRevision": false,
"percent": 45,
"revisionName": "sample-app-v1",
"tag": "current",
"url": "http://current-sample-app.default.example.com"
},
{
"latestRevision": true,
"percent": 55,
"revisionName": "sample-app-v2",
"tag": "candidate",
"url": "http://candidate-sample-app.default.example.com"
}
]
8. Cleanup¶
kubectl delete -f $ITER8/samples/knative/quickstart/fortio.yaml
kubectl delete -f $ITER8/samples/knative/quickstart/experiment.yaml
kubectl delete -f $ITER8/samples/knative/quickstart/experimentalservice.yaml
Understanding what happened
- You created a Knative service with two revisions, sample-app-v1 (
baseline
) and sample-app-v2 (candidate
). - You generated requests for the Knative service using a fortio-job. At the start of the experiment, 100% of the requests are sent to
baseline
and 0% tocandidate
. - You created an Iter8
Canary
experiment withProgressive
deployment pattern. In each iteration, Iter8 observed the mean latency, 95th percentile tail-latency, and error-rate metrics collected by Prometheus, verified thatcandidate
satisfied all theobjectives
specified in the experiment, identifiedcandidate
as thewinner
, progressively shifted traffic frombaseline
tocandidate
and eventually promoted thecandidate
usingkubectl
.- Note: Had
candidate
failed to satisfyobjectives
, thenbaseline
would have been promoted.
- Note: Had