Merge "NONRTRIC-980: Service Manager - SMO deployment"
[it/dep.git] / smo-install / scripts / sub-scripts / uninstall-nonrtric.sh
1 #!/bin/bash
2
3 ###
4 # ============LICENSE_START========================================================
5 # ORAN SMO Package
6 # =================================================================================
7 # Copyright (C) 2021 AT&T Intellectual Property. All rights
8 #                             reserved.
9 # Modification Copyright (C) 2024 OpenInfra Foundation Europe. All rights reserved.
10 # =================================================================================
11 # Licensed under the Apache License, Version 2.0 (the "License");
12 # you may not use this file except in compliance with the License.
13 # You may obtain a copy of the License at
14 #
15 # http://www.apache.org/licenses/LICENSE-2.0
16 #
17 # Unless required by applicable law or agreed to in writing, software
18 # distributed under the License is distributed on an "AS IS" BASIS,
19 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 # See the License for the specific language governing permissions and
21 # limitations under the License.
22 # ============LICENSE_END==========================================================
23 # =================================================================================
24 #
25 ###
26
27 if ! jq --version > /dev/null 2>&1 ; then
28     sudo apt-get update
29     sudo apt-get install -y jq
30 fi
31
32 INSTALL_KONG=$(helm get values oran-nonrtric -n nonrtric -o json | jq '.nonrtric.installKong')
33 if [ $? -ne 0 ]; then
34     echo "Failed to parse helm release value installKong with jq."
35     exit 1
36 fi
37
38 if [ "$INSTALL_KONG" = true ];then
39     echo "Warning - deleting Kong routes and services for ServiceManager."
40     SERVICEMANAGER_POD=$(kubectl get pods -o custom-columns=NAME:.metadata.name -l app.kubernetes.io/name=servicemanager --no-headers -n nonrtric)
41     if [[ -n $SERVICEMANAGER_POD ]]; then
42         kubectl exec $SERVICEMANAGER_POD -n nonrtric -- ./kongclearup
43     else
44         echo "Error - Servicemanager pod not found, didn't delete Kong routes and services for ServiceManager."
45     fi
46 fi
47
48 kubectl delete namespace nonrtric
49 kubectl delete pv nonrtric-pv2
50 kubectl delete pv nonrtric-pv1
51 kubectl delete pv nonrtric-pv3
52 kubectl get pv | grep Released | awk '$1 {print$1}' | while read vol; do kubectl delete pv/${vol}; done