-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathsetup-microk8s.sh
executable file
·31 lines (26 loc) · 1.19 KB
/
setup-microk8s.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
#!/usr/bin/env bash
set -e # exit immediately on error
set -u # fail on undeclared variables
# Grab the directory of the scripts, in case the script is invoked from a different path
SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
# Useful routines in common.sh
. "${SCRIPTS_DIR}/common.sh"
CHANNEL=${CHANNEL:-1.15/stable}
ensure_root
# install kubernetes .. using current known working version
snap install microk8s --classic --channel=${CHANNEL}
# use the kubectl that matches the microk8s kubernetes version
snap alias microk8s.kubectl kubectl
# export the kubectl config file in case other tools rely on this
mkdir -p $HOME/.kube
microk8s.kubectl config view --raw > $HOME/.kube/config
echo "Waiting for kubernetes core services to be ready.."
microk8s.status --wait-ready
# enable common services
microk8s.enable dns dashboard storage
# This gets around an open issue with all-in-one installs
iptables -P FORWARD ACCEPT
until [[ `kubectl get pods -n=kube-system | grep -o 'ContainerCreating' | wc -l` == 0 ]] ; do
echo "Waiting for kubernetes addon service pods to be ready.. ("`kubectl get pods -n=kube-system | grep -o 'ContainerCreating' | wc -l`" not running)"
sleep 5
done