Skip to content

Your First Experiment

Run your first Iter8 experiment by load testing a Kubernetes HTTP service and validating its service-level objectives (SLOs). This is a single-loop Kubernetes experiment.

Load test HTTP

Before you begin
  1. Ensure that you have a Kubernetes cluster and the kubectl CLI. You can create a local Kubernetes cluster using tools like Kind or Minikube.
  2. Deploy the sample HTTP service in the Kubernetes cluster.
    kubectl create deploy httpbin --image=kennethreitz/httpbin --port=80
    kubectl expose deploy httpbin --port=80
    

Install Iter8 CLI

Install the latest stable release of the Iter8 CLI as follows.

go install github.com/iter8-tools/iter8@v0.14

Launch experiment

Launch the Iter8 experiment inside the Kubernetes cluster.

iter8 k launch \
--set "tasks={ready,http,assess}" \
--set ready.deploy=httpbin \
--set ready.service=httpbin \
--set ready.timeout=60s \
--set http.url=http://httpbin.default/get \
--set assess.SLOs.upper.http/latency-mean=50 \
--set assess.SLOs.upper.http/error-count=0 \
--set runner=job
iter8 k launch \
--set "tasks={ready,http,assess}" \
--set ready.deploy=httpbin \
--set ready.service=httpbin \
--set ready.timeout=60s \
--set http.url=http://httpbin.default/post \
--set http.payloadStr=hello \
--set assess.SLOs.upper.http/latency-mean=50 \
--set assess.SLOs.upper.http/error-count=0 \
--set runner=job
About this experiment

This experiment consists of three tasks, namely, ready, http, and assess.

The ready task checks if the httpbin deployment exists and is available, and the httpbin service exists.

The http task sends requests to the cluster-local HTTP service using the specified url, and collects Iter8's built-in HTTP load test metrics. This tasks supports both GET and POST requests, and for POST requests, a payload can be provided by using either payloadStr or payloadURL.

The assess task verifies if the app satisfies the specified SLOs: i) the mean latency of the service does not exceed 50 msec, and ii) there are no errors (4xx or 5xx response codes) in the responses.

This is a single-loop Kubernetes experiment where all the previously mentioned tasks will run once and the experiment will finish. Hence, its runner value is set to job.


Assert experiment outcomes

Assert that the experiment completed without failures, and all SLOs are satisfied. The timeout flag below specifies a period of 120 sec for assert conditions to be satisfied.

iter8 k assert -c completed -c nofailure -c slos --timeout 120s

If the assert conditions are satisfied, the above command exits with code 0; else, it exits with code 1. Assertions are especially useful inside CI/CD/GitOps pipelines. Depending on the exit code of the assert command, your pipeline can branch into different actions.


View experiment report

iter8 k report
The text report looks like this
Experiment summary:
*******************

  Experiment completed: true
  No task failures: true
  Total number of tasks: 4
  Number of completed tasks: 4

Whether or not service level objectives (SLOs) are satisfied:
*************************************************************

  SLO Conditions                 |Satisfied
  --------------                 |---------
  http/error-count <= 0          |true
  http/latency-mean (msec) <= 50 |true


Latest observed values for metrics:
***********************************

  Metric                     |value
  -------                    |-----
  http/error-count           |0.00
  http/error-rate            |0.00
  http/latency-max (msec)    |19.74
  http/latency-mean (msec)   |5.27
  http/latency-min (msec)    |1.16
  http/latency-p50 (msec)    |4.67
  http/latency-p75 (msec)    |7.00
  http/latency-p90 (msec)    |9.50
  http/latency-p95 (msec)    |11.33
  http/latency-p99 (msec)    |18.00
  http/latency-p99.9 (msec)  |19.56
  http/latency-stddev (msec) |3.28
  http/request-count         |100.00
iter8 k report -o html > report.html # view in a browser
The HTML report looks like this

HTML report


View experiment logs

Logs are useful when debugging an experiment.

iter8 k log
Sample experiment logs
INFO[2022-06-27 11:50:39] inited Helm config                           
INFO[2022-06-27 11:50:39] experiment logs from Kubernetes cluster       indented-trace=below ... 
  time=2022-06-27 15:48:59 level=info msg=task 1: ready: started
  time=2022-06-27 15:48:59 level=info msg=task 1: ready: completed
  time=2022-06-27 15:48:59 level=info msg=task 2: ready: started
  time=2022-06-27 15:48:59 level=info msg=task 2: ready: completed
  time=2022-06-27 15:48:59 level=info msg=task 3: http: started
  time=2022-06-27 15:49:11 level=info msg=task 3: http: completed
  time=2022-06-27 15:49:11 level=info msg=task 4: assess: started
  time=2022-06-27 15:49:11 level=info msg=task 4: assess: completed

Cleanup

Remove the Iter8 experiment and the sample app from the Kubernetes cluster and the local Iter8 charts folder.

iter8 k delete
kubectl delete svc/httpbin
kubectl delete deploy/httpbin


Congratulations! 🎉 You completed your first Iter8 experiment.


Some variations and extensions of this experiment
  1. The http task can be configured with load related parameters such as the number of requests, queries per second, or number of parallel connections.
  2. The http task can be configured to send various types of content as payload.
  3. The assess task can be configured with SLOs for any of Iter8's built-in HTTP load test metrics.