-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_performance_collection.sh
50 lines (42 loc) · 1.36 KB
/
run_performance_collection.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
#!/bin/bash
show_help () {
echo "usage: run_performance_collection.sh <pod_name> <namespace>"
}
if [[ $# -eq 0 ]] ; then
echo 'No arguments supplied'
show_help
exit 1
fi
if [ -z "$1" ]
then
echo "Application to debug not supplied"
show_help
exit 1
fi
if [ -z "$2" ]
then
echo "Namespace not supplied"
show_help
exit 1
fi
if [ "$#" -ne 2 ]; then
echo "Illegal number of parameters. I just need the name of the pod you want to debug and its namespace"
show_help
exit 1
fi
echo "Deleting performance-debugger pod if it exists..."
kubectl delete pod performance-debugger --force --grace-period=0 > /dev/null 2>&1
app_to_debug=$(kubectl get pod $1 -o custom-columns=":metadata.name" -n $2)
if [ -z "$app_to_debug" ]; then
echo "No pod found with name $1"
exit 1
fi
debugger_container=$(kubectl debug $1 --image=jandroavicloud/performance-debugger:latest --share-processes --copy-to=performance-debugger -n $2 | egrep -io 'debugger-[a-zA-Z0-9]*')
echo "${debugger_container} created..."
echo "Gathering performance data..."
sleep 80
echo "Copying data to your current directory..."
kubectl cp -c $debugger_container performance-debugger:/scripts/performance_output.tar.gz performance_output.tar.gz -n $2
echo "Done!"
echo "Deleting performance-debugger pod"
kubectl delete pod performance-debugger --force --grace-period=0 -n $2