blob: 33ecb320e50d7a322d893a1272c2de0449e322c2 [file] [log] [blame]
Mandeep Khindad6ea9872017-06-24 11:49:37 -04001#!/bin/bash
Borislav Glozman5197e2e2017-07-24 10:45:28 +03002
3. $(dirname "$0")/setenv.bash
4
Mandeep Khindad6ea9872017-06-24 11:49:37 -04005delete_namespace() {
Borislav Glozman5197e2e2017-07-24 10:45:28 +03006 _NS=$1-$2
7 kubectl delete namespace $_NS
Mandeep Khinda0e8f8892017-08-25 03:31:17 +00008 printf "Waiting for namespace $_NS termination...\n"
9 while kubectl get namespaces $_NS > /dev/null 2>&1; do
10 sleep 2
11 done
Borislav Glozman5197e2e2017-07-24 10:45:28 +030012 printf "Namespace $_NS deleted.\n\n"
13}
14
15delete_registry_key() {
Mandeep Khinda0e8f8892017-08-25 03:31:17 +000016 kubectl --namespace $1-$2 delete secret ${1}-docker-registry-key
Mandeep Khindad6ea9872017-06-24 11:49:37 -040017}
18
kerenj74d723a2017-08-22 15:27:04 +000019delete_app_helm() {
20 helm delete $1 --purge
21}
22
Mandeep Khindad6ea9872017-06-24 11:49:37 -040023usage() {
24 cat <<EOF
25Usage: $0 [PARAMs]
26-u : Display usage
27-n [NAMESPACE] : Kubernetes namespace (required)
Mandeep Khindad6ea9872017-06-24 11:49:37 -040028-a [APP] : Specify a specific ONAP component (default: all)
29 from the following choices:
30 sdc, aai ,mso, message-router, robot,
31 vid, sdnc, portal, policy, appc
32EOF
33}
34
35#MAINs
36NS=
37INCL_SVC=false
38APP=
39
40while getopts ":n:u:s:a:" PARAM; do
41 case $PARAM in
42 u)
43 usage
44 exit 1
45 ;;
46 n)
47 NS=${OPTARG}
48 ;;
Mandeep Khindad6ea9872017-06-24 11:49:37 -040049 a)
50 APP=${OPTARG}
51 if [[ -z $APP ]]; then
52 usage
53 exit 1
54 fi
55 ;;
56 ?)
57 usage
58 exit
59 ;;
60 esac
61done
62
63if [[ -z $NS ]]; then
64 usage
65 exit 1
66fi
67
68if [[ ! -z "$APP" ]]; then
kerenj80102842017-08-24 13:54:21 +000069 HELM_APPS=($APP)
Mandeep Khindad6ea9872017-06-24 11:49:37 -040070fi
71
72printf "\n********** Cleaning up ONAP: ${ONAP_APPS[*]}\n"
73
Mandeep Khindad6ea9872017-06-24 11:49:37 -040074
kerenj74d723a2017-08-22 15:27:04 +000075for i in ${HELM_APPS[@]}; do
76
77 delete_app_helm $i
78 delete_namespace $NS $i
79
80done
81
Mandeep Khindad6ea9872017-06-24 11:49:37 -040082
83printf "\n********** Gone **********\n"