blob: 2fb080eae8da9307d08ba278c09704e96cce78f1 [file] [log] [blame]
Zhe Huang38dc8572019-12-08 00:01:26 -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
vipine38909d2020-12-21 10:35:07 +000019COMPONENTS="xapp-onboarder appmgr rtmgr e2mgr e2term a1mediator submgr vespamgr jaegeradapter dbaas infrastructure o1mediator alarmmanager"
Zhe Huang38dc8572019-12-08 00:01:26 -050020RECIPE_NAMESPACE=$(kubectl get cm --all-namespaces | grep ricplt-recipe | awk '{print $1}')
21kubectl get configmap -n $RECIPE_NAMESPACE ricplt-recipe -o jsonpath='{.data.recipe}' > /tmp/recipe.yaml
22
23if [ ! -s /tmp/recipe.yaml ]; then
24 echo "RICPLT recipe is not found. Are you sure the ric platform is deployed successfully?"
25 exit 0
26fi
27
28COMMON_BLOCK=$(cat /tmp/recipe.yaml | awk '/^common:/{getline; while ($0 ~ /^ +.*|^ *$/) {print $0; if (getline == 0) {break}}}')
29NAMESPACE_BLOCK=$(cat /tmp/recipe.yaml | awk '/^ namespace:/{getline; while ($0 ~ /^ .*|^ *$/) {print $0; if (getline == 0) {break}}}')
30PLTNAMESPACE=$(echo "$NAMESPACE_BLOCK" | awk '/^ *platform:/{print $2}')
31INFRANAMESPACE=$(echo "$NAMESPACE_BLOCK" | awk '/^ *infra:/{print $2}')
32XAPPNAMESPACE=$(echo "$NAMESPACE_BLOCK" | awk '/^ *xapp:/{print $2}')
33RELEASE_PREFIX=$(echo "$COMMON_BLOCK" | awk '/^ *releasePrefix:/{print $2}')
34
Alok Bhattf947fc82020-11-11 04:32:33 +000035IS_HELM3=$(helm version --short|grep -e "^v3")
Zhe Huang38dc8572019-12-08 00:01:26 -050036
37echo "Undeploying RIC platform components [$COMPONENTS]"
38
39
Alok Bhattf947fc82020-11-11 04:32:33 +000040HELM_FLAG=''
41if [ $IS_HELM3 ]
42then
43 HELM_FLAG=' -n '${PLTNAMESPACE:-ricplt}
44else
45 HELM_FLAG='--purge'
46fi
47
48
Zhe Huang38dc8572019-12-08 00:01:26 -050049for component in $COMPONENTS; do
Alok Bhattf947fc82020-11-11 04:32:33 +000050 helm delete $HELM_FLAG ${RELEASE_PREFIX}-$component
Zhe Huang38dc8572019-12-08 00:01:26 -050051done
52
53kubectl delete cm -n ${PLTNAMESPACE:-ricplt} ricplt-recipe
54
55kubectl delete ns ${XAPPNAMESPACE:-ricxapp}
56kubectl delete ns ${INFRANAMESPACE:-ricinfra}
57kubectl delete ns ${PLTNAMESPACE:-ricplt}