|
64 | 64 |
|
65 | 65 | 4. With the change synchronized, we should see a new object in ArgoCD and the cluster. Feel free to check those out.
|
66 | 66 |
|
67 |
| -5. Let's now test our pod autoscaler, to do this we want to fire lots of load on the API of pet-battle. This should trigger an autoscale due to the increased load on the pods. `hey` is simple load testing tool that can be run from the command line that will fire lots of load at our endpoint: |
| 67 | +5. Let's now test our pod autoscaler, to do this we want to fire lots of load on the API of pet-battle. This should trigger an autoscale due to the increased load on the pods. `k6` is simple load testing tool that can be run from the command line that will fire lots of load at our endpoint: |
| 68 | + |
| 69 | + First, create the load.js javascript file that defines the load test type to run. |
| 70 | + |
| 71 | + ```javascript |
| 72 | + cat << EOF > /tmp/load.js |
| 73 | + import http from 'k6/http'; |
| 74 | + import { sleep } from 'k6'; |
| 75 | + export default function () { |
| 76 | + http.get('https://$(oc get route/pet-battle-api -n ${TEAM_NAME}-test --template='{{.spec.host}}')/cats'); |
| 77 | + } |
| 78 | + EOF |
| 79 | + ``` |
| 80 | + |
| 81 | + Then, using the `k6` binary, run the load test using more than one virtual user and a defined duration. |
68 | 82 |
|
69 | 83 | ```bash
|
70 |
| - hey -t 30 -c 10 -n 10000 -H "Content-Type: application/json" -m GET https://$(oc get route/pet-battle-api -n ${TEAM_NAME}-test --template='{{.spec.host}}')/cats |
| 84 | + k6 run --insecure-skip-tls-verify --vus 100 --duration 30s /tmp/load.js |
71 | 85 | ```
|
72 | 86 |
|
73 | 87 | Where:
|
74 |
| - * -c: Number of workers to run concurrently (10) |
75 |
| - * -n: Number of requests to run (10,000) |
76 |
| - * -t: Timeout for each request in seconds (30) |
| 88 | + * --vus: Number of virtual users (VUs) to run concurrently (100) |
| 89 | + * --duration: Test duration limit (30s) |
77 | 90 |
|
78 | 91 | 6. While this is running, we should see in OpenShift land the autoscaler is kickin in and spinnin gup additional pods. If you navigate to the pet-battle-api deployment, you should see the replica count has jumped.
|
79 | 92 |
|
|
0 commit comments