3 . $(dirname "$0")/setenv.bash
6 kubectl delete namespace $1
9 delete_service_account() {
10 kubectl delete clusterrolebinding $1-admin-binding
13 delete_registry_key() {
14 kubectl --namespace $1 delete secret ${1}-docker-registry-key
18 helm delete $1-$2 --purge
22 printf "Waiting for namespaces termination...\n"
25 for i in ${HELM_APPS[@]}; do
26 kubectl get pods --namespace $1 | grep -w " $i" > /dev/null 2>&1
27 if [ "$?" -ne "0" ]; then
33 if [ "$SINGLE_COMPONENT" == "false" ]; then
34 kubectl get namespaces $1 > /dev/null 2>&1
37 if [ "$_STATUS" -ne "0" ]; then
48 -n [NAMESPACE] : Kubernetes namespace (required)
49 -c : kubectl context (default: current context)
50 -y : Skip interactive confirmation (default: no)
51 -a [APP] : Specify a specific ONAP component (default: all)
52 from the following choices:
53 sdc, aai ,mso, message-router, robot, vid, aaf, uui
54 sdnc, portal, policy, appc, multicloud, clamp, consul, vnfsdk
55 -N : Do not wait for deletion of namespace and its objects
64 SKIP_INTERACTIVE_CONFIRMATION=no
66 SINGLE_COMPONENT=false
67 while getopts ":c:n:u:s:a:yN" PARAM; do
78 if [[ -z $APP ]]; then
88 SKIP_INTERACTIVE_CONFIRMATION=yes
91 KUBECTL_CONTEXT=${OPTARG}
100 if [[ -z $NS ]]; then
105 if [[ "$SKIP_INTERACTIVE_CONFIRMATION" != yes ]]; then
106 current_kubectl_context=$(kubectl config get-contexts |grep "*" |awk '{print $2}')
107 if test "$KUBECTL_CONTEXT" != "$current_kubectl_context"; then
108 printf "Current kubectl context does not match context specified:\x1b[31m $current_kubectl_context\x1b[0m\n"
109 if [ ! -z "$KUBECTL_CONTEXT" -a "$KUBECTL_CONTEXT" != " " ]; then
110 read -p "Do you wish to switch context to $KUBECTL_CONTEXT and continue?" yn
112 [Yy]* ) kubectl config use-context $KUBECTL_CONTEXT;;
113 * ) printf "Skipping delete...\n"; exit;;
116 printf "You are about to delete deployment from:\x1b[31m $current_kubectl_context\x1b[0m\n"
117 read -p "To continue enter context name: " response
119 if test "$response" != "$current_kubectl_context"
121 printf "Your response does not match current context! Skipping delete ...\n"
128 if [[ ! -z "$APP" ]]; then
132 printf "\n********** Cleaning up ONAP: ${ONAP_APPS[*]}\n"
134 for i in ${HELM_APPS[@]}; do
135 delete_app_helm $NS $i
138 if [ "$SINGLE_COMPONENT" == "false" ]
140 delete_app_helm $NS "config"
142 delete_registry_key $NS
143 delete_service_account $NS
146 if $WAIT_TERMINATE; then
150 printf "\n********** Gone **********\n"