-
Notifications
You must be signed in to change notification settings - Fork 41
/
kind-smoketest.sh
executable file
·55 lines (47 loc) · 1.47 KB
/
kind-smoketest.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
# standard bash error handling
set -o errexit;
set -o pipefail;
set -o nounset;
# debug commands
set -x;
# working dir to install binaries etc, cleaned up on exit
BIN_DIR="$(mktemp -d)"
# kind binary will be here
KIND="${BIN_DIR}/kind"
CWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
KIND_CONFIG="${CWD}/kind-config.yaml"
# cleanup on exit (useful for running locally)
cleanup() {
"${KIND}" delete cluster || true
rm -rf "${BIN_DIR}"
}
trap cleanup EXIT
# util to install the latest kind version into ${BIN_DIR}
install_latest_kind() {
# clone kind into a tempdir within BIN_DIR
local tmp_dir
tmp_dir="$(TMPDIR="${BIN_DIR}" mktemp -d "${BIN_DIR}/kind-source.XXXXX")"
cd "${tmp_dir}" || exit
git clone https://github.com/kubernetes-sigs/kind && cd ./kind
make install INSTALL_DIR="${BIN_DIR}"
}
# util to install a released kind version into ${BIN_DIR}
install_kind_release() {
VERSION="v0.5.1"
KIND_BINARY_URL="https://github.com/kubernetes-sigs/kind/releases/download/${VERSION}/kind-linux-amd64"
wget -O "${KIND}" "${KIND_BINARY_URL}"
chmod +x "${KIND}"
}
main() {
# get kind
install_latest_kind
# create a cluster
"${KIND}" create cluster --loglevel=debug --config "${KIND_CONFIG}"
# set KUBECONFIG to point to the cluster
KUBECONFIG="$("${KIND}" get kubeconfig-path)"
export KUBECONFIG
# TODO: invoke your tests here
# teardown will happen automatically on exit
}
main