3 . $(dirname "$0")/setenv.bash
6 kubectl delete namespace $1
9 delete_service_account() {
10 kubectl delete clusterrolebinding $1-$2-admin-binding
11 printf "Service account $1-$2-admin-binding deleted.\n\n"
14 delete_registry_key() {
15 kubectl --namespace $1-$2 delete secret ${1}-docker-registry-key
19 helm delete $1-$2 --purge
23 printf "Waiting for namespaces termination...\n"
26 for i in ${HELM_APPS[@]}; do
27 kubectl get pods --namespace $1 | grep -w " $i" > /dev/null 2>&1
28 if [ "$?" -ne "0" ]; then
34 if [ "$SINGLE_COMPONENT" == "false" ]; then
35 kubectl get namespaces $1 > /dev/null 2>&1
38 if [ "$_STATUS" -ne "0" ]; then
49 -n [NAMESPACE] : Kubernetes namespace (required)
50 -c : kubectl context (default: current context)
51 -y : Skip interactive confirmation (default: no)
52 -a [APP] : Specify a specific ONAP component (default: all)
53 from the following choices:
54 sdc, aai ,mso, message-router, robot, vid, aaf, uui
55 sdnc, portal, policy, appc, multicloud, clamp, consul, vnfsdk
56 -N : Do not wait for deletion of namespace and its objects
65 SKIP_INTERACTIVE_CONFIRMATION=no
67 SINGLE_COMPONENT=false
68 while getopts ":c:n:u:s:a:yN" PARAM; do
79 if [[ -z $APP ]]; then
89 SKIP_INTERACTIVE_CONFIRMATION=yes
92 KUBECTL_CONTEXT=${OPTARG}
101 if [[ -z $NS ]]; then
106 if [[ "$SKIP_INTERACTIVE_CONFIRMATION" != yes ]]; then
107 current_kubectl_context=$(kubectl config get-contexts |grep "*" |awk '{print $2}')
108 if test "$KUBECTL_CONTEXT" != "$current_kubectl_context"; then
109 printf "Current kubectl context does not match context specified:\x1b[31m $current_kubectl_context\x1b[0m\n"
110 if [ ! -z "$KUBECTL_CONTEXT" -a "$KUBECTL_CONTEXT" != " " ]; then
111 read -p "Do you wish to switch context to $KUBECTL_CONTEXT and continue?" yn
113 [Yy]* ) kubectl config use-context $KUBECTL_CONTEXT;;
114 * ) printf "Skipping delete...\n"; exit;;
117 printf "You are about to delete deployment from:\x1b[31m $current_kubectl_context\x1b[0m\n"
118 read -p "To continue enter context name: " response
120 if test "$response" != "$current_kubectl_context"
122 printf "Your response does not match current context! Skipping delete ...\n"
129 if [[ ! -z "$APP" ]]; then
133 printf "\n********** Cleaning up ONAP: ${ONAP_APPS[*]}\n"
135 for i in ${HELM_APPS[@]}; do
136 delete_app_helm $NS $i
137 delete_service_account $NS $i
140 if [ "$SINGLE_COMPONENT" == "false" ]
142 delete_app_helm $NS "config"
146 if $WAIT_TERMINATE; then
150 printf "\n********** Gone **********\n"