blob: f065fe8baa1d3f725c52468e157647c17db1cdcf [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. #
Chandrasekaran Ramachandranb515b962021-06-11 16:07:09 +05305# Copyright (c) 2021 HCL Technologies Limited. #
Zhe Huang38dc8572019-12-08 00:01:26 -05006# #
7# Licensed under the Apache License, Version 2.0 (the "License"); #
8# you may not use this file except in compliance with the License. #
9# You may obtain a copy of the License at #
10# #
11# http://www.apache.org/licenses/LICENSE-2.0 #
12# #
13# Unless required by applicable law or agreed to in writing, software #
14# distributed under the License is distributed on an "AS IS" BASIS, #
15# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
16# See the License for the specific language governing permissions and #
17# limitations under the License. #
18################################################################################
19
Chandrasekaran Ramachandranb515b962021-06-11 16:07:09 +053020COMPONENTS="xapp-onboarder appmgr rtmgr e2mgr e2term a1mediator submgr vespamgr jaegeradapter dbaas infrastructure o1mediator alarmmanager influxdb"
Zhe Huang38dc8572019-12-08 00:01:26 -050021RECIPE_NAMESPACE=$(kubectl get cm --all-namespaces | grep ricplt-recipe | awk '{print $1}')
22kubectl get configmap -n $RECIPE_NAMESPACE ricplt-recipe -o jsonpath='{.data.recipe}' > /tmp/recipe.yaml
23
24if [ ! -s /tmp/recipe.yaml ]; then
25 echo "RICPLT 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}}}')
31PLTNAMESPACE=$(echo "$NAMESPACE_BLOCK" | awk '/^ *platform:/{print $2}')
32INFRANAMESPACE=$(echo "$NAMESPACE_BLOCK" | awk '/^ *infra:/{print $2}')
33XAPPNAMESPACE=$(echo "$NAMESPACE_BLOCK" | awk '/^ *xapp:/{print $2}')
34RELEASE_PREFIX=$(echo "$COMMON_BLOCK" | awk '/^ *releasePrefix:/{print $2}')
35
Alok Bhattf947fc82020-11-11 04:32:33 +000036IS_HELM3=$(helm version --short|grep -e "^v3")
Zhe Huang38dc8572019-12-08 00:01:26 -050037
38echo "Undeploying RIC platform components [$COMPONENTS]"
39
40
Alok Bhattf947fc82020-11-11 04:32:33 +000041HELM_FLAG=''
42if [ $IS_HELM3 ]
43then
44 HELM_FLAG=' -n '${PLTNAMESPACE:-ricplt}
45else
46 HELM_FLAG='--purge'
47fi
48
49
Zhe Huang38dc8572019-12-08 00:01:26 -050050for component in $COMPONENTS; do
Alok Bhattf947fc82020-11-11 04:32:33 +000051 helm delete $HELM_FLAG ${RELEASE_PREFIX}-$component
Zhe Huang38dc8572019-12-08 00:01:26 -050052done
53
54kubectl delete cm -n ${PLTNAMESPACE:-ricplt} ricplt-recipe
55
56kubectl delete ns ${XAPPNAMESPACE:-ricxapp}
57kubectl delete ns ${INFRANAMESPACE:-ricinfra}
58kubectl delete ns ${PLTNAMESPACE:-ricplt}