Files
linuxkit/projects/kubernetes/boot.sh
Ian Campbell 164c4a30f5 kubernetes: support untainting master via metadata
If a stamp file is present in the metadata then untaint.

This is useful for dev environments where you only want to start a single vm.

The construction of the metadata becomes a little more complex to produce
correct json syntax now that there are two (independent) possible options.

Likewise the kubelet.sh script now takes the presence of /var/config/kubeadm
(rather than /var/config/kubeadm/init) as the signal to use the more structured
setup, since we may now have /var/config/kubeadm/untaint-master but not
/var/config/kubeadm/init so would otherwise end up passing the contents of
`/var/config/userdata` (something like `{ "kubeadm": { "untaint-master": "" }
}`) to `kubeadm` and confusing it enormously.

Signed-off-by: Ian Campbell <ijc@docker.com>
2017-10-04 11:28:48 +01:00

84 lines
2.1 KiB
Bash
Executable File

#!/bin/sh
set -e
: ${KUBE_MASTER_VCPUS:=2}
: ${KUBE_MASTER_MEM:=1024}
: ${KUBE_MASTER_DISK:=4G}
: ${KUBE_MASTER_UNTAINT:=n}
: ${KUBE_NODE_VCPUS:=2}
: ${KUBE_NODE_MEM:=4096}
: ${KUBE_NODE_DISK:=8G}
: ${KUBE_NETWORKING:=default}
: ${KUBE_RUN_ARGS:=}
: ${KUBE_EFI:=}
: ${KUBE_MAC:=}
: ${KUBE_PRESERVE_STATE:=}
[ "$(uname -s)" = "Darwin" ] && KUBE_EFI=1
suffix=".iso"
[ -n "${KUBE_EFI}" ] && suffix="-efi.iso" && uefi="--uefi"
if [ $# -eq 0 ] ; then
img="kube-master"
# If $KUBE_MASTER_AUTOINIT is set, including if it is set to ""
# then we configure for auto init. If it is completely unset then
# we do not.
if [ -n "${KUBE_MASTER_AUTOINIT+x}" ] ; then
kubeadm_data="${kubeadm_data+$kubeadm_data, }\"init\": \"${KUBE_MASTER_AUTOINIT}\""
fi
if [ "${KUBE_MASTER_UNTAINT}" = "y" ] ; then
kubeadm_data="${kubeadm_data+$kubeadm_data, }\"untaint-master\": \"\""
fi
if [ -n "${kubeadm_data}" ] ; then
data="{ \"kubeadm\": { ${kubeadm_data} } }"
fi
state="kube-master-state"
: ${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
case $1 in
''|*[!0-9]*)
echo "Node number must be a number"
exit 1
;;
0)
echo "Node number must be greater than 0"
exit 1
;;
*) ;;
esac
img="kube-node"
name="node-${1}"
shift
data="{\"kubeadm\": {\"join\": \"${*}\"} }"
state="kube-${name}-state"
: ${KUBE_VCPUS:=$KUBE_NODE_VCPUS}
: ${KUBE_MEM:=$KUBE_NODE_MEM}
: ${KUBE_DISK:=$KUBE_NODE_DISK}
else
echo "Usage:"
echo " - Boot master:"
echo " ${0}"
echo " - Boot node:"
echo " ${0} <node> <join_args>"
exit 1
fi
set -x
if [ -z "${KUBE_PRESERVE_STATE}" ] ; then
rm -rf "${state}"
mkdir "${state}"
if [ -n "${KUBE_MAC}" ] ; then
echo -n "${KUBE_MAC}" > "${state}"/mac-addr
fi
fi
linuxkit run ${KUBE_RUN_ARGS} -networking ${KUBE_NETWORKING} -cpus ${KUBE_VCPUS} -mem ${KUBE_MEM} -state "${state}" -disk size=${KUBE_DISK} -data "${data}" ${uefi} "${img}${suffix}"