3 # Copyright 2019 Minsait - Indra S.A.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 # Author: Jose Manuel Palacios (jmpalacios@minsait.com)
17 # Author: Jose Antonio Martinez (jamartinezv@minsait.com)
20 echo -e "usage: $0 [OPTIONS]"
21 echo -e "Uninstall OSM Monitoring"
23 echo -e " -n <namespace>: use specified kubernetes namespace - default: monitoring"
24 echo -e " --helm : uninstall tiller"
25 echo -e " --debug : debug script"
26 echo -e " -h / --help : print this help"
32 while getopts ":h-:n:" o
; do
42 [ "${OPTARG}" == "help" ] && usage
&& exit 0
43 [ "${OPTARG}" == "helm" ] && HELM
="y" && continue
44 [ "${OPTARG}" == "debug" ] && DEBUG
="y" && continue
45 echo -e "Invalid option: '--$OPTARG'\n" >&2
50 echo -e "Invalid option: '-$OPTARG'\n" >&2
60 echo "NAMESPACE=$NAMESPACE"
65 if [ -n "$DEBUG" ] ; then
72 echo "Deleting dashboards...."
73 kubectl
-n $NAMESPACE delete configmap osm-monitoring-osm-summary-grafana
> /dev
/null
2>&1
74 kubectl
-n $NAMESPACE delete configmap osm-monitoring-osm-nodes-grafana
> /dev
/null
2>&1
75 kubectl
-n $NAMESPACE delete configmap osm-monitoring-prometheus-kafka-exporter-grafana
> /dev
/null
2>&1
76 kubectl
-n $NAMESPACE delete configmap osm-monitoring-prometheus-mysql-exporter-grafana
> /dev
/null
2>&1
77 kubectl
-n $NAMESPACE delete configmap osm-monitoring-prometheus-mongodb-exporter-grafana
> /dev
/null
2>&1
80 echo "Deleting exporters...."
81 helm delete
--purge osm-kafka-exporter
> /dev
/null
2>&1
82 helm delete
--purge osm-mysql-exporter
> /dev
/null
2>&1
83 helm delete
--purge osm-mongodb-exporter
> /dev
/null
2>&1
85 # remove prometheus-operator
86 echo "Deleting prometheus-operator...."
87 helm delete
--purge osm-monitoring
> /dev
/null
2>&1
90 kubectl delete crd prometheusrules.monitoring.coreos.com
> /dev
/null
2>&1
91 kubectl delete crd servicemonitors.monitoring.coreos.com
> /dev
/null
2>&1
92 kubectl delete crd alertmanagers.monitoring.coreos.com
> /dev
/null
2>&1
93 kubectl delete crd prometheuses.monitoring.coreos.com
> /dev
/null
2>&1
94 kubectl delete crd alertmanagers.monitoring.coreos.com
> /dev
/null
2>&1
95 kubectl delete crd podmonitors.monitoring.coreos.com
> /dev
/null
2>&1
97 # Delete monitoring namespace
98 echo "Deleting monitoring namespace...."
99 kubectl delete namespace
$NAMESPACE
101 if [ -n "$HELM" ] ; then
102 sudo helm
reset --force
103 kubectl delete
--namespace kube-system serviceaccount tiller
104 kubectl delete clusterrolebinding tiller-cluster-rule
105 sudo
rm /usr
/local
/bin
/helm