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 " --debug : debug script"
25 echo -e " -h / --help : print this help"
30 while getopts ":h-:n:" o
; do
40 [ "${OPTARG}" == "help" ] && usage
&& exit 0
41 [ "${OPTARG}" == "debug" ] && DEBUG
="y" && continue
42 echo -e "Invalid option: '--$OPTARG'\n" >&2
47 echo -e "Invalid option: '-$OPTARG'\n" >&2
57 echo "NAMESPACE=$NAMESPACE"
61 if [ -n "$DEBUG" ] ; then
68 echo "Deleting dashboards...."
69 kubectl
-n $NAMESPACE delete configmap osm-monitoring-osm-summary-grafana
> /dev
/null
2>&1
70 kubectl
-n $NAMESPACE delete configmap osm-monitoring-osm-nodes-grafana
> /dev
/null
2>&1
71 kubectl
-n $NAMESPACE delete configmap osm-monitoring-prometheus-kafka-exporter-grafana
> /dev
/null
2>&1
72 kubectl
-n $NAMESPACE delete configmap osm-monitoring-prometheus-mysql-exporter-grafana
> /dev
/null
2>&1
73 kubectl
-n $NAMESPACE delete configmap osm-monitoring-prometheus-mongodb-exporter-grafana
> /dev
/null
2>&1
76 echo "Deleting exporters...."
77 helm delete
--purge osm-kafka-exporter
> /dev
/null
2>&1
78 helm delete
--purge osm-mysql-exporter
> /dev
/null
2>&1
79 helm delete
--purge osm-mongodb-exporter
> /dev
/null
2>&1
81 # remove kube-prometheus-stack
82 echo "Deleting kube-prometheus-stack...."
83 helm delete
--purge osm-monitoring
> /dev
/null
2>&1
86 kubectl delete crd prometheusrules.monitoring.coreos.com
> /dev
/null
2>&1
87 kubectl delete crd servicemonitors.monitoring.coreos.com
> /dev
/null
2>&1
88 kubectl delete crd alertmanagers.monitoring.coreos.com
> /dev
/null
2>&1
89 kubectl delete crd prometheuses.monitoring.coreos.com
> /dev
/null
2>&1
90 kubectl delete crd alertmanagers.monitoring.coreos.com
> /dev
/null
2>&1
91 kubectl delete crd podmonitors.monitoring.coreos.com
> /dev
/null
2>&1
94 kubectl
-n kube-system delete service osm-monitoring-kube-promet-coredns
95 kubectl
-n kube-system delete service osm-monitoring-kube-promet-kube-controller-manager
96 kubectl
-n kube-system delete service osm-monitoring-kube-promet-kube-etcd
97 kubectl
-n kube-system delete service osm-monitoring-kube-promet-kube-proxy
98 kubectl
-n kube-system delete service osm-monitoring-kube-promet-kube-scheduler
99 kubectl
-n kube-system delete service osm-monitoring-kube-promet-kubelet
102 kubectl delete validatingwebhookconfigurations.admissionregistration.k8s.io osm-monitoring-kube-promet-admission
103 kubectl delete mutatingwebhookconfigurations.admissionregistration.k8s.io osm-monitoring-kube-promet-admission
105 # Delete monitoring namespace
106 echo "Deleting monitoring namespace...."
107 kubectl delete namespace
$NAMESPACE