3 . $(dirname "$0")/setenv.bash
7 kubectl delete namespace $_NS
10 delete_service_account() {
11 kubectl delete clusterrolebinding $1-$2-admin-binding
12 printf "Service account $1-$2-admin-binding deleted.\n\n"
15 delete_registry_key() {
16 kubectl --namespace $1-$2 delete secret ${1}-docker-registry-key
20 helm delete $1-$2 --purge
24 printf "Waiting for namespaces termination...\n"
27 for i in ${HELM_APPS[@]}; do
28 kubectl get namespaces $1-$i > /dev/null 2>&1
29 if [ "$?" -eq "0" ]; then
34 if [ "$_STATUS" -eq "0" ]; then
45 -n [NAMESPACE] : Kubernetes namespace (required)
46 -c : kubectl context (default: current context)
47 -y : Skip interactive confirmation (default: no)
48 -a [APP] : Specify a specific ONAP component (default: all)
49 from the following choices:
50 sdc, aai ,mso, message-router, robot, vid, aaf, uui
51 sdnc, portal, policy, appc, multicloud, clamp, consul, vnfsdk
52 -N : Do not wait for deletion of namespace and its objects
61 SKIP_INTERACTIVE_CONFIRMATION=no
64 while getopts ":c:n:u:s:a:yN" PARAM; do
75 if [[ -z $APP ]]; then
84 SKIP_INTERACTIVE_CONFIRMATION=yes
87 KUBECTL_CONTEXT=${OPTARG}
101 if [[ "$SKIP_INTERACTIVE_CONFIRMATION" != yes ]]; then
102 current_kubectl_context=$(kubectl config get-contexts |grep "*" |awk '{print $2}')
103 if test "$KUBECTL_CONTEXT" != "$current_kubectl_context"; then
104 printf "Current kubectl context does not match context specified:\x1b[31m $current_kubectl_context\x1b[0m\n"
105 if [ ! -z "$KUBECTL_CONTEXT" -a "$KUBECTL_CONTEXT" != " " ]; then
106 read -p "Do you wish to switch context to $KUBECTL_CONTEXT and continue?" yn
108 [Yy]* ) kubectl config use-context $KUBECTL_CONTEXT;;
109 * ) printf "Skipping delete...\n"; exit;;
112 printf "You are about to delete deployment from:\x1b[31m $current_kubectl_context\x1b[0m\n"
113 read -p "To continue enter context name: " response
115 if test "$response" != "$current_kubectl_context"
117 printf "Your response does not match current context! Skipping delete ...\n"
124 if [[ ! -z "$APP" ]]; then
128 printf "\n********** Cleaning up ONAP: ${ONAP_APPS[*]}\n"
130 for i in ${HELM_APPS[@]}; do
132 delete_app_helm $NS $i
133 delete_namespace $NS $i
134 delete_service_account $NS $i
138 delete_app_helm $NS "config"
139 kubectl delete namespace $NS
141 if $WAIT_TERMINATE; then
145 printf "\n********** Gone **********\n"