Skip to content

Commit 941ba6c

Browse files
committed
Deploy kubernetes Jobs for perf-test and stream-perf-test.
1 parent 5cd50db commit 941ba6c

File tree

1 file changed

+64
-17
lines changed

1 file changed

+64
-17
lines changed

bin/kubectl-rabbitmq

Lines changed: 64 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ USAGE:
6666
List all instances that has the pause reconciliation label
6767
kubectl rabbitmq [-n NAMESPACE | -A] list-pause-reconciliation-instances
6868
69-
Run perf-test against an instance - you can pass as many perf test parameters as you want
69+
Create a Job to run perf-test against an instance - you can pass as many perf test parameters as you want
7070
(see https://rabbitmq.github.io/rabbitmq-perf-test/stable/htmlsingle/ for more details)
7171
kubectl rabbitmq [-n NAMESPACE] perf-test INSTANCE --rate 100
7272
If you want to monitor perf-test, create the following ServiceMonitor:
@@ -82,7 +82,7 @@ USAGE:
8282
matchLabels:
8383
app: perf-test
8484
85-
Run stream-perf-test against an instance - you can pass as many stream perf test parameters as you want
85+
Create a job to run stream-perf-test against an instance - you can pass as many stream perf test parameters as you want
8686
(see https://rabbitmq.github.io/rabbitmq-stream-java-client/snapshot/htmlsingle/ for more details)
8787
kubectl rabbitmq [-n NAMESPACE] stream-perf-test INSTANCE --rate 100
8888
@@ -130,27 +130,74 @@ get_instance_details() {
130130
perf_test() {
131131
get_instance_details "$@"
132132
shift 1
133-
perftestopts=$*
134-
135-
kubectl "$NAMESPACE" run perf-test \
136-
--expose=true \
137-
--port=8080 \
138-
--labels="app=perf-test,run=perf-test" \
139-
--image=pivotalrabbitmq/perf-test \
140-
-- --uri "amqp://${username}:${password}@${service}" \
141-
--metrics-prometheus "$perftestopts"
133+
134+
local perf_test_job_file="perf-test.yml"
135+
set -u
136+
pushd "$(mktemp -d)" || exit 1
137+
{
138+
echo "apiVersion: batch/v1"
139+
echo "kind: Job"
140+
echo "metadata:"
141+
echo " name: perf-test"
142+
echo " labels:"
143+
echo " app: perf-test"
144+
echo "spec:"
145+
echo " completions: 1"
146+
echo " ttlSecondsAfterFinished: 300"
147+
echo " template:"
148+
echo " spec:"
149+
echo " restartPolicy: Never"
150+
echo " containers:"
151+
echo " - name: rabbitmq-perf-test"
152+
echo " image: pivotalrabbitmq/perf-test"
153+
echo " ports:"
154+
echo " - containerPort: 8080"
155+
echo " args:"
156+
echo " - --uri"
157+
echo " - amqp://${username}:${password}@${service}"
158+
echo " - --metrics-prometheus"
159+
for arg in "$@"; do
160+
echo " - $arg"
161+
done
162+
} >"$perf_test_job_file"
163+
164+
kubectl "$NAMESPACE" apply -f "$perf_test_job_file"
165+
popd
142166
}
143167

144168
stream_perf_test() {
145169
get_instance_details "$@"
146170
shift 1
147-
streamperftestopts=$*
148171

149-
kubectl "$NAMESPACE" run stream-perf-test \
150-
--labels="app=stream-perf-test,run=stream-perf-test" \
151-
--image=pivotalrabbitmq/stream-perf-test \
152-
-- --uris "rabbitmq-stream://${username}:${password}@${service}" \
153-
"$streamperftestopts"
172+
local perf_test_job_file="stream-perf-test.yml"
173+
set -u
174+
pushd "$(mktemp -d)" || exit 1
175+
{
176+
echo "apiVersion: batch/v1"
177+
echo "kind: Job"
178+
echo "metadata:"
179+
echo " name: stream-perf-test"
180+
echo " labels:"
181+
echo " app: stream-perf-test"
182+
echo "spec:"
183+
echo " completions: 1"
184+
echo " ttlSecondsAfterFinished: 300"
185+
echo " template:"
186+
echo " spec:"
187+
echo " restartPolicy: Never"
188+
echo " containers:"
189+
echo " - name: rabbitmq-stream-perf-test"
190+
echo " image: pivotalrabbitmq/stream-perf-test"
191+
echo " args:"
192+
echo " - --uris"
193+
echo " - stream://${username}:${password}@${service}"
194+
for arg in "$@"; do
195+
echo " - $arg"
196+
done
197+
} >"$perf_test_job_file"
198+
199+
kubectl "$NAMESPACE" apply -f "$perf_test_job_file"
200+
popd
154201
}
155202

156203
manage() {

0 commit comments

Comments
 (0)