apiVersion: batch/v1
kind: Job
metadata:
name: iperf-test
spec:
completions: 2
parallelism: 2
completionMode: Indexed
template:
spec:
restartPolicy: Never
containers:
- name: iperf-client
image: networkstatic/iperf3
command:
- /bin/sh
- -c
args:
- |
TARGETS="10.40.23.221 10.40.23.220"
INDEX=$((${JOB_COMPLETION_INDEX}))
TARGET=$(echo $TARGETS | awk -v idx=$((INDEX+1)) '{print $idx}')
echo "Testing target index $INDEX -> $TARGET"
iperf3 -c "$TARGET" -t 30 -J > /results/iperf_${TARGET}.json
echo "Done: $TARGET"
env:
- name: JOB_COMPLETION_INDEX
valueFrom:
fieldRef:
fieldPath: metadata.annotations['batch.kubernetes.io/job-completion-index']
volumeMounts:
- name: results
mountPath: /results
volumes:
- name: results
emptyDir: {}