forked from terrastackai/geospatial-studio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall.sh
More file actions
executable file
·83 lines (58 loc) · 2.61 KB
/
uninstall.sh
File metadata and controls
executable file
·83 lines (58 loc) · 2.61 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
# get_user_input
get_user_input() {
local prompt_msg="$1"
local result_var_name="$2"
local input=""
while [[ -z "$input" ]]; do
printf "%s\n" "$prompt_msg"
read -r input
if [[ -z "$input" ]]; then
echo "Error: Input cannot be blank. Please try again."
fi
done
eval "$result_var_name='$input'"
}
typeset deployment_env
get_user_input "Provide a name for the deployment environment, maybe cluster name e.g. fmaas-dev, cimf-staging, rosa-prod, local... This will be the name used for a local folder created under workspace directory." deployment_env
echo "DEPLOYMENT_ENV accepted: **$deployment_env**"
export DEPLOYMENT_ENV=$deployment_env
typeset namespace
get_user_input "For uninstall. Provide the namespace/project name: " namespace
echo "OC_PROJECT accepted: **$namespace**"
export OC_PROJECT=$namespace
oc project $OC_PROJECT
# kill all forwarded ports
# Define the list of ports
PORTS=(3000 8080 54320)
for PORT in "${PORTS[@]}"
do
echo "Attempting to kill processes on port $PORT"
# Find PIDs and kill them
PIDS=$(lsof -t -i:"$PORT")
if [ -z "$PIDS" ]; then
echo "No processes found running on port $PORT"
else
# Use 'kill -9' for forceful termination if needed
# kill -9 $PIDS
# Use 'kill' for a graceful termination
kill -9 $PIDS
echo "Killed processes: $PIDS on port $PORT"
fi
done
helm uninstall studio
kubectl delete pvc redis-data-geofm-redis-master-0 -n $OC_PROJECT
kubectl delete pvc redis-data-geofm-redis-replicas-0 -n $OC_PROJECT
kubectl delete -f workspace/$DEPLOYMENT_ENV/initialisation/populate-buckets-with-initial-data.yaml -n $OC_PROJECT
kubectl delete -f workspace/$DEPLOYMENT_ENV/initialisation/populate-buckets-default-pvc.yaml -n $OC_PROJECT
kubectl delete -f workspace/$DEPLOYMENT_ENV/initialisation/geoserver-deployment.yaml -n $OC_PROJECT
kubectl delete -f workspace/$DEPLOYMENT_ENV/initialisation/geoserver_docker_secret.yaml -n $OC_PROJECT
kubectl delete -f workspace/$DEPLOYMENT_ENV/initialisation/keycloak-deployment.yaml -n $OC_PROJECT
helm uninstall postgresql
kubectl delete -f workspace/$DEPLOYMENT_ENV/initialisation/create_postgres_local_pvc.yaml -n $OC_PROJECT
kubectl delete -f workspace/$DEPLOYMENT_ENV/initialisation/minio-deployment.yaml -n $OC_PROJECT
oc delete rb api-gateway-sa-rb -n $OC_PROJECT
oc delete role api-gateway-sa-role -n $OC_PROJECT
oc delete sa api-gateway-sa -n $OC_PROJECT
oc delete configmap geofm-gateway-cm geofm-gateway-seed-data geofm-mlflow-run-trigger -n $OC_PROJECT
oc delete secret geofm-gateway-secrets studio-cos-secret us-icr-pull-secret -n $OC_PROJECT