blob: 05eac1cbb737f7641c6e2ff267567c57da06c61c [file] [log] [blame]
Lathish7e090012020-04-01 17:38:20 +01001#!/bin/bash
Lathish65cb6092020-03-26 15:06:31 +00002################################################################################
3# Copyright (c) 2020 Nordix Foundation. #
4# #
5# Licensed under the Apache License, Version 2.0 (the "License"); #
6# you may not use this file except in compliance with the License. #
7# You may obtain a copy of the License at #
8# #
9# http://www.apache.org/licenses/LICENSE-2.0 #
10# #
11# Unless required by applicable law or agreed to in writing, software #
12# distributed under the License is distributed on an "AS IS" BASIS, #
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14# See the License for the specific language governing permissions and #
15# limitations under the License. #
16################################################################################
17
Lathish7e090012020-04-01 17:38:20 +010018# This script to undeploy the NONRTRIC
Lathish65cb6092020-03-26 15:06:31 +000019
PatrikBuhrc5c107d2021-05-26 09:26:09 +020020
RehanRaza2482dc92021-09-22 18:14:27 +020021COMPONENTS="controlpanel a1controller a1simulator policymanagementservice enrichmentservice rappcatalogueservice nonrtricgateway dmaapadapterservice"
PatrikBuhrc5c107d2021-05-26 09:26:09 +020022RECIPE_NAMESPACE=$(kubectl get cm --all-namespaces | grep nonrtric-recipe | awk '{print $1}')
23kubectl get configmap -n $RECIPE_NAMESPACE nonrtric-recipe -o jsonpath='{.data.recipe}' > /tmp/recipe.yaml
24
25if [ ! -s /tmp/recipe.yaml ]; then
26 echo "NONRTRIC recipe is not found. Are you sure it's deployed successfully?"
27 exit 0
28fi
29
30COMMON_BLOCK=$(cat /tmp/recipe.yaml | awk '/^common:/{getline; while ($0 ~ /^ +.*|^ *$/) {print $0; if (getline == 0) {break}}}')
31NAMESPACE_BLOCK=$(cat /tmp/recipe.yaml | awk '/^ namespace:/{getline; while ($0 ~ /^ .*|^ *$/) {print $0; if (getline == 0) {break}}}')
32NONRTRIC_NAMESPACE=$(echo "$NAMESPACE_BLOCK" | awk '/^ *nonrtric:/{print $2}')
33RELEASE_PREFIX=$(echo "$COMMON_BLOCK" | awk '/^ *releasePrefix:/{print $2}')
Lathishad832472021-05-26 15:52:08 +010034INSTALL_KONG=$(cat /tmp/recipe.yaml | awk '/^ installKong:/{print $2}')
35
36if [ "$INSTALL_KONG" = true ];then
37 echo "Uninstalling Kong"
38 helm delete kong-nonrtric --namespace kong
39fi
PatrikBuhrc5c107d2021-05-26 09:26:09 +020040
41echo "Undeploying NONRTRIC components [$COMPONENTS]"
42
43IS_HELM3=$(helm version -c --short|grep -e "^v3")
44HELM_FLAG=''
45if [ $IS_HELM3 ]
46then
47 HELM_FLAG=' -n '${NONRTRIC_NAMESPACE:-nonrtric}
48else
49 HELM_FLAG='--purge'
50fi
51
52helm delete ${HELM_FLAG} ${RELEASE_PREFIX}
53
54kubectl delete cm -n ${NONRTRIC_NAMESPACE:-nonrtric} nonrtric-recipe
55
56kubectl delete ns ${NONRTRIC_NAMESPACE:-nonrtric}