-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.sh
executable file
·52 lines (45 loc) · 1.28 KB
/
manage.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
#!/usr/bin/env bash
# Management script for <del>stashbot</del> grid-deprecation kubernetes processes
# https://github.com/wikimedia/stashbot/blob/master/bin/stashbot.sh
set -e
DEPLOYMENT=grid-deprecation
POD_NAME=grid-deprecation
TOOL_DIR=/data/project/grid-deprecation/www/python/src
KUBECTL=/usr/bin/kubectl
_get_pod() {
$KUBECTL get pods \
--output=jsonpath={.items..metadata.name} \
--selector=name=${POD_NAME}
}
case "$1" in
start)
echo "Starting grid-deprecation k8s deployment..."
$KUBECTL create --validate=true -f ${TOOL_DIR}/k8s/
;;
stop)
echo "Starting grid-deprecation k8s deployment..."
$KUBECTL delete -f ${TOOL_DIR}/k8s/
# FIXME: wait for the pods to stop
;;
restart)
echo "Restarting grid-deprecation pod..."
exec $KUBECTL delete pod $(_get_pod)
;;
status)
echo "Active pods:"
exec $KUBECTL get pods -l name=${POD_NAME}
;;
tail)
exec $KUBECTL logs -f $(_get_pod)
;;
attach)
echo "Attaching to pod..."
exec $KUBECTL exec -i -t $(_get_pod) -- /bin/bash
;;
*)
echo "Usage: $0 {start|stop|restart|status|tail|attach}"
exit 1
;;
esac
exit 0
# vim:ft=sh:sw=4:ts=4:sts=4:et: