Skip to content

Commit 1681392

Browse files
committed
Add support for Kubernetes
Signed-off-by: Greg Haskins <greg@manetu.com>
1 parent feae722 commit 1681392

File tree

4 files changed

+123
-4
lines changed

4 files changed

+123
-4
lines changed

Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ RUN \
1313
COPY . .
1414
RUN ls -la && make all
1515

16-
ENV MANETU_URL="ingress.manetu-platform"
16+
ENV MANETU_URL="https://ingress.manetu-platform"
1717
ENV LOG_LEVEL="info"
1818
ENV LOADTEST_CONCURRENCY="64"
1919
ENV LOADTEST_NR="10000"
20-
ENV LOADTEST_QUERY=/etc/manetu/loadtest/examples/label-by-email.sparql
21-
ENV LOADTEST_BINDINGS=/etc/manetu/loadtest/examples/bindings.csv
20+
ENV LOADTEST_QUERY="/etc/manetu/loadtest/examples/label-by-email.sparql"
21+
ENV LOADTEST_BINDINGS="/etc/manetu/loadtest/examples/bindings.csv"
22+
ENV LOADTEST_EXTRA_OPTIONS="--insecure"
2223

2324
COPY target/uberjar/app.j* /usr/local/
2425
COPY docker/entrypoint.sh /usr/local/bin

README.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,93 @@ If successful, the test should display something similar to the following:
9999
|-------------+----------------+-------+--------+--------+--------+--------+--------+--------+--------|
100100
Total Duration: 20403.423232msecs
101101
```
102+
103+
## Running on Kubernetes
104+
105+
The following instructions allow you to deploy this tool into a Kubernetes instance. You would typically use the Kubernetes option to run the tool in close proximity to a Manetu instance running in the same cluster, though this is not strictly required.
106+
107+
Manetu hosts a Docker-based version of this tool on Dockerhub:
108+
109+
[https://hub.docker.com/repository/docker/manetuops/sparql-loadtest/general](https://hub.docker.com/repository/docker/manetuops/sparql-loadtest/general)
110+
111+
We will use this to deploy into Kubernetes.
112+
113+
### Setup
114+
115+
To do so, you must first inject a Personal Access Token to your Manetu instance as a secret into your cluster for the tool to use, like so:
116+
117+
```shell
118+
kubectl create secret generic manetu-sparql-loadtest --from-literal=MANETU_TOKEN=<your token>
119+
```
120+
121+
### Launching the test
122+
123+
Next, we can define a Kubernetes [Job](https://kubernetes.io/docs/concepts/workloads/controllers/job/) like so:
124+
125+
```yaml
126+
apiVersion: batch/v1
127+
kind: Job
128+
metadata:
129+
name: manetu-sparql-loadtest
130+
spec:
131+
template:
132+
spec:
133+
containers:
134+
- name: sparql-loadtest
135+
image: manetuops/sparql-loadtest:0.0.1
136+
imagePullPolicy: Always
137+
env:
138+
- name: MANETU_URL
139+
value: https://ingress.manetu-platform
140+
- name: LOG_LEVEL
141+
value: info
142+
- name: LOADTEST_CONCURRENCY
143+
value: "64"
144+
- name: LOADTEST_NR
145+
value: "10000"
146+
- name: LOADTEST_QUERY
147+
value: "/etc/manetu/loadtest/examples/label-by-email.sparql"
148+
- name: LOADTEST_BINDINGS
149+
value: "/etc/manetu/loadtest/examples/bindings.csv"
150+
envFrom:
151+
- secretRef:
152+
name: manetu-sparql-loadtest
153+
restartPolicy: Never
154+
155+
```
156+
For convenience, this file may be found in this repository as [kubernetes/job.yaml](./kubernetes/job.yaml). You may apply this like so:
157+
158+
```shell
159+
kubectl apply -f kubernetes/job.yaml
160+
```
161+
> N.B. The container supports overriding the query and bindings with the environment variables LOADTEST_QUERY and LOADTEST_BINDINGS, respectively. You may replace the default examples using techniques such as mounting Kubernetes [ConfigMaps as volumes](https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#add-configmap-data-to-a-specific-path-in-the-volume). This is left as an exercise to the reader.
162+
163+
### Obtaining results
164+
165+
You may use 'kubectl logs' to obtain the test results once the run is completed. First, obtain the name of the pod, like so:
166+
167+
```shell
168+
$ kubectl get pods
169+
NAME READY STATUS RESTARTS AGE
170+
manetu-sparql-loadtest-4bmkh 0/1 Completed 0 28m
171+
```
172+
173+
Then, query for the job logs, like so:
174+
175+
```shell
176+
$ kubectl logs manetu-sparql-loadtest-4bmkh
177+
+ exec java -jar /usr/local/app.jar -u https://ingress.manetu-platform -l info --no-progress --insecure --concurrency 64 --nr 10000 --query /etc/manetu/loadtest/examples/label-by-email.sparql --bindings /etc/manetu/loadtest/examples/bindings.csv
178+
2024-10-18T23:51:00.921Z INFO processing 10000 requests with concurrency 64
179+
2024-10-18T23:51:00.943Z INFO Loading bindings from: /etc/manetu/loadtest/examples/bindings.csv
180+
|-------------+----------------+-------+--------+--------+--------+--------+--------+--------+--------|
181+
| Description | Count | Min | Mean | Stddev | P50 | P90 | P99 | Max | Rate |
182+
|-------------+----------------+-------+--------+--------+--------+--------+--------+--------+--------|
183+
| Errors | 0 (0.0%) | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
184+
| Not found | 0 (0.0%) | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
185+
| Successes | 10000 (100.0%) | 26.37 | 109.17 | 42.2 | 109.07 | 144.32 | 186.83 | 586.19 | 489.78 |
186+
| Total | 10000 (100.0%) | 26.37 | 109.17 | 42.2 | 109.07 | 144.32 | 186.83 | 586.19 | 489.78 |
187+
|-------------+----------------+-------+--------+--------+--------+--------+--------+--------+--------|
188+
Total Duration: 20417.142784msecs
189+
```
190+
191+
> Tip: If the job is experiencing errors, you may set LOG_LEVEL to 'trace' to diagnose the problem.

docker/entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
set -eux -o pipefail
44

5-
exec java -jar /usr/local/app.jar -u $MANETU_URL --no-progress -l $LOG_LEVEL --concurrency $LOADTEST_CONCURRENCY --nr $LOADTEST_NR --query $LOADTEST_QUERY --bindings $LOADTEST_BINDINGS
5+
exec java -jar /usr/local/app.jar -u $MANETU_URL -l $LOG_LEVEL --no-progress $LOADTEST_EXTRA_OPTIONS --concurrency $LOADTEST_CONCURRENCY --nr $LOADTEST_NR --query $LOADTEST_QUERY --bindings $LOADTEST_BINDINGS

kubernetes/job.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
apiVersion: batch/v1
2+
kind: Job
3+
metadata:
4+
name: manetu-sparql-loadtest
5+
spec:
6+
template:
7+
spec:
8+
containers:
9+
- name: sparql-loadtest
10+
image: manetuops/sparql-loadtest:0.0.1
11+
imagePullPolicy: Always
12+
env:
13+
- name: MANETU_URL
14+
value: https://ingress.manetu-platform
15+
- name: LOG_LEVEL
16+
value: info
17+
- name: LOADTEST_CONCURRENCY
18+
value: "64"
19+
- name: LOADTEST_NR
20+
value: "10000"
21+
- name: LOADTEST_QUERY
22+
value: "/etc/manetu/loadtest/examples/label-by-email.sparql"
23+
- name: LOADTEST_BINDINGS
24+
value: "/etc/manetu/loadtest/examples/bindings.csv"
25+
envFrom:
26+
- secretRef:
27+
name: manetu-sparql-loadtest
28+
restartPolicy: Never

0 commit comments

Comments
 (0)