mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-20 09:39:08 +00:00
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>
This commit is contained in:
parent
ce35fea83e
commit
2cfac0e8bb
@ -1,11 +1,25 @@
|
|||||||
#!/bin/bash -eu
|
#!/bin/bash -eu
|
||||||
|
: ${KUBE_PORT_BASE:=2222}
|
||||||
if [ $# -eq 0 ] ; then
|
if [ $# -eq 0 ] ; then
|
||||||
img="kube-master"
|
img="kube-master"
|
||||||
|
port=${KUBE_PORT_BASE}
|
||||||
data=""
|
data=""
|
||||||
state="kube-master-state"
|
state="kube-master-state"
|
||||||
elif [ $# -gt 1 ] ; then
|
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"
|
img="kube-node"
|
||||||
name="node-${1}"
|
name="node-${1}"
|
||||||
|
port=$((${KUBE_PORT_BASE} + $1))
|
||||||
shift
|
shift
|
||||||
data="${*}"
|
data="${*}"
|
||||||
state="kube-${name}-state"
|
state="kube-${name}-state"
|
||||||
@ -19,4 +33,4 @@ else
|
|||||||
fi
|
fi
|
||||||
set -x
|
set -x
|
||||||
rm -rf "${state}"
|
rm -rf "${state}"
|
||||||
../../bin/linuxkit run -cpus 2 -mem 4096 -state "${state}" -disk size=4G -data "${data}" "${img}"
|
../../bin/linuxkit run -publish $port:22 -cpus 2 -mem 4096 -state "${state}" -disk size=4G -data "${data}" "${img}"
|
||||||
|
Loading…
Reference in New Issue
Block a user