mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-22 18:41:37 +00:00
kubernetes: support untainting master via metadata
If a stamp file is present in the metadata then untaint. This is useful for dev environments where you only want to start a single vm. The construction of the metadata becomes a little more complex to produce correct json syntax now that there are two (independent) possible options. Likewise the kubelet.sh script now takes the presence of /var/config/kubeadm (rather than /var/config/kubeadm/init) as the signal to use the more structured setup, since we may now have /var/config/kubeadm/untaint-master but not /var/config/kubeadm/init so would otherwise end up passing the contents of `/var/config/userdata` (something like `{ "kubeadm": { "untaint-master": "" } }`) to `kubeadm` and confusing it enormously. Signed-off-by: Ian Campbell <ijc@docker.com>
This commit is contained in:
parent
77f0c75b9d
commit
164c4a30f5
@ -5,6 +5,7 @@ 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}
|
||||
@ -27,10 +28,16 @@ if [ $# -eq 0 ] ; then
|
||||
# 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=""
|
||||
kubeadm_data="${kubeadm_data+$kubeadm_data, }\"init\": \"${KUBE_MASTER_AUTOINIT}\""
|
||||
fi
|
||||
if [ "${KUBE_MASTER_UNTAINT}" = "y" ] ; then
|
||||
kubeadm_data="${kubeadm_data+$kubeadm_data, }\"untaint-master\": \"\""
|
||||
fi
|
||||
|
||||
if [ -n "${kubeadm_data}" ] ; then
|
||||
data="{ \"kubeadm\": { ${kubeadm_data} } }"
|
||||
fi
|
||||
|
||||
state="kube-master-state"
|
||||
|
||||
: ${KUBE_VCPUS:=$KUBE_MASTER_VCPUS}
|
||||
|
@ -7,3 +7,7 @@ for i in /etc/kubeadm/kube-system.init/*.yaml ; do
|
||||
kubectl create -n kube-system -f "$i"
|
||||
fi
|
||||
done
|
||||
if [ -f /var/config/kubeadm/untaint-master ] ; then
|
||||
echo "Removing \"node-role.kubernetes.io/master\" taint from all nodes"
|
||||
kubectl taint nodes --all node-role.kubernetes.io/master-
|
||||
fi
|
||||
|
@ -15,15 +15,17 @@ await=/etc/kubernetes/kubelet.conf
|
||||
|
||||
if [ -f "/etc/kubernetes/kubelet.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.
|
||||
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)
|
||||
await=/etc/kubernetes/bootstrap-kubelet.conf
|
||||
elif [ -d /var/config/kubeadm ] ; then
|
||||
if [ -f /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)
|
||||
await=/etc/kubernetes/bootstrap-kubelet.conf
|
||||
fi
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user