mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-20 17:49:10 +00:00
kubernetes: support auto-init via metadata
Set KUBE_MASTER_AUTOINIT when using boot.sh to enable. User will need to pick up the token for other nodes using `kubeadm token list`. Signed-off-by: Ian Campbell <ijc@docker.com>
This commit is contained in:
parent
3ce260cb9a
commit
5c4c25cac6
@ -23,7 +23,14 @@ suffix=".iso"
|
||||
|
||||
if [ $# -eq 0 ] ; then
|
||||
img="kube-master"
|
||||
data=""
|
||||
# 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
|
||||
data="{\"kubeadm\": {\"init\": \"${KUBE_MASTER_AUTOINIT}\"} }"
|
||||
else
|
||||
data=""
|
||||
fi
|
||||
state="kube-master-state"
|
||||
|
||||
: ${KUBE_VCPUS:=$KUBE_MASTER_VCPUS}
|
||||
@ -44,7 +51,7 @@ elif [ $# -gt 1 ] || [ $# -eq 1 -a -n "${KUBE_PRESERVE_STATE}" ] ; then
|
||||
img="kube-node"
|
||||
name="node-${1}"
|
||||
shift
|
||||
data="${*}"
|
||||
data="{\"kubeadm\": {\"join\": \"${*}\"} }"
|
||||
state="kube-${name}-state"
|
||||
|
||||
: ${KUBE_VCPUS:=$KUBE_NODE_VCPUS}
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
kubeadm init --skip-preflight-checks --kubernetes-version @KUBERNETES_VERSION@
|
||||
kubeadm init --skip-preflight-checks --kubernetes-version @KUBERNETES_VERSION@ $@
|
||||
for i in /etc/kubeadm/kube-system.init/*.yaml ; do
|
||||
if [ -e "$i" ] ; then
|
||||
echo "Applying "$(basename "$i")
|
||||
|
@ -10,7 +10,15 @@ fi
|
||||
if [ -e /etc/kubelet.conf ] ; then
|
||||
. /etc/kubelet.conf
|
||||
fi
|
||||
if [ -e /var/config/userdata ] ; then
|
||||
if [ -e /var/config/kubeadm/init ] ; then
|
||||
echo "kubelet.sh: init cluster with metadata \"$(cat /var/config/kubeadm/init)\""
|
||||
# This needs to be in the background since it waits for kubelet to start.
|
||||
# We skip printing the token so it is not persisted in the log.
|
||||
kubeadm-init.sh --skip-token-print $(cat /var/config/kubeadm/init) &
|
||||
elif [ -e /var/config/kubeadm/join ] ; then
|
||||
echo "kubelet.sh: joining cluster with metadata \"$(cat /var/config/kubeadm/join)\""
|
||||
kubeadm join --skip-preflight-checks $(cat /var/config/kubeadm/join)
|
||||
elif [ -e /var/config/userdata ] ; then
|
||||
echo "kubelet.sh: joining cluster with metadata \"$(cat /var/config/userdata)\""
|
||||
kubeadm join --skip-preflight-checks $(cat /var/config/userdata)
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user