-
Notifications
You must be signed in to change notification settings - Fork 0
/
pipe-uninstall.sh
executable file
·68 lines (61 loc) · 2.02 KB
/
pipe-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
#!/bin/bash
# Copyright (c) 2023 Ho Kim ([email protected]). All rights reserved.
# Use of this source code is governed by a GPL-3-style license that can be
# found in the LICENSE file.
# Prehibit errors
set -e -o pipefail
###########################################################
# Main Function #
###########################################################
for cluster_name in $("$(dirname "$0")/ceph-ls.sh"); do
echo -n "* ${cluster_name}: "
kubectl config use-context "${cluster_name}"
# Infer namespace
cluster_namespace="$(
cat "$(pwd)/clusters/${cluster_name}.yaml" |
grep -Po '^ +namespace\: *\K[0-9a-z-]+$' |
head -n 1 ||
true
)"
if [ "x${cluster_namespace}" = 'x' ]; then
continue
elif
! echo "${cluster_namespace}" |
grep -Po '^tenant-[0-9a-z-]+' >/dev/null
then
continue
fi
# Uninstall Data Pond Pipelines
kubectl delete clusterissuers \
--all \
--context "${cluster_name}" \
--namespace "${cluster_namespace}" || true
kubectl delete certificates \
--all \
--context "${cluster_name}" \
--namespace "${cluster_namespace}" || true
kubectl delete issuers \
--all \
--context "${cluster_name}" \
--namespace "${cluster_namespace}" || true
kubectl delete natscluster \
--all \
--context "${cluster_name}" \
--namespace "${cluster_namespace}" || true
kubectl delete natsserviceroles \
--all \
--context "${cluster_name}" \
--namespace "${cluster_namespace}" || true
kubectl delete natsserviceroles \
--all \
--context "${cluster_name}" \
--namespace "${cluster_namespace}" || true
kubectl delete pods \
--context "${cluster_name}" \
--namespace "${cluster_namespace}" \
--selector 'serviceType=pipe' || true
done
# Cleanup
kubectl config use-context 'default'
# Done
exec echo 'Finished!'