forked from stolostron/deploy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall.sh
executable file
·70 lines (51 loc) · 1.78 KB
/
uninstall.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
# Parameters
# -k, --keep-providers Keeping all provider connections that are not in Advanced Cluster Management namespaces.
TARGET_NAMESPACE=${TARGET_NAMESPACE:-open-cluster-management}
KEEP_PROVIDERS=0
# save args to pass to called scripts
args=("$@")
# Parse command line arguments
for arg in "$@"
do
case $arg in
-k|--keep-providers)
KEEP_PROVIDERS=1
shift
;;
*)
echo "Unrecognized argument: $1"
shift
;;
esac
done
# Make sure `oc login` has been done and `oc` command is working
echo "Testing connection"
oc version >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "ERROR: Make sure you are logged into an OpenShift Container Platform before running this script"
exit 1
fi
VER=$(oc version | grep "Client Version:")
if ! [[ $VER =~ .*[4-9]|10\.[3-9]\..* ]]; then
echo "oc cli version 4.3 or greater required. Please visit https://access.redhat.com/downloads/content/290/ver=4.3/rhel---8/4.3.9/x86_64/product-software."
exit 1
fi
printf "\n"
echo "This script will uninstall Open Cluster Management from the current OpenShift target cluster in namespace ${TARGET_NAMESPACE}:"
printf "\n"
oc cluster-info | head -n 1 | awk '{print $NF}'
printf "\n"
./clean-clusters.sh "$args"
kubectl delete -k multiclusterhub/ -n ${TARGET_NAMESPACE}
echo "Sleeping for 200 seconds to allow resources to finalize ..."
sleep 200
kubectl delete -k multicluster-hub-operator/ -n ${TARGET_NAMESPACE}
./multicluster-hub-operator/uninstall.sh
kubectl delete -k acm-operator/ -n ${TARGET_NAMESPACE}
./acm-operator/uninstall.sh
kubectl delete -k community-subscriptions/ -n ${TARGET_NAMESPACE}
echo "Cleaning up the ${TARGET_NAMESPACE} namespace.."
oc delete namespace ${TARGET_NAMESPACE}
kubectl delete -f catalogsources/
exit 0