Merge "Added initial deployment yamls for UUI"
[oom.git] / kubernetes / oneclick / deleteAll.bash
1 #!/bin/bash
2
3 . $(dirname "$0")/setenv.bash
4
5 delete_namespace() {
6   _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
15 delete_service_account() {
16     kubectl delete clusterrolebinding $1-$2-admin-binding
17     printf "Service account $1-$2-admin-binding deleted.\n\n"
18 }
19
20 delete_registry_key() {
21   kubectl --namespace $1-$2 delete secret ${1}-docker-registry-key
22 }
23
24 delete_app_helm() {
25   helm delete $1-$2 --purge
26 }
27
28 usage() {
29   cat <<EOF
30 Usage: $0 [PARAMs]
31 -u                  : Display usage
32 -n [NAMESPACE]      : Kubernetes namespace (required)
33 -a [APP]            : Specify a specific ONAP component (default: all)
34                       from the following choices:
35                       sdc, aai ,mso, message-router, robot, vid, aaf, uui
36                       sdnc, portal, policy, appc, multicloud, clamp, consul, vnfsdk
37 EOF
38 }
39
40 #MAINs
41 NS=
42 INCL_SVC=false
43 APP=
44
45 while getopts ":n:u:s:a:" PARAM; do
46   case $PARAM in
47     u)
48       usage
49       exit 1
50       ;;
51     n)
52       NS=${OPTARG}
53       ;;
54     a)
55       APP=${OPTARG}
56       if [[ -z $APP ]]; then
57         usage
58         exit 1
59       fi
60       ;;
61     ?)
62       usage
63       exit
64       ;;
65   esac
66 done
67
68 if [[ -z $NS ]]; then
69   usage
70   exit 1
71 fi
72
73 if [[ ! -z "$APP" ]]; then
74   HELM_APPS=($APP)
75 fi
76
77 printf "\n********** Cleaning up ONAP: ${ONAP_APPS[*]}\n"
78
79
80 for i in ${HELM_APPS[@]}; do
81
82   delete_app_helm $NS $i
83   delete_namespace $NS $i
84   delete_service_account $NS $i
85
86 done
87
88
89 printf "\n********** Gone **********\n"