blob: 3d54aa80aeec1867ca583bdc9e162dad97d9c32c [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
8 printf "Waiting for namespace $_NS termination...\n"
9 while kubectl get namespaces $_NS > /dev/null 2>&1; do
10 sleep 2
11 done
12 printf "Namespace $_NS deleted.\n\n"
13}
14
15delete_registry_key() {
16 kubectl --namespace $1-$2 delete secret onap-docker-registry-key
Mandeep Khindad6ea9872017-06-24 11:49:37 -040017}
18
19delete_service() {
20 kubectl --namespace $1-$2 delete -f ../$2/all-services.yaml
21}
22
23usage() {
24 cat <<EOF
25Usage: $0 [PARAMs]
26-u : Display usage
27-n [NAMESPACE] : Kubernetes namespace (required)
28-s true : Include services (default: false)
29-a [APP] : Specify a specific ONAP component (default: all)
30 from the following choices:
31 sdc, aai ,mso, message-router, robot,
32 vid, sdnc, portal, policy, appc
33EOF
34}
35
36#MAINs
37NS=
38INCL_SVC=false
39APP=
40
41while getopts ":n:u:s:a:" PARAM; do
42 case $PARAM in
43 u)
44 usage
45 exit 1
46 ;;
47 n)
48 NS=${OPTARG}
49 ;;
50 s)
51 INCL_SVC=${OPTARG}
52 ;;
53 a)
54 APP=${OPTARG}
55 if [[ -z $APP ]]; then
56 usage
57 exit 1
58 fi
59 ;;
60 ?)
61 usage
62 exit
63 ;;
64 esac
65done
66
67if [[ -z $NS ]]; then
68 usage
69 exit 1
70fi
71
72if [[ ! -z "$APP" ]]; then
73 ONAP_APPS=($APP)
Mandeep Khindad6ea9872017-06-24 11:49:37 -040074fi
75
76printf "\n********** Cleaning up ONAP: ${ONAP_APPS[*]}\n"
77
78for i in ${ONAP_APPS[@]}; do
79
Borislav Glozman5197e2e2017-07-24 10:45:28 +030080 # delete the deployments
81 /bin/bash $i.sh $NS $i 'delete'
82
Mandeep Khindad6ea9872017-06-24 11:49:37 -040083 if [[ "$INCL_SVC" == true ]]; then
84 printf "\nDeleting services **********\n"
85 delete_service $NS $i
86 delete_namespace $NS $i
87 fi
88
Mandeep Khindad6ea9872017-06-24 11:49:37 -040089done
90
91
92printf "\n********** Gone **********\n"