-
Notifications
You must be signed in to change notification settings - Fork 1
/
sequencer-cluster.sh
executable file
·71 lines (58 loc) · 1.54 KB
/
sequencer-cluster.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
#
# Copyright 2024 Hewlett Packard Enterprise Development LP.
#
if [[ -z ${1} ]]; then
echo "Usage: $(basename ${0}) <overlay> <staggered starts in seconds>"
exit 1
fi
if ! mkdir -p ${BENK_OUTPUT_LOCATION:=$(pwd)/logs}; then
echo "Unable to log to ${BENK_OUTPUT_LOCATION}"
exit 1
fi
overlay=kustomize/overlays/${1}
if ! [[ -d ${overlay} ]]; then
echo "Error: overlay (${overlay}) doesn't exist"
exit 1
fi
clusters=$(ls cluster-* | wc -l | awk '{print $1}')
now=$(date +%Y%m%d%H%M%S)
# Non-staggered starts
if [[ -z ${2} ]]; then
for c in cluster-[1-${clusters}]-kubeconfig; do
if ! [[ -e ${c} ]]; then
echo "Error: kubeconfig (${c}) doesn't exist"
exit 1
fi
export KUBECONFIG=${c}
# Replace
kubectl replace --force -k ${overlay} &
done
wait
for c in cluster-[1-${clusters}]-kubeconfig; do
export KUBECONFIG=${c}
# Wait
kubectl wait --for=condition=complete --timeout=7200s -n benk job/benk
# Extract
kubectl -n benk logs job/benk | tee -a ${BENK_OUTPUT_LOCATION}/run-${1}-${c}-${now}.log
done
# Staggered starts
else
for c in cluster-[1-${clusters}]-kubeconfig; do
if ! [[ -e ${c} ]]; then
echo "Error: kubeconfig (${c}) doesn't exist"
exit 1
fi
export KUBECONFIG=${c}
# Replace
kubectl replace --force -k ${overlay}
sleep ${2}
done
for c in cluster-[1-${clusters}]-kubeconfig; do
export KUBECONFIG=${c}
# Wait
kubectl wait --for=condition=complete --timeout=7200s -n benk job/benk
# Extract
kubectl -n benk logs job/benk | tee -a ${BENK_OUTPUT_LOCATION}/run-${1}-${now}.log
done
fi