@@ -19,26 +19,32 @@ export PATH=$kb_root_dir/bin:$PATH
19
19
fetch_tools
20
20
install_kind
21
21
22
- # Creates a kind cluster given a k8s version and a cluster name.
22
+ # Creates a named kind cluster given a k8s version.
23
+ # The KIND_CLUSTER variable defines the cluster name and
24
+ # is expected to be defined in the calling environment.
23
25
#
24
26
# Usage:
25
27
#
26
- # create_cluster <k8s version> <kind cluster name>
28
+ # export KIND_CLUSTER=<kind cluster name>
29
+ # create_cluster <k8s version>
27
30
function create_cluster {
28
- if ! kind get clusters | grep -q $2 ; then
29
- kind create cluster -v 4 --name $2 --retain --wait=1m --config $( dirname " $0 " ) /kind-config.yaml --image=kindest/node:$1
31
+ : ${KIND_CLUSTER:? " KIND_CLUSTER must be set" }
32
+ if ! kind get clusters | grep -q $KIND_CLUSTER ; then
33
+ kind create cluster -v 4 --name $KIND_CLUSTER --retain --wait=1m --config $( dirname " $0 " ) /kind-config.yaml --image=kindest/node:$1
30
34
fi
31
35
}
32
36
33
- # Deletes a kind cluster by cluster name. The kind cluster needs to be defined as a variable instead of an argument
34
- # so that this function can be used with `trap`
37
+ # Deletes a kind cluster by cluster name.
38
+ # The KIND_CLUSTER variable defines the cluster name and
39
+ # is expected to be defined in the calling environment.
35
40
#
36
41
# Usage:
37
42
#
38
- # kind_cluster =<kind cluster name>
43
+ # export KIND_CLUSTER =<kind cluster name>
39
44
# delete_cluster
40
45
function delete_cluster {
41
- kind delete cluster --name $kind_cluster
46
+ : ${KIND_CLUSTER:? " KIND_CLUSTER must be set" }
47
+ kind delete cluster --name $KIND_CLUSTER
42
48
}
43
49
44
50
function test_cluster {
0 commit comments