Run performance tests for Gravitee.io API Management with K6, Prometheus and Grafana on Kubernetes.
Table of content :
- 1. Architecture
- 2. Results
- 3. Do the tests yourself
- 3.1. Setup
- 3.1.1. [Optional, not recommended] Create a local kubernetes cluster with kind
- 3.1.2. Install Gravitee.io API Management
- 3.1.3. [Optional] Install Gravitee.io Kubernetes Operator (GKO)
- 3.1.4. Install Redis
- 3.1.5. Install K6 Operator
- 3.1.6. Install the upstream API service
- 3.1.7. Install Prometheus
- 3.1.8. Install Grafana
- 3.2. Execute load testings scenarios
- 3.3. Uninstall
- 3.1. Setup
Note
Coming soon, more scenarios and tests running in AWS EKS and GCP GKE.
To perform these tests yourself, you need :
- A Kubernetes cluster with at least 4 worker nodes. For local testing (not recommended, as it is biased and limited), you can use minikube, k3s or kind, for example.
- Kubectl (installation guide)
- Helm (installation guide)
Warning
Using a local Kubernetes cluster is not recommended, as it is biased and limited. Hardware resources will be shared between all components, and the network topology is not representative of a real deployment. However, for small-scale one-off tests, it may be sufficient to validate minimal requirements (a few hundred or even thousands of calls per second).
-
Install kind following the official documentation.
-
Create a kind cluster, with labels on nodes to apply nodeSelector (example).
Customize the cluster by providing the
gravitee-apim-perf-test-cluster.yaml
file :kind create cluster --config kind/gravitee-apim-perf-test-cluster.yaml
Configure kubectl to use this cluster.
kubectl cluster-info --context kind-gravitee-apim-perf-test
List nodes with their labels
kubectl get nodes --show-labels
-
Install Nginx ingress controler, unless you prefer to use Port Forwarding
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml
Use the Helm Chart to install Gravitee.io API Management on Kubernetes.
-
Add and update the
graviteeio
helm repohelm repo add graviteeio https://helm.gravitee.io && \ helm repo update graviteeio
-
Install the Gravitee.io API Management Gateway
Customize the installation by providing the
values.yaml
file :helm install apim -f gio-apim/SIZING/values.yaml graviteeio/apim --create-namespace --namespace gio-apim
If you need to upgrade the deployment after any change in the configuration :
helm upgrade apim -f gio-apim/SIZING/values.yaml graviteeio/apim --namespace gio-apim
Watch all containers come up
kubectl get pods --namespace=gio-apim -l app.kubernetes.io/instance=apim -o wide -w
We will also use the Gravitee.io Kubernetes Operator (GKO) to deploy the APIs used during the performance test.
-
Deploy the Gravitee.io Kubernetes Operator (GKO)
helm install gko graviteeio/gko --create-namespace --namespace gio-apim
Redis is used to store Rate Limits counters.
helm install redis -f redis/values.yaml oci://registry-1.docker.io/bitnamicharts/redis --create-namespace --namespace redis
If you need to upgrade the deployment after any change in the configuration :
helm upgrade redis -f redis/values.yaml oci://registry-1.docker.io/bitnamicharts/redis --namespace redis
-
Add and update the
grafana
helm repohelm repo add grafana https://grafana.github.io/helm-charts && \ helm repo update grafana
-
Install k6 Kubernetes operator
[!NOTE] The k6 operator will by default create a namespace
k6-operator-system
Customize the installation by providing the
values.yaml
file :gravitee-api-management-performance-benchmark/k6/values.yaml
Lines 1 to 2 in 10ce3e2
helm install k6-operator -f k6/values.yaml grafana/k6-operator
-
Deploy the
go-bench-suite
serviceCreate a dedicated namespace to execute the dummy upstream API service
kubectl create ns dummy-upstream-api-service
kubectl apply -f go-bench-suite --namespace=dummy-upstream-api-service
-
Add and update the
bitnami
helm repohelm repo add bitnami https://charts.bitnami.com/bitnami && \ helm repo update bitnami
-
Install Prometheus
Customize the installation by providing the
values.yaml
file :helm install prometheus -f prometheus/values.yaml bitnami/kube-prometheus --create-namespace --namespace prometheus
If you need to upgrade the deployment after any change in the configuration :
helm upgrade prometheus -f prometheus/values.yaml bitnami/kube-prometheus --namespace prometheus
-
Deploy Prometheus datasource and dashboard
kubectl create ns grafana && \ kubectl create secret generic datasource-secret --from-file=./grafana/datasource-secret.yaml -n grafana && \ kubectl create configmap k6-prometheus-dashboard --from-file=./grafana/k6-prometheus-dashboard.json -n grafana
-
Install Grafana
Customize the installation by providing the
values.yaml
file :gravitee-api-management-performance-benchmark/grafana/values.yaml
Lines 1 to 12 in 80aeedb
helm install grafana -f grafana/values.yaml bitnami/grafana --create-namespace --namespace grafana
If you need to upgrade the deployment after any change in the configuration :
helm upgrade grafana -f grafana/values.yaml bitnami/grafana --namespace grafana
make run-test TEST_NAME=your-test-name BASE_URL=url-apim-management-api
Example
make run-test TEST_NAME=2-api-key BASE_URL=http://localhost:50083
- Deploy the API
Warning
In its current version, the CRDs that come with the Kubernetes operator don't allow you to manage API plans and subscriptions. For simple tests that don't require plans and subscriptions, the operator is sufficient and can deploy APIs that contain policies. For more advanced cases, such as API subscriptions protected by API key or JWT plans, you'll need to use the Management API.
- Using the Gravitee.io Kubenertes Operator (GKO)
```sh
kubectl create ns k6-perf-tests
```
```sh
kubectl apply -f scenarios/0-passthrough/api-passthrough-v1.yaml --namespace=gio-apim
kubectl apply -f scenarios/1-mock/apim-mock-v1.yaml --namespace=gio-apim
```
- Using the Management API
To do this, you can use [the Postman collection provided](scenarios/G.io APIm Perf Tests.postman_collection.json) (running the collection or the folders it contains automates these tasks).
If not exposed externally, you can use port-forward to have access to the Management API.
```sh
kubectl port-forward service/apim-api 50083:api --namespace=gio-apim
```
-
Deploy test scripts and execute scenario
Create a dedicated namespace to execute the performance tests
kubectl create ns k6-perf-tests
Deploy the k6 test script to a configmap
kubectl create configmap your-test-name --from-file scenarios/your-test-folder/your-test-script.js -n k6-perf-tests
Deploy the k6 Test Run resource, this will trigger the k6 operator and create a job running k6 runner(s).
kubectl apply -f scenarios/your-test-folder/your-k6-testrun.yaml -n k6-perf-tests
At the end of the load testings scenario delete both resources.
kubectl delete configmap your-test-name -n k6-perf-tests && \ kubectl delete -f scenarios/your-test-folder/your-k6-testrun.yaml -n k6-perf-tests
Just delete the used namespaces or the cluster itself.
If you used a local Kubernetes with kind
kind delete cluster --name gravitee-apim-perf-test
Note
If you don't remember the cluster name, you have it in the kind cluster configuration file, or find it with kind get clusters
.