From 7b16f41540f6d3bfb096bfc15b60a2ae21c0b47d Mon Sep 17 00:00:00 2001 From: w9n Date: Sat, 28 Oct 2017 16:24:40 +0200 Subject: [PATCH] Kubernetes: Autoinit and persistent state by default Signed-off-by: Robin Winkelewski --- projects/kubernetes/README.md | 6 +++++- projects/kubernetes/boot.sh | 12 ++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/projects/kubernetes/README.md b/projects/kubernetes/README.md index d5e3a13a3..985ab536c 100644 --- a/projects/kubernetes/README.md +++ b/projects/kubernetes/README.md @@ -18,6 +18,10 @@ Boot Kubernetes master OS image using `hyperkit` on macOS: or `qemu` on Linux: ``` ./boot.sh ``` +or, to automatically initialise the cluster upon boot with no additional options +``` +KUBE_MASTER_AUTOINIT="" ./boot.sh +``` Get IP address of the master: ``` @@ -29,7 +33,7 @@ Login to the kubelet container: ./ssh_into_kubelet.sh ``` -Manually initialise master with `kubeadm`: +Manually initialise master with `kubeadm` if booted without `KUBE_MASTER_AUTOINIT`: ``` kubeadm-init.sh ``` diff --git a/projects/kubernetes/boot.sh b/projects/kubernetes/boot.sh index 241c098c8..0970fbebd 100755 --- a/projects/kubernetes/boot.sh +++ b/projects/kubernetes/boot.sh @@ -15,7 +15,7 @@ set -e : ${KUBE_RUN_ARGS:=} : ${KUBE_EFI:=} : ${KUBE_MAC:=} -: ${KUBE_PRESERVE_STATE:=} +: ${KUBE_CLEAR_STATE:=} [ "$(uname -s)" = "Darwin" ] && KUBE_EFI=1 @@ -43,7 +43,7 @@ if [ $# -eq 0 ] ; then : ${KUBE_VCPUS:=$KUBE_MASTER_VCPUS} : ${KUBE_MEM:=$KUBE_MASTER_MEM} : ${KUBE_DISK:=$KUBE_MASTER_DISK} -elif [ $# -gt 1 ] || [ $# -eq 1 -a -n "${KUBE_PRESERVE_STATE}" ] ; then +elif [ $# -ge 1 ] ; then case $1 in ''|*[!0-9]*) echo "Node number must be a number" @@ -58,7 +58,11 @@ elif [ $# -gt 1 ] || [ $# -eq 1 -a -n "${KUBE_PRESERVE_STATE}" ] ; then img="kube-node" name="node-${1}" shift - data="{\"kubeadm\": {\"join\": \"${*}\"} }" + + if [ $# -ge 1 ] ; then + data="{\"kubeadm\": {\"join\": \"${*}\"} }" + fi + state="kube-${name}-state" : ${KUBE_VCPUS:=$KUBE_NODE_VCPUS} @@ -73,7 +77,7 @@ else exit 1 fi set -x -if [ -z "${KUBE_PRESERVE_STATE}" ] ; then +if [ -n "${KUBE_CLEAR_STATE}" ] ; then rm -rf "${state}" mkdir "${state}" if [ -n "${KUBE_MAC}" ] ; then