forked from tdihp/dspcap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dspcap-stop
executable file
·35 lines (29 loc) · 774 Bytes
/
dspcap-stop
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
#!/bin/bash
set -e
set -o pipefail
PIDFILE=/var/run/dspcap.pid
KILL_COMMAND="$(cat <<EOF
if [ -f "$PIDFILE" ]; then
echo "killing pcap"
pkill -SIGINT -F$PIDFILE
fi
EOF
)"
TAR_COMMAND="cd /tmp && tar zvc dspcap"
DEL_COMMAND="rm -rf /tmp/dspcap"
NAMESPACE=default
pods=`kubectl get po -n $NAMESPACE -l app=dspcap -o name`
for po in `echo "$pods"`; do
echo "run killing for $po"
kubectl exec -n $NAMESPACE "$po" -- bash -c "$KILL_COMMAND"
done
for po in `echo "$pods"`; do
echo "downloading for $po"
kubectl exec -n $NAMESPACE "$po" -- bash -c "$TAR_COMMAND" | tar zvx
done
for po in `echo "$pods"`; do
echo "cleanup for $po"
kubectl exec -n $NAMESPACE "$po" -- bash -c "$DEL_COMMAND"
done
kubectl delete -n $NAMESPACE ds/dspcap
echo "All done, cheers."