-
Notifications
You must be signed in to change notification settings - Fork 0
/
nats-uninstall.sh
executable file
·55 lines (44 loc) · 1.59 KB
/
nats-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
#!/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
###########################################################
# Configuration #
###########################################################
# Configure default environment variables
OPENARK_HOME_DEFAULT="${HOME}/Library/ipis-dev-env/netai-cloud"
# Configure environment variables
OPENARK_HOME="${OPENARK_HOME:-$OPENARK_HOME_DEFAULT}"
###########################################################
# Main Function #
###########################################################
for cluster_name in $("$(dirname "$0")/ceph-ls.sh"); do
echo -n "* ${cluster_name}: "
kubectl config use-context "${cluster_name}"
# Parse cluster name
export CLUSTER_NAME="$(
kubectl -n kube-system get configmap coredns -o yaml |
yq -r '.data.Corefile' |
grep -Po ' +kubernetes \K[\w\.\_\-]+'
)"
# Do not use PVC if no ceph cluster
if
! kubectl \
--context "${cluster_name}" \
get namespace 'csi-rook-ceph' \
>/dev/null 2>/dev/null
then
export NATS_ENABLE_PVC="false"
else
export NATS_ENABLE_PVC="true"
fi
# Uninstall NATS
helm uninstall --namespace 'nats-io' nats || true
kubectl delete namespace 'nats-io'
done
# Cleanup
kubectl config use-context 'default'
# Done
exec echo 'Finished!'