Skip to content

Commit 19e7b82

Browse files
authored
Updated Knative installation and tutorials (#635)
* RBAC profile * Initial changes to platformsetup and quickstart * Updated platform setup and quickstart * Namespace creation as part of platform setup * Improved helm tutorial * Tutorial documentation changes * Updated e2e tests and fortio * fortio updates * Replace 6000s in Fortio with 120s * Fixed e2e tests * Updated e2e tests * source pptx * curl.yaml also fixed to 6000s * Fixed metric analysis tabs and moved up understanding
1 parent 85f1532 commit 19e7b82

32 files changed

+392
-184
lines changed

.github/workflows/knative-e2e-tests.yaml

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,17 @@ jobs:
3838
- name: create Fortio job and create experiment
3939
run: |
4040
export ITER8=$(pwd)
41+
sed -i "s/6000s/120s/g" $ITER8/samples/knative/quickstart/fortio.yaml
4142
URL_VALUE=$(kubectl get ksvc sample-app -o json | jq .status.address.url)
4243
sed "s+URL_VALUE+${URL_VALUE}+g" $ITER8/samples/knative/quickstart/fortio.yaml | kubectl apply -f -
4344
4445
# Wait for Fortio to be ready
4546
pod_name=$(kubectl get pods --selector=job-name=fortio -o jsonpath='{.items[*].metadata.name}')
4647
kubectl wait --for=condition=Ready pods/"$pod_name" --timeout=240s
4748
49+
# Define metrics
50+
kubectl apply -f $ITER8/samples/knative/quickstart/metrics.yaml
51+
4852
# Starting the experiment
4953
kubectl apply -f $ITER8/samples/knative/quickstart/experiment.yaml
5054
@@ -85,16 +89,26 @@ jobs:
8589
helm install --repo https://raw.githubusercontent.com/iter8-tools/iter8/master/samples/knative/canaryprogressive/helm-repo sample-app sample-app --namespace=default
8690
kubectl wait ksvc/sample-app --for condition=Ready --timeout=240s
8791
helm upgrade --install --repo https://raw.githubusercontent.com/iter8-tools/iter8/master/samples/knative/canaryprogressive/helm-repo sample-app sample-app --values=https://raw.githubusercontent.com/iter8-tools/iter8/master/samples/knative/canaryprogressive/experimental-values.yaml --namespace=default
92+
kubectl wait --for=condition=Ready ksvc/sample-app --timeout=240s
8893
8994
- name: Generate requests
9095
run: |
9196
export ITER8=$(pwd)
92-
kubectl wait --for=condition=Ready ksvc/sample-app --timeout=240s
97+
sed -i "s/6000s/120s/g" $ITER8/samples/knative/canaryprogressive/fortio.yaml
9398
URL_VALUE=$(kubectl get ksvc sample-app -o json | jq .status.address.url)
9499
sed "s+URL_VALUE+${URL_VALUE}+g" $ITER8/samples/knative/canaryprogressive/fortio.yaml | kubectl apply -f -
95100
101+
# Wait for Fortio to be ready
102+
pod_name=$(kubectl get pods --selector=job-name=fortio -o jsonpath='{.items[*].metadata.name}')
103+
kubectl wait --for=condition=Ready pods/"$pod_name" --timeout=240s
104+
96105
- name: Create Iter8 experiment
97106
run: |
107+
export ITER8=$(pwd)
108+
109+
# Define metrics
110+
kubectl apply -f $ITER8/samples/knative/quickstart/metrics.yaml
111+
98112
export ITER8=$(pwd)
99113
kubectl apply -f $ITER8/samples/knative/canaryprogressive/experiment.yaml
100114
@@ -133,12 +147,21 @@ jobs:
133147
run: |
134148
export ITER8=$(pwd)
135149
kubectl wait --for=condition=Ready ksvc/sample-app --timeout=240s
150+
sed -i "s/6000s/120s/g" $ITER8/samples/knative/canaryfixedsplit/fortio.yaml
136151
URL_VALUE=$(kubectl get ksvc sample-app -o json | jq .status.address.url)
137-
sed "s+URL_VALUE+${URL_VALUE}+g" $ITER8/samples/knative/canaryfixedsplit/fortio.yaml | kubectl apply -f -
138-
152+
sed "s+URL_VALUE+${URL_VALUE}+g" $ITER8/samples/knative/canaryfixedsplit/fortio.yaml | kubectl apply -f -
153+
154+
# Wait for Fortio to be ready
155+
pod_name=$(kubectl get pods --selector=job-name=fortio -o jsonpath='{.items[*].metadata.name}')
156+
kubectl wait --for=condition=Ready pods/"$pod_name" --timeout=240s
157+
139158
- name: Create Iter8 experiment
140159
run: |
141160
export ITER8=$(pwd)
161+
162+
# Define metrics
163+
kubectl apply -f $ITER8/samples/knative/quickstart/metrics.yaml
164+
142165
kubectl apply -f $ITER8/samples/knative/canaryfixedsplit/experiment.yaml
143166
144167
- name: Sleep until end of experiment
@@ -169,17 +192,26 @@ jobs:
169192
run: |
170193
export ITER8=$(pwd)
171194
kubectl apply -f $ITER8/samples/knative/conformance/baseline.yaml
195+
kubectl wait --for=condition=Ready ksvc/sample-app --timeout=240s
172196
173197
- name: Generate requests
174198
run: |
175199
export ITER8=$(pwd)
176-
kubectl wait --for=condition=Ready ksvc/sample-app --timeout=240s
200+
sed -i "s/6000s/120s/g" $ITER8/samples/knative/conformance/fortio.yaml
177201
URL_VALUE=$(kubectl get ksvc sample-app -o json | jq .status.address.url)
178-
sed "s+URL_VALUE+${URL_VALUE}+g" $ITER8/samples/knative/conformance/fortio.yaml | kubectl apply -f -
179-
202+
sed "s+URL_VALUE+${URL_VALUE}+g" $ITER8/samples/knative/conformance/fortio.yaml | kubectl apply -f -
203+
204+
# Wait for Fortio to be ready
205+
pod_name=$(kubectl get pods --selector=job-name=fortio -o jsonpath='{.items[*].metadata.name}')
206+
kubectl wait --for=condition=Ready pods/"$pod_name" --timeout=240s
207+
180208
- name: Create Iter8 experiment
181209
run: |
182210
export ITER8=$(pwd)
211+
212+
# Define metrics
213+
kubectl apply -f $ITER8/samples/knative/quickstart/metrics.yaml
214+
183215
kubectl apply -f $ITER8/samples/knative/conformance/experiment.yaml
184216
185217
- name: Sleep until end of experiment

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,4 @@ material
118118
site
119119

120120
# backup pptx
121-
~$iter8++images.pptx
121+
~$*.pptx
Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
11
---
22
template: main.html
33
title: Installation
4+
hide:
5+
- toc
46
---
57

68
# Installation
79

8-
## Iter8
9-
10-
Install Iter8 in your Kubernetes cluster as follows. This installation requires [`kubectl`](https://kubernetes.io/docs/tasks/tools/install-kubectl/).
10+
Install Iter8 in your Kubernetes cluster using [Kustomize v3+](https://kubectl.docs.kubernetes.io/installation/kustomize/) as follows.
1111

1212
```shell
13-
export TAG=v0.4.3
14-
curl -s https://raw.githubusercontent.com/iter8-tools/iter8-install/main/install.sh | bash
13+
export TAG=v0.4.5
14+
kustomize build github.com/iter8-tools/iter8-install/core?ref=$TAG | kubectl apply -f -
1515
```
1616

17-
## iter8ctl (optional)
18-
The `iter8ctl` client facilitates real-time observability of Iter8 experiments. Install `iter8ctl` on your local machine as follows. This installation requires Go 1.13+.
17+
The above command installs Iter8's controller and analytics services in the `iter8-system` namespace, the Experiment and Metric CRDs, and the following RBAC permissions.
1918

20-
```shell
21-
GO111MODULE=on GOBIN=/usr/local/bin go get github.com/iter8-tools/[email protected]
22-
```
19+
??? info "Default RBAC Permissions"
20+
| Resource | Permissions | Scope |
21+
| ----- | ---- | ----------- |
22+
| experiments.iter8.tools | get, list, patch, update, watch | Cluster-wide |
23+
| experiments.iter8.tools/status | get, patch, update | Cluster-wide |
24+
| metrics.iter8.tools | get, list | Cluster-wide |
25+
| jobs.batch | create, delete, get, list, watch | Cluster-wide |
26+
| leases.coordination.k8s.io | get, list, watch, create, update, patch, delete | `iter8-system` namespace |
27+
| events | create | `iter8-system` namespace |
28+
| services.serving.knative.dev | get, list, patch, update | Cluster-wide |
29+
| virtualservices.networking.istio.io | get, list, patch, update, create, delete | Cluster-wide |
30+
| destinationrules.networking.istio.io | get, list, patch, update, create, delete | Cluster-wide |

mkdocs/docs/getting-started/quick-start/with-knative.md

Lines changed: 125 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ template: main.html
1919
???+ warning "Before you begin, you will need... "
2020
1. **Kubernetes cluster.** You can also use [Minikube](https://minikube.sigs.k8s.io/docs/) or [Kind](https://kind.sigs.k8s.io/).
2121
2. The `kubectl` CLI. Install `kubectl` [here](https://kubernetes.io/docs/tasks/tools/install-kubectl/).
22-
3. **Go 1.13+** (recommended; required for using `iter8ctl` in [Step 7](/getting-started/quick-start/with-knative/#7-observe-experiment)). Install Go [here](https://golang.org/doc/install).
22+
3. **Go 1.13+** (recommended; required for using `iter8ctl` in [Step 8](/getting-started/quick-start/with-knative/#8-observe-experiment)). Install Go [here](https://golang.org/doc/install).
2323

2424
## 1. Create Kubernetes cluster
2525

@@ -43,21 +43,16 @@ Create a local cluster using Minikube or Kind as follows, or use a managed Kuber
4343

4444
![Resources](../../images/ddresourcepreferences.png)
4545

46-
47-
48-
4946
## 2. Clone Iter8 repo
5047
```shell
5148
git clone https://github.com/iter8-tools/iter8.git
5249
cd iter8
5350
export ITER8=$(pwd)
5451
```
5552

56-
## 3. Install Knative and Iter8
53+
## 3. Install Knative, Iter8, and Prometheus add-on
5754
Knative can work with multiple networking layers. So can Iter8's Knative extension. Choose a networking layer for Knative.
5855

59-
This also installs sample metrics for Knative and Iter8's Prometheus add-on. These optional components are used by the sample experiment below.
60-
6156
=== "Contour"
6257

6358
```shell
@@ -156,28 +151,133 @@ sed "s+URL_VALUE+${URL_VALUE}+g" $ITER8/samples/knative/quickstart/fortio.yaml |
156151
spec:
157152
volumes:
158153
- name: shared
159-
emptyDir: {}
154+
emptyDir: {}
160155
containers:
161156
- name: fortio
162157
image: fortio/fortio
163-
command: ["fortio", "load", "-t", "100s", "-qps", "16","-json", "/shared/fortiooutput.json", $(URL)]
158+
command: ["fortio", "load", "-t", "6000s", "-qps", "16", "-json", "/shared/fortiooutput.json", $(URL)]
164159
env:
165160
- name: URL
166161
value: URL_VALUE
167162
volumeMounts:
168163
- name: shared
169-
mountPath: /shared
170-
# useful for extracting fortiooutput.json out of here
171-
- name: busybox
164+
mountPath: /shared
165+
- name: busybox
172166
image: busybox:1.28
173-
command: ['sh', '-c', 'echo busybox is running! && sleep 600']
167+
command: ['sh', '-c', 'echo busybox is running! && sleep 600']
174168
volumeMounts:
175169
- name: shared
176170
mountPath: /shared
177171
restartPolicy: Never
178172
```
179173

180-
## 6. Launch Iter8 experiment
174+
## 6. Define metrics
175+
Define the Iter8 metrics used in this experiment.
176+
177+
```shell
178+
kubectl apply -f $ITER8/samples/knative/quickstart/metrics.yaml
179+
```
180+
181+
??? info "Look inside metrics.yaml"
182+
```yaml linenums="1"
183+
apiVersion: iter8.tools/v2alpha2
184+
kind: Metric
185+
metadata:
186+
labels:
187+
creator: iter8
188+
name: 95th-percentile-tail-latency
189+
namespace: iter8-knative
190+
spec:
191+
description: 95th percentile tail latency
192+
jqExpression: .data.result[0].value[1] | tonumber
193+
params:
194+
- name: query
195+
value: |
196+
histogram_quantile(0.95, sum(rate(revision_app_request_latencies_bucket{revision_name='$revision'}[${elapsedTime}s])) by (le))
197+
provider: prometheus
198+
sampleSize: request-count
199+
type: Gauge
200+
units: milliseconds
201+
urlTemplate: http://prometheus-operated.iter8-system:9090/api/v1/query
202+
---
203+
apiVersion: iter8.tools/v2alpha2
204+
kind: Metric
205+
metadata:
206+
labels:
207+
creator: iter8
208+
name: error-count
209+
namespace: iter8-knative
210+
spec:
211+
description: Number of error responses
212+
jqExpression: .data.result[0].value[1] | tonumber
213+
params:
214+
- name: query
215+
value: |
216+
sum(increase(revision_app_request_latencies_count{response_code_class!='2xx',revision_name='$revision'}[${elapsedTime}s])) or on() vector(0)
217+
provider: prometheus
218+
type: Counter
219+
urlTemplate: http://prometheus-operated.iter8-system:9090/api/v1/query
220+
---
221+
apiVersion: iter8.tools/v2alpha2
222+
kind: Metric
223+
metadata:
224+
labels:
225+
creator: iter8
226+
name: error-rate
227+
namespace: iter8-knative
228+
spec:
229+
description: Fraction of requests with error responses
230+
jqExpression: .data.result[0].value[1] | tonumber
231+
params:
232+
- name: query
233+
value: |
234+
(sum(increase(revision_app_request_latencies_count{response_code_class!='2xx',revision_name='$revision'}[${elapsedTime}s])) or on() vector(0)) / (sum(increase(revision_app_request_latencies_count{revision_name='$revision'}[${elapsedTime}s])) or on() vector(0))
235+
provider: prometheus
236+
sampleSize: request-count
237+
type: Gauge
238+
urlTemplate: http://prometheus-operated.iter8-system:9090/api/v1/query
239+
---
240+
apiVersion: iter8.tools/v2alpha2
241+
kind: Metric
242+
metadata:
243+
labels:
244+
creator: iter8
245+
name: mean-latency
246+
namespace: iter8-knative
247+
spec:
248+
description: Mean latency
249+
jqExpression: .data.result[0].value[1] | tonumber
250+
params:
251+
- name: query
252+
value: |
253+
(sum(increase(revision_app_request_latencies_sum{revision_name='$revision'}[${elapsedTime}s])) or on() vector(0)) / (sum(increase(revision_app_request_latencies_count{revision_name='$revision'}[${elapsedTime}s])) or on() vector(0))
254+
provider: prometheus
255+
sampleSize: request-count
256+
type: Gauge
257+
units: milliseconds
258+
urlTemplate: http://prometheus-operated.iter8-system:9090/api/v1/query
259+
---
260+
apiVersion: iter8.tools/v2alpha2
261+
kind: Metric
262+
metadata:
263+
labels:
264+
creator: iter8
265+
name: request-count
266+
namespace: iter8-knative
267+
spec:
268+
description: Number of requests
269+
jqExpression: .data.result[0].value[1] | tonumber
270+
params:
271+
- name: query
272+
value: |
273+
sum(increase(revision_app_request_latencies_count{revision_name='$revision'}[${elapsedTime}s])) or on() vector(0)
274+
provider: prometheus
275+
type: Counter
276+
urlTemplate: http://prometheus-operated.iter8-system:9090/api/v1/query
277+
```
278+
The `urlTemplate` field in these metrics point to the Prometheus instance that was created in Step 3 above. If you wish to use these metrics in your production/staging/dev/test K8s cluster, change the `urlTemplate` values to match the URL of your Prometheus instance.
279+
280+
## 7. Launch experiment
181281
Launch the Iter8 experiment. Iter8 will orchestrate the canary release of the new version with SLO validation and progressive deployment as specified in the experiment.
182282

183283
```shell
@@ -245,10 +345,10 @@ The process automated by Iter8 during this experiment is depicted below.
245345

246346
![Iter8 automation](../../images/canary-progressive-kubectl-iter8.png)
247347

248-
## 7. Observe experiment
348+
## 8. Observe experiment
249349
Observe the experiment in realtime. Paste commands from the tabs below in separate terminals.
250350

251-
=== "iter8ctl"
351+
=== "Metrics-based analysis"
252352
Install `iter8ctl`. You can change the directory where `iter8ctl` binary is installed by changing `GOBIN` below.
253353
```shell
254354
GO111MODULE=on GOBIN=/usr/local/bin go get github.com/iter8-tools/[email protected]
@@ -319,7 +419,7 @@ Observe the experiment in realtime. Paste commands from the tabs below in separa
319419

320420
As the experiment progresses, you should eventually see that all of the objectives reported as being satisfied by both versions. The candidate is identified as the winner and is recommended for promotion. When the experiment completes (in ~2 mins), you will see the experiment stage change from `Running` to `Completed`.
321421

322-
=== "kubectl get experiment"
422+
=== "Experiment progress"
323423

324424
```shell
325425
kubectl get experiment quickstart-exp --watch
@@ -342,7 +442,7 @@ Observe the experiment in realtime. Paste commands from the tabs below in separa
342442

343443
When the experiment completes (in ~ 2 mins), you will see the experiment stage change from `Running` to `Completed`.
344444

345-
=== "kubectl get ksvc"
445+
=== "Traffic split"
346446

347447
```shell
348448
kubectl get ksvc sample-app -o json --watch | jq .status.traffic
@@ -370,15 +470,15 @@ Observe the experiment in realtime. Paste commands from the tabs below in separa
370470
```
371471
As the experiment progresses, you should see traffic progressively shift from `sample-app-v1` to `sample-app-v2`. When the experiment completes, all of the traffic will be sent to the winner, `sample-app-v2`.
372472

373-
## 8. Cleanup
374-
```shell
375-
kubectl delete -f $ITER8/samples/knative/quickstart/fortio.yaml
376-
kubectl delete -f $ITER8/samples/knative/quickstart/experiment.yaml
377-
kubectl delete -f $ITER8/samples/knative/quickstart/experimentalservice.yaml
378-
```
379-
380473
???+ info "Understanding what happened"
381474
1. You created a Knative service with two revisions, `sample-app-v1` (baseline) and `sample-app-v2` (candidate).
382475
2. You generated requests for the Knative service using a Fortio job. At the start of the experiment, 100% of the requests are sent to the baseline and 0% to the candidate.
383476
3. You created an Iter8 experiment with canary testing and progressive deployment patterns. In each iteration, Iter8 observed the mean latency, 95th percentile tail-latency, and error-rate metrics collected by Prometheus, verified that the candidate satisfied all objectives, identified the candidate as the winner, progressively shifted traffic from the baseline to the candidate, and eventually promoted the candidate using the `kubectl apply` command embedded within its finish action.
384477
4. Had the candidate failed to satisfy objectives, then the baseline would have been promoted.
478+
479+
## 9. Cleanup
480+
```shell
481+
kubectl delete -f $ITER8/samples/knative/quickstart/fortio.yaml
482+
kubectl delete -f $ITER8/samples/knative/quickstart/experiment.yaml
483+
kubectl delete -f $ITER8/samples/knative/quickstart/experimentalservice.yaml
484+
```
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
814 KB
Binary file not shown.
44.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)