forked from kayrus/prometheus-kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
undeploy.sh
executable file
·43 lines (36 loc) · 1.19 KB
/
undeploy.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
#!/bin/sh
CDIR=$(cd `dirname "$0"` && pwd)
cd "$CDIR"
print_red() {
printf '%b' "\033[91m$1\033[0m\n"
}
print_green() {
printf '%b' "\033[92m$1\033[0m\n"
}
#KUBECTL_PARAMS="--context=foo"
NAMESPACE=${NAMESPACE:-monitoring}
KUBECTL="kubectl ${KUBECTL_PARAMS} --namespace=\"${NAMESPACE}\""
INSTANCES="daemonset/node-exporter
job/grafana-import-dashboards
deployment/alertmanager
deployment/grafana
deployment/prometheus-deployment
service/alertmanager
service/grafana
service/prometheus-svc
configmap/alertmanager
configmap/alertmanager-templates
configmap/grafana-import-dashboards
configmap/prometheus-configmap
configmap/prometheus-rules
configmap/external-url"
for instance in ${INSTANCES}; do
eval "${KUBECTL} delete --ignore-not-found --now \"${instance}\""
done
PODS=$(eval "${KUBECTL} get pods -o name" | awk '/^pod\/(alertmanager|grafana|prometheus-deployment|node-exporter)-/ {print $1}' | tr '\n' ' ')
while [ ! "${PODS}" = "" ]; do
echo "Waiting 1 second for ${PODS}pods to shutdown..."
sleep 1
eval "${KUBECTL} delete --now ${PODS}"
PODS=$(eval "${KUBECTL} get pods -o name" | awk '/^pod\/(alertmanager|grafana|prometheus-deployment|node-exporter)-/ {print $1}' | tr '\n' ' ')
done