-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathcluster.sh
More file actions
executable file
·54 lines (43 loc) · 1021 Bytes
/
cluster.sh
File metadata and controls
executable file
·54 lines (43 loc) · 1021 Bytes
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
#!/bin/bash
cluster_name='vscode-debug'
# find script dir, following symlinks if any
SOURCE=${BASH_SOURCE[0]}
while [ -L "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR=$(cd -P "$(dirname "$SOURCE")" >/dev/null 2>&1 && pwd)
SOURCE=$(readlink "$SOURCE")
[[ $SOURCE != /* ]] && SOURCE=$DIR/$SOURCE # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
SCRIPT_DIR=$(cd -P "$(dirname "$SOURCE")" >/dev/null 2>&1 && pwd)
create() {
kind create cluster --config=$SCRIPT_DIR/kind.yaml --name $cluster_name
}
delete() {
kind delete clusters $cluster_name
}
recreate() {
delete
create
}
help() {
cat <<EOF
Usage: ${0} CMD
with CMD:
- create: create the kind cluster
- delete: delete the cluster
- recreate: recreate the cluster
- * (anything else): show this help
EOF
}
if [[ $# -ne 1 ]]; then
help
exit
fi
cmd=$1
case $cmd in
create | delete | recreate)
$cmd
;;
*)
help
;;
esac