blob: 5c1834e3460b4afb2b259e91d7db1909edaf607e [file] [log] [blame]
Zhe Huangdc00cdf2020-02-10 13:45:15 -05001#!/bin/bash
2################################################################################
3# Copyright (c) 2019 AT&T Intellectual Property. #
4# Copyright (c) 2019 Nokia. #
5# #
6# Licensed under the Apache License, Version 2.0 (the "License"); #
7# you may not use this file except in compliance with the License. #
8# You may obtain a copy of the License at #
9# #
10# http://www.apache.org/licenses/LICENSE-2.0 #
11# #
12# Unless required by applicable law or agreed to in writing, software #
13# distributed under the License is distributed on an "AS IS" BASIS, #
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
15# See the License for the specific language governing permissions and #
16# limitations under the License. #
17################################################################################
18
19
20COMPONENTS="dashboard message-router ves mrsub mc-stack portal aaf infrastructure"
21RECIPE_NAMESPACE=$(kubectl get cm --all-namespaces | grep aux-recipe | awk '{print $1}')
22kubectl get configmap -n $RECIPE_NAMESPACE aux-recipe -o jsonpath='{.data.recipe}' > /tmp/recipe.yaml
23
24if [ ! -s /tmp/recipe.yaml ]; then
25 echo "AUX recipe is not found. Are you sure the ric platform is deployed successfully?"
26 exit 0
27fi
28
29COMMON_BLOCK=$(cat /tmp/recipe.yaml | awk '/^common:/{getline; while ($0 ~ /^ +.*|^ *$/) {print $0; if (getline == 0) {break}}}')
30NAMESPACE_BLOCK=$(cat /tmp/recipe.yaml | awk '/^ namespace:/{getline; while ($0 ~ /^ .*|^ *$/) {print $0; if (getline == 0) {break}}}')
31AUXNAMESPACE=$(echo "$NAMESPACE_BLOCK" | awk '/^ *aux:/{print $2}')
32INFRANAMESPACE=$(echo "$NAMESPACE_BLOCK" | awk '/^ *infra:/{print $2}')
33RELEASE_PREFIX=$(echo "$COMMON_BLOCK" | awk '/^ *releasePrefix:/{print $2}')
34
35echo "Undeploying AUX components [$COMPONENTS]"
36
Alok Bhatt2fcd3912020-12-04 10:40:36 +000037IS_HELM3=$(helm version -c --short|grep -e "^v3")
38HELM_FLAG=''
39if [ $IS_HELM3 ]
40then
41 HELM_FLAG=' -n '${AUXNAMESPACE:-ricaux}
42else
43 HELM_FLAG='--purge'
44fi
Zhe Huangdc00cdf2020-02-10 13:45:15 -050045
46for component in $COMPONENTS; do
Alok Bhatt2fcd3912020-12-04 10:40:36 +000047 helm delete ${HELM_FLAG} ${RELEASE_PREFIX}-$component
Zhe Huangdc00cdf2020-02-10 13:45:15 -050048done
49
50kubectl delete cm -n ${AUXNAMESPACE:-ricaux} ricaux-recipe
51
52kubectl delete ns ${INFRANAMESPACE:-ricinfra}
53kubectl delete ns ${AUXNAMESPACE:-ricaux}
Lathish83c04522020-05-26 15:18:38 +010054#kubectl delete ns onap