-
Notifications
You must be signed in to change notification settings - Fork 75
/
boot.sh
executable file
·100 lines (84 loc) · 2.47 KB
/
boot.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/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_CLEAR_STATE:=}
: ${KUBE_METADATA:=} # Without the outermost braces {}.
[ "$(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\": { \"content\": \"${KUBE_MASTER_AUTOINIT}\" }"
fi
if [ "${KUBE_MASTER_UNTAINT}" = "y" ] ; then
kubeadm_data="${kubeadm_data:+$kubeadm_data, }\"untaint-master\": { \"content\": \"\" }"
fi
state="kube-master-state"
: ${KUBE_VCPUS:=$KUBE_MASTER_VCPUS}
: ${KUBE_MEM:=$KUBE_MASTER_MEM}
: ${KUBE_DISK:=$KUBE_MASTER_DISK}
elif [ $# -ge 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}"
shift
if [ $# -ge 1 ] ; then
kubeadm_data="\"join\": { \"content\": \"${*}\" }"
fi
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 [ -n "${KUBE_CLEAR_STATE}" ] ; then
rm -rf "${state}"
mkdir "${state}"
if [ -n "${KUBE_MAC}" ] ; then
echo -n "${KUBE_MAC}" > "${state}"/mac-addr
fi
fi
mkdir -p "${state}"
touch $state/metadata.json
if [ -n "${KUBE_METADATA}" ] ; then
metadata="${metadata:+$metadata, }${KUBE_METADATA}"
fi
if [ -n "${kubeadm_data}" ] ; then
metadata="${metadata:+$metadata, }\"kubeadm\": { \"entries\": { ${kubeadm_data} } }"
fi
if [ -n "${metadata}" ] ; then
metadata="{ ${metadata} }"
echo "${metadata}" > $state/metadata.json
fi
exec linuxkit run ${KUBE_RUN_ARGS} -networking ${KUBE_NETWORKING} -cpus ${KUBE_VCPUS} -mem ${KUBE_MEM} -state "${state}" -disk size=${KUBE_DISK} -data-file $state/metadata.json -iso ${uefi} "${img}${suffix}"