Lathish | 7e09001 | 2020-04-01 17:38:20 +0100 | [diff] [blame] | 1 | #!/bin/bash |
Lathish | 65cb609 | 2020-03-26 15:06:31 +0000 | [diff] [blame] | 2 | ################################################################################ |
rohithrajneesh | 538db33 | 2023-08-09 14:48:30 +0100 | [diff] [blame] | 3 | # Copyright (c) 2023 Nordix Foundation. # |
aravind.est | 031a911 | 2024-03-14 15:52:15 +0000 | [diff] [blame] | 4 | # Copyright (C) 2024 OpenInfra Foundation Europe. All rights reserved. # |
Lathish | 65cb609 | 2020-03-26 15:06:31 +0000 | [diff] [blame] | 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 | |
Lathish | 7e09001 | 2020-04-01 17:38:20 +0100 | [diff] [blame] | 19 | # This script to undeploy the NONRTRIC |
aravind.est | 031a911 | 2024-03-14 15:52:15 +0000 | [diff] [blame] | 20 | ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" |
| 21 | echo "** $ROOT_DIR" |
Lathish | 65cb609 | 2020-03-26 15:06:31 +0000 | [diff] [blame] | 22 | |
DenisGNoonan | b4dae85 | 2024-03-26 14:46:10 +0000 | [diff] [blame^] | 23 | COMPONENTS=" |
| 24 | a1controller \ |
| 25 | a1simulator \ |
| 26 | capifcore \ |
| 27 | controlpanel \ |
| 28 | dmaapadapterservice \ |
| 29 | dmaapmediatorservice \ |
| 30 | dmeparticipant \ |
| 31 | helmmanager \ |
| 32 | informationservice \ |
| 33 | nonrtricgateway \ |
| 34 | orufhrecovery \ |
| 35 | policymanagementservice \ |
| 36 | ransliceassurance \ |
| 37 | rappcatalogueenhancedservice \ |
| 38 | rappcatalogueservice \ |
| 39 | rappmanager \ |
| 40 | servicemanager \ |
| 41 | " |
| 42 | |
PatrikBuhr | c5c107d | 2021-05-26 09:26:09 +0200 | [diff] [blame] | 43 | RECIPE_NAMESPACE=$(kubectl get cm --all-namespaces | grep nonrtric-recipe | awk '{print $1}') |
| 44 | kubectl get configmap -n $RECIPE_NAMESPACE nonrtric-recipe -o jsonpath='{.data.recipe}' > /tmp/recipe.yaml |
| 45 | |
| 46 | if [ ! -s /tmp/recipe.yaml ]; then |
| 47 | echo "NONRTRIC recipe is not found. Are you sure it's deployed successfully?" |
| 48 | exit 0 |
| 49 | fi |
| 50 | |
| 51 | COMMON_BLOCK=$(cat /tmp/recipe.yaml | awk '/^common:/{getline; while ($0 ~ /^ +.*|^ *$/) {print $0; if (getline == 0) {break}}}') |
| 52 | NAMESPACE_BLOCK=$(cat /tmp/recipe.yaml | awk '/^ namespace:/{getline; while ($0 ~ /^ .*|^ *$/) {print $0; if (getline == 0) {break}}}') |
| 53 | NONRTRIC_NAMESPACE=$(echo "$NAMESPACE_BLOCK" | awk '/^ *nonrtric:/{print $2}') |
| 54 | RELEASE_PREFIX=$(echo "$COMMON_BLOCK" | awk '/^ *releasePrefix:/{print $2}') |
Lathish | ad83247 | 2021-05-26 15:52:08 +0100 | [diff] [blame] | 55 | INSTALL_KONG=$(cat /tmp/recipe.yaml | awk '/^ installKong:/{print $2}') |
rohithrajneesh | 538db33 | 2023-08-09 14:48:30 +0100 | [diff] [blame] | 56 | INSTALL_RANPM=$(cat /tmp/recipe.yaml | awk '/^ installRanpm:/{print $2}') |
Lathish | ad83247 | 2021-05-26 15:52:08 +0100 | [diff] [blame] | 57 | |
| 58 | if [ "$INSTALL_KONG" = true ];then |
DenisGNoonan | b4dae85 | 2024-03-26 14:46:10 +0000 | [diff] [blame^] | 59 | echo "Warning - deleting Kong routes and services for ServiceManager" |
| 60 | SERVICEMANAGER_POD=$(kubectl get pods -o custom-columns=NAME:.metadata.name -l app=nonrtric-servicemanager --no-headers -n ${NONRTRIC_NAMESPACE:-nonrtric}) |
| 61 | if [[ -n $SERVICEMANAGER_POD ]]; then |
| 62 | kubectl exec $SERVICEMANAGER_POD -n ${NONRTRIC_NAMESPACE:-nonrtric} -- ./kongclearup |
| 63 | else |
| 64 | echo "Error - Servicemanager pod not found, didn't delete Kong routes and services for ServiceManager" |
| 65 | fi |
| 66 | echo "Uninstalling kongstorage" |
| 67 | helm delete kongstorage -n "${NONRTRIC_NAMESPACE:-nonrtric}" |
| 68 | echo "Uninstalling Kong" |
| 69 | helm delete kong-nonrtric -n ${NONRTRIC_NAMESPACE:-nonrtric} |
Lathish | ad83247 | 2021-05-26 15:52:08 +0100 | [diff] [blame] | 70 | fi |
PatrikBuhr | c5c107d | 2021-05-26 09:26:09 +0200 | [diff] [blame] | 71 | |
rohithrajneesh | 538db33 | 2023-08-09 14:48:30 +0100 | [diff] [blame] | 72 | ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" |
| 73 | |
| 74 | if [ "$INSTALL_RANPM" = true ];then |
| 75 | echo "Running uninstall-ranpm.sh" |
| 76 | chmod +x ${ROOT_DIR}/../ranpm/install/uninstall-ranpm.sh |
| 77 | ${ROOT_DIR}/../ranpm/install/uninstall-ranpm.sh |
| 78 | kubectl delete ns ran |
| 79 | echo "uninstall-ranpm.sh completed" |
| 80 | fi |
| 81 | |
PatrikBuhr | c5c107d | 2021-05-26 09:26:09 +0200 | [diff] [blame] | 82 | echo "Undeploying NONRTRIC components [$COMPONENTS]" |
| 83 | |
| 84 | IS_HELM3=$(helm version -c --short|grep -e "^v3") |
| 85 | HELM_FLAG='' |
| 86 | if [ $IS_HELM3 ] |
| 87 | then |
| 88 | HELM_FLAG=' -n '${NONRTRIC_NAMESPACE:-nonrtric} |
| 89 | else |
| 90 | HELM_FLAG='--purge' |
| 91 | fi |
| 92 | |
| 93 | helm delete ${HELM_FLAG} ${RELEASE_PREFIX} |
| 94 | |
| 95 | kubectl delete cm -n ${NONRTRIC_NAMESPACE:-nonrtric} nonrtric-recipe |
| 96 | |
| 97 | kubectl delete ns ${NONRTRIC_NAMESPACE:-nonrtric} |
rohithrajneesh | 538db33 | 2023-08-09 14:48:30 +0100 | [diff] [blame] | 98 | |
| 99 | kubectl delete ns onap |
aravind.est | 031a911 | 2024-03-14 15:52:15 +0000 | [diff] [blame] | 100 | |
| 101 | # Cleanup ChartMuseum |
| 102 | CM_PID_FILE="$ROOT_DIR/CM_PID.txt" |
| 103 | if [ -f $CM_PID_FILE ]; then |
| 104 | echo "Cleaning up ChartMuseum..." |
| 105 | PID=$(cat "$CM_PID_FILE") |
| 106 | echo "Killing ChartMuseum with PID $PID" |
| 107 | kill $PID |
| 108 | rm $CM_PID_FILE |
| 109 | echo "ChartMuseum cleanup completed" |
| 110 | fi |