Files
linuxkit/projects/kubernetes/boot.sh
Ian Campbell 2cfac0e8bb kubernetes: Expose each node's ssh port on the host starting from 2222
Port base is configurable (via $KUBE_PORT_BASE envvar). Master uses this and
nodes use subsequent ports.

Check that the node number is numeric so we can add them to things, but avoid
worker node 0 since the port will clash with master.

Signed-off-by: Ian Campbell <ian.campbell@docker.com>
2017-07-17 13:37:46 +01:00

37 lines
780 B
Bash
Executable File

#!/bin/bash -eu
: ${KUBE_PORT_BASE:=2222}
if [ $# -eq 0 ] ; then
img="kube-master"
port=${KUBE_PORT_BASE}
data=""
state="kube-master-state"
elif [ $# -gt 1 ] ; 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}"
port=$((${KUBE_PORT_BASE} + $1))
shift
data="${*}"
state="kube-${name}-state"
else
echo "Usage:"
echo " - Boot master:"
echo " ${0}"
echo " - Boot node:"
echo " ${0} <node> <join_args>"
exit 1
fi
set -x
rm -rf "${state}"
../../bin/linuxkit run -publish $port:22 -cpus 2 -mem 4096 -state "${state}" -disk size=4G -data "${data}" "${img}"