Load test HTTP endpoint¶
Run your first Iter8 experiment by load testing a Kubernetes HTTP service and visualizing the performance metrics with an Iter8 Grafana dashboard.
Before you begin
- Ensure that you have a Kubernetes cluster and the
kubectl
CLI. You can create a local Kubernetes cluster using tools like Kind or Minikube. - Deploy the sample HTTP service in the Kubernetes cluster.
kubectl create deploy httpbin --image=kennethreitz/httpbin --port=80 kubectl expose deploy httpbin --port=80
- Have Grafana available. For example, Grafana can be installed on your cluster as follows:
kubectl create deploy grafana --image=grafana/grafana kubectl expose deploy grafana --port=3000
Install Iter8 CLI¶
Install the latest stable release of the Iter8 CLI as follows.
go install github.com/iter8-tools/iter8@v0.16
Install Iter8 controller¶
helm install --repo https://iter8-tools.github.io/iter8 --version 0.1.11 iter8 controller
helm install --repo https://iter8-tools.github.io/iter8 --version 0.1.11 iter8 controller \
--set clusterScoped=true
kubectl apply -k 'https://github.com/iter8-tools/iter8.git/kustomize/controller/namespaceScoped?ref=v0.16.6'
kubectl apply -k 'https://github.com/iter8-tools/iter8.git/kustomize/controller/clusterScoped?ref=v0.16.6'
Launch experiment¶
Launch the Iter8 experiment inside the Kubernetes cluster.
iter8 k launch \
--set "tasks={ready,http}" \
--set ready.deploy=httpbin \
--set ready.service=httpbin \
--set ready.timeout=60s \
--set http.url=http://httpbin.default/get
iter8 k launch \
--set "tasks={ready,http}" \
--set ready.deploy=httpbin \
--set ready.service=httpbin \
--set ready.timeout=60s \
--set http.url=http://httpbin.default/post \
--set http.payloadStr=hello
About this experiment
This experiment consists of two tasks, namely, ready and http.
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
.
View results using Grafana¶
Inspect the metrics using Grafana. If Grafana is deployed to your cluster, port-forward requests as follows:
kubectl port-forward service/grafana 3000:3000
Open Grafana by going to http://localhost:3000.
Add a JSON API data source Iter8
with the following parameters:
- URL:
http://iter8.default:8080/httpDashboard
- Query string:
namespace=default&experiment=default
Create a new dashboard by import. Paste the contents of the http
Grafana dashboard into the text box and load it. Associate it with the JSON API data source defined above.
The Iter8 dashboard will look like the following:
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
Cleanup¶
Remove the Iter8 experiment and the sample app from the Kubernetes cluster.
iter8 k delete
kubectl delete svc/httpbin
kubectl delete deploy/httpbin
Uninstall the Iter8 controller¶
helm delete iter8
kubectl delete -k 'https://github.com/iter8-tools/iter8.git/kustomize/controller/namespaceScoped?ref=v0.16.6'
kubectl delete -k 'https://github.com/iter8-tools/iter8.git/kustomize/controller/clusterScoped?ref=v0.16.6'
Congratulations! You completed your first Iter8 experiment.