Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 1 | #!/bin/bash |
Borislav Glozman | 5197e2e | 2017-07-24 10:45:28 +0300 | [diff] [blame^] | 2 | |
| 3 | . $(dirname "$0")/setenv.bash |
| 4 | |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 5 | delete_namespace() { |
Borislav Glozman | 5197e2e | 2017-07-24 10:45:28 +0300 | [diff] [blame^] | 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_registry_key() { |
| 16 | kubectl --namespace $1-$2 delete secret onap-docker-registry-key |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 17 | } |
| 18 | |
| 19 | delete_service() { |
| 20 | kubectl --namespace $1-$2 delete -f ../$2/all-services.yaml |
| 21 | } |
| 22 | |
| 23 | usage() { |
| 24 | cat <<EOF |
| 25 | Usage: $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 |
| 33 | EOF |
| 34 | } |
| 35 | |
| 36 | #MAINs |
| 37 | NS= |
| 38 | INCL_SVC=false |
| 39 | APP= |
| 40 | |
| 41 | while 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 |
| 65 | done |
| 66 | |
| 67 | if [[ -z $NS ]]; then |
| 68 | usage |
| 69 | exit 1 |
| 70 | fi |
| 71 | |
| 72 | if [[ ! -z "$APP" ]]; then |
| 73 | ONAP_APPS=($APP) |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 74 | fi |
| 75 | |
| 76 | printf "\n********** Cleaning up ONAP: ${ONAP_APPS[*]}\n" |
| 77 | |
| 78 | for i in ${ONAP_APPS[@]}; do |
| 79 | |
Borislav Glozman | 5197e2e | 2017-07-24 10:45:28 +0300 | [diff] [blame^] | 80 | # delete the deployments |
| 81 | /bin/bash $i.sh $NS $i 'delete' |
| 82 | |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 83 | if [[ "$INCL_SVC" == true ]]; then |
| 84 | printf "\nDeleting services **********\n" |
| 85 | delete_service $NS $i |
| 86 | delete_namespace $NS $i |
| 87 | fi |
| 88 | |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 89 | done |
| 90 | |
| 91 | |
| 92 | printf "\n********** Gone **********\n" |