-
Notifications
You must be signed in to change notification settings - Fork 12
/
setup-minikube.sh
executable file
·66 lines (56 loc) · 2.07 KB
/
setup-minikube.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
#!/usr/bin/env bash
ORIG_DIR="$(pwd)"
cd "$(dirname "$0")"
BIN_DIR="$(pwd)"
trap "cd '${ORIG_DIR}'" EXIT
mkdir -p $HOME/.local/bin
VERSION="v1.14.2"
# minikube: download and install locally
if hash minikube 2>/dev/null
then
INSTALLED_VERSION=`minikube version -o json | jq -r .minikubeVersion`
echo "Current installed version of minikube is ${INSTALLED_VERSION}"
fi
if [ "${INSTALLED_VERSION}" = "${VERSION}" ]
then
echo "Using existing minikube version ${VERSION}"
else
echo "Download and install minikube version ${VERSION}..."
curl -sLo $HOME/.local/bin/minikube https://github.com/kubernetes/minikube/releases/download/${VERSION}/minikube-linux-amd64 \
&& chmod +x $HOME/.local/bin/minikube
fi
# If MINIKUBE_MODE is not set, and USER is vagrant, deduce we are running in a VM, so use 'native' mode
MINIKUBE_MODE="$1"
if [ -z "${MINIKUBE_MODE}" -a "${USER}" = "vagrant" ]; then MINIKUBE_MODE="native"; fi
# Extra options
OPTIONS="--memory=8g --cpus=4"
# Use default location for kubeconfig
unset KUBECONFIG
# minikube (native)
if [ "${MINIKUBE_MODE}" = "native" ]
then
if hash conntrack 2>/dev/null
then
# start minikube
# - default container runtime is docker - see https://minikube.sigs.k8s.io/docs/handbook/config/#runtime-configuration
echo "Start minikube (native), and wait for cluster..."
export CHANGE_MINIKUBE_NONE_USER=true
sudo -E $HOME/.local/bin/minikube start ${OPTIONS} --driver=none --addons ingress --wait "all"
else
echo "ERROR: conntrack must be installed for minikube driver='none', e.g. 'sudo apt install conntrack'. Aborting..."
exit 1
fi
# minikube docker
else
if [ "${MINIKUBE_MODE}" = "github" ]
then
echo "Start minikube (github), and wait for cluster..."
minikube start --memory=6g --cpus=2 --addons ingress --wait "all"
else
# start minikube
# - default container runtime is docker - see https://minikube.sigs.k8s.io/docs/handbook/config/#runtime-configuration
echo "Start minikube (default), and wait for cluster..."
minikube start ${OPTIONS} --addons ingress --wait "all"
fi
fi
echo "...READY"