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 |
Mandeep Khinda | 0e8f889 | 2017-08-25 03:31:17 +0000 | [diff] [blame^] | 8 | printf "Waiting for namespace $_NS termination...\n" |
| 9 | while kubectl get namespaces $_NS > /dev/null 2>&1; do |
| 10 | sleep 2 |
| 11 | done |
Borislav Glozman | 5197e2e | 2017-07-24 10:45:28 +0300 | [diff] [blame] | 12 | printf "Namespace $_NS deleted.\n\n" |
| 13 | } |
| 14 | |
| 15 | delete_registry_key() { |
Mandeep Khinda | 0e8f889 | 2017-08-25 03:31:17 +0000 | [diff] [blame^] | 16 | kubectl --namespace $1-$2 delete secret ${1}-docker-registry-key |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 17 | } |
| 18 | |
kerenj | 74d723a | 2017-08-22 15:27:04 +0000 | [diff] [blame] | 19 | delete_app_helm() { |
| 20 | helm delete $1 --purge |
| 21 | } |
| 22 | |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 23 | usage() { |
| 24 | cat <<EOF |
| 25 | Usage: $0 [PARAMs] |
| 26 | -u : Display usage |
| 27 | -n [NAMESPACE] : Kubernetes namespace (required) |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 28 | -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 |
| 32 | EOF |
| 33 | } |
| 34 | |
| 35 | #MAINs |
| 36 | NS= |
| 37 | INCL_SVC=false |
| 38 | APP= |
| 39 | |
| 40 | while 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 Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 49 | 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 |
| 61 | done |
| 62 | |
| 63 | if [[ -z $NS ]]; then |
| 64 | usage |
| 65 | exit 1 |
| 66 | fi |
| 67 | |
| 68 | if [[ ! -z "$APP" ]]; then |
kerenj | 8010284 | 2017-08-24 13:54:21 +0000 | [diff] [blame] | 69 | HELM_APPS=($APP) |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 70 | fi |
| 71 | |
| 72 | printf "\n********** Cleaning up ONAP: ${ONAP_APPS[*]}\n" |
| 73 | |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 74 | |
kerenj | 74d723a | 2017-08-22 15:27:04 +0000 | [diff] [blame] | 75 | for i in ${HELM_APPS[@]}; do |
| 76 | |
| 77 | delete_app_helm $i |
| 78 | delete_namespace $NS $i |
| 79 | |
| 80 | done |
| 81 | |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 82 | |
| 83 | printf "\n********** Gone **********\n" |