-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathstart.sh
78 lines (68 loc) · 2.12 KB
/
start.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#/bin/bash
set +x
set -e
###########################################################################
# Usage: bash -f ./start.sh
# Supported Options -
# --kind-cluster-name=<Kind Cluster Name> (default INTEGRATION_TEST_CLUSTER)
# --kind-version (default v0.7.0)
# --kubectl-version (default v1.18.0)
# --helm-version (default v3.2.0)
###########################################################################
# All Supported Arguments
ARGUMENT_LIST=(
"kind-cluster-name"
"kind-version"
"kubectl-version"
"helm-version"
)
# Read Arguments
opts=$(getopt \
--longoptions "$(printf "%s:," "${ARGUMENT_LIST[@]}")" \
--name "$(basename "$0")" \
--options "" \
-- "$@"
)
# Assign Values from Arguments
eval set --$opts
while [[ $# -gt 0 ]]; do
case "$1" in
--kind-cluster-name)
CLUSTER_NAME=$2
shift 2
;;
--kind-version)
KIND_VERSION=$2
shift 2
;;
--kubectl-version)
KUBECTL_VERSION=$2
shift 2
;;
--helm-version)
HELM_VERSION=$2
shift 2
;;
*)
break
;;
esac
done
# Assign Deafults
CLUSTER_NAME=${CLUSTER_NAME:-"INTEGRATION_TEST_CLUSTER"}
KIND_VERSION=${KIND_VERSION:-v0.7.0}
KUBECTL_VERSION=${KUBECTL_VERSION:-v1.18.0}
HELM_VERSION=${HELM_VERSION:-v3.2.0}
echo $(date -u) "[INFO] Downloading Kubectl ..."
curl -LO https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl
chmod +x ./kubectl
echo $(date -u) "[INFO] Downloading KIND ..."
curl -Lo ./kind https://kind.sigs.k8s.io/dl/${KIND_VERSION}/kind-$(uname)-amd64
chmod +x ./kind
echo $(date -u) "[INFO] Downloading helm ..."
wget https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz
tar -zxvf helm-${HELM_VERSION}-linux-amd64.tar.gz
echo $(date -u) "[INFO] Creating a KIND cluster ${CLUSTER_NAME} ..."
./kind create cluster --name ${CLUSTER_NAME}
echo $(date -u) "[INFO] Sleeping for 60s to make sure KIND cluster is ready to accept request ..."
sleep 60s