-
Notifications
You must be signed in to change notification settings - Fork 191
Expand file tree
/
Copy pathuninstall.sh
More file actions
executable file
·116 lines (103 loc) · 2.94 KB
/
uninstall.sh
File metadata and controls
executable file
·116 lines (103 loc) · 2.94 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/bash
# Copyright 2024 The Kubeflow Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -eux
HELM=${HELM:-arena-helm}
KUBECTL=${KUBECTL:-arena-kubectl}
RELEASE_NAME=${ARENA_RELEASE_NAME:-arena-artifacts}
RELEASE_NAMESPACE=${ARENA_RELEASE_NAMESPACE:-arena-system}
CLEAN_CLIENT=false
ARTIFACTS_DIR=""
CHART_DIR=""
function help() {
echo -e "
Usage:
arena-uninstall [OPTION1] [OPTION2] ...
Options:
--namespace string Specify the namespace to delete arena
--delete-binary Clean the client env,include ~/charts and /usr/local/bin/arena
--chart-dir Specify the chart dir
"
}
function logger() {
timestr=$(date +"%Y-%m-%d/%H:%M:%S")
level=$(echo $1 | tr 'a-z' 'A-Z')
echo ${timestr}" "${level}" "$2
}
function delete() {
if ${HELM} status -n ${RELEASE_NAMESPACE} ${RELEASE_NAME} &>/dev/null; then
${HELM} delete -n ${RELEASE_NAMESPACE} ${RELEASE_NAME}
else
${HELM} template ${RELEASE_NAME} -n ${RELEASE_NAMESPACE} $ARTIFACTS_DIR | ${KUBECTL} delete --ignore-not-found -f -
fi
}
function delete_client() {
rm -rf /charts
rm -rf /usr/local/bin/arena*
}
function detect_chart_dir() {
if [[ $CHART_DIR != "" ]]; then
ARTIFACTS_DIR=$CHART_DIR
elif [ -d arena-artifacts ]; then
ARTIFACTS_DIR=arena-artifacts
elif [ -d ~/charts/arena-artifacts ]; then
ARTIFACTS_DIR=~/charts/arena-artifacts
else
ARTIFACTS_DIR=/charts/arena-artifacts
fi
}
function parse_args() {
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
--delete-binary)
CLEAN_CLIENT=true
;;
--namespace)
check_option_value "--namespace" $2
RELEASE_NAMESPACE=$2
shift
;;
--chart-dir)
check_option_value "--chart-dir" $2
CHART_DIR=$2
shift
;;
--help | -h)
help
exit 0
;;
*)
logger error "unknown option [$key]"
help
exit 3
;;
esac
shift
done
}
function check_option_value() {
option=$1
value=$2
if [[ $value == "" ]] || echo "$value" | grep -- "^--" &>/dev/null; then
logger error "the option $option not set value,please set it"
exit 3
fi
}
parse_args "$@"
detect_chart_dir
delete
if [[ $CLEAN_CLIENT == "true" ]]; then
delete_client
fi