Skip to content

Commit 0be78a5

Browse files
authored
Add instructions for overriding bindings/query on kubernetes (#5)
Signed-off-by: Greg Haskins <greg@manetu.com>
1 parent dbd80bd commit 0be78a5

File tree

2 files changed

+42
-15
lines changed

2 files changed

+42
-15
lines changed

README.md

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,27 @@ We will use this to deploy into Kubernetes.
112112

113113
### Setup
114114

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:
115+
#### Credentials
116+
117+
You must inject a Personal Access Token to your Manetu instance as a Kubernetes [Secret](https://kubernetes.io/docs/concepts/configuration/secret/) into your cluster for the tool to use, like so:
116118

117119
```shell
118120
kubectl create secret generic manetu-sparql-loadtest --from-literal=MANETU_TOKEN=<your token>
119121
```
120122

123+
#### Query/Bindings data
124+
125+
You must also deploy the query/bindings you wish to use as a Kubernetes [ConfigMap](https://kubernetes.io/docs/concepts/configuration/configmap/). The ConfigMap should have two bindings named 'bindings.csv' and 'query.sparql', which we will use to inject the files into our deployment in the next step.
126+
127+
##### Example
128+
129+
``` shell
130+
kubectl create configmap manetu-sparql-loadtest --from-file=bindings.csv=examples/by-uuid/bindings.csv --from-file=query.sparql=examples/by-uuid/query.sparql
131+
```
132+
121133
### Launching the test
122134

123-
Next, we can define a Kubernetes [Job](https://kubernetes.io/docs/concepts/workloads/controllers/job/) like so:
135+
Next, we can define a Kubernetes [Job](https://kubernetes.io/docs/concepts/workloads/controllers/job/) that leverages our secret/configmap like so:
124136

125137
```yaml
126138
apiVersion: batch/v1
@@ -130,9 +142,10 @@ metadata:
130142
spec:
131143
template:
132144
spec:
145+
restartPolicy: Never
133146
containers:
134147
- name: sparql-loadtest
135-
image: manetuops/sparql-loadtest:0.0.1
148+
image: manetuops/sparql-loadtest:latest
136149
imagePullPolicy: Always
137150
env:
138151
- name: MANETU_URL
@@ -144,25 +157,31 @@ spec:
144157
- name: LOADTEST_NR
145158
value: "10000"
146159
- name: LOADTEST_QUERY
147-
value: "/etc/manetu/loadtest/examples/label-by-email.sparql"
160+
value: "/etc/manetu/loadtest/query.sparql"
148161
- name: LOADTEST_BINDINGS
149-
value: "/etc/manetu/loadtest/examples/bindings.csv"
162+
value: "/etc/manetu/loadtest/bindings.csv"
150163
envFrom:
151164
- secretRef:
152165
name: manetu-sparql-loadtest
153-
restartPolicy: Never
154-
166+
volumeMounts:
167+
- name: data
168+
mountPath: "/etc/manetu/loadtest"
169+
readOnly: true
170+
volumes:
171+
- name: data
172+
configMap:
173+
name: manetu-sparql-loadtest
155174
```
156-
For convenience, this file may be found in this repository as [kubernetes/job.yaml](./kubernetes/job.yaml). You may apply this like so:
175+
176+
For convenience, this file is available in this repository as [kubernetes/job.yaml](./kubernetes/job.yaml). You may apply this like so:
157177
158178
```shell
159179
kubectl apply -f kubernetes/job.yaml
160180
```
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.
162181

163182
### Obtaining results
164183

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:
184+
Once the job is completed, you may use 'kubectl logs' to obtain the test results. First, obtain the name of the pod, like so:
166185

167186
```shell
168187
$ kubectl get pods
@@ -188,4 +207,4 @@ $ kubectl logs manetu-sparql-loadtest-4bmkh
188207
Total Duration: 20417.142784msecs
189208
```
190209

191-
> Tip: If the job is experiencing errors, you may set LOG_LEVEL to 'trace' to diagnose the problem.
210+
> Tip: If the job is experiencing errors, you may set LOG_LEVEL to 'trace' to diagnose the problem.

kubernetes/job.yaml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ metadata:
55
spec:
66
template:
77
spec:
8+
restartPolicy: Never
89
containers:
910
- name: sparql-loadtest
10-
image: manetuops/sparql-loadtest:0.0.1
11+
image: manetuops/sparql-loadtest:latest
1112
imagePullPolicy: Always
1213
env:
1314
- name: MANETU_URL
@@ -19,10 +20,17 @@ spec:
1920
- name: LOADTEST_NR
2021
value: "10000"
2122
- name: LOADTEST_QUERY
22-
value: "/etc/manetu/loadtest/examples/label-by-email.sparql"
23+
value: "/etc/manetu/loadtest/query.sparql"
2324
- name: LOADTEST_BINDINGS
24-
value: "/etc/manetu/loadtest/examples/bindings.csv"
25+
value: "/etc/manetu/loadtest/bindings.csv"
2526
envFrom:
2627
- secretRef:
2728
name: manetu-sparql-loadtest
28-
restartPolicy: Never
29+
volumeMounts:
30+
- name: data
31+
mountPath: "/etc/manetu/loadtest"
32+
readOnly: true
33+
volumes:
34+
- name: data
35+
configMap:
36+
name: manetu-sparql-loadtest

0 commit comments

Comments
 (0)