kubernetes: do not try to re-init the cluster on subsequent boots

If `kubelet.conf` already exits then don't try to redo `kubeadm`, no matter
what the metadata requests.

Signed-off-by: Ian Campbell <ijc@docker.com>
This commit is contained in:
Ian Campbell 2017-10-02 10:47:03 +01:00
parent 367c7e2c88
commit 6d387bf59d

View File

@ -10,7 +10,12 @@ fi
if [ -e /etc/kubelet.sh.conf ] ; then
. /etc/kubelet.sh.conf
fi
if [ -e /var/config/kubeadm/init ] ; then
conf=/var/lib/kubeadm/kubelet.conf
if [ -f "${conf}" ] ; then
echo "kubelet.sh: kubelet already configured"
elif [ -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.
@ -23,8 +28,6 @@ elif [ -e /var/config/userdata ] ; then
kubeadm join --skip-preflight-checks $(cat /var/config/userdata)
fi
conf=/var/lib/kubeadm/kubelet.conf
echo "kubelet.sh: waiting for ${conf}"
# TODO(ijc) is there a race between kubeadm creating this file and
# finishing the write where we might be able to fall through and