-
Notifications
You must be signed in to change notification settings - Fork 75
/
Copy pathkubeadm-init.sh
executable file
·36 lines (35 loc) · 1.32 KB
/
kubeadm-init.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
#!/bin/sh
set -e
touch /var/lib/kubeadm/.kubeadm-init.sh-started
if [ -f /etc/kubeadm/kubeadm.yaml ]; then
echo Using the configuration from /etc/kubeadm/kubeadm.yaml
if [ $# -ne 0 ] ; then
echo WARNING: Ignoring command line options: $@
fi
kubeadm init --ignore-preflight-errors=all --config /etc/kubeadm/kubeadm.yaml
else
kubeadm init --ignore-preflight-errors=all --kubernetes-version @KUBERNETES_VERSION@ $@
fi
# sorting by basename relies on the dirnames having the same number of directories
YAML=$(ls -1 /run/config/kube-system.init/*.yaml /etc/kubeadm/kube-system.init/*.yaml 2>/dev/null | sort --field-separator=/ --key=5)
for i in ${YAML}; do
n=$(basename "$i")
if [ -e "$i" ] ; then
if [ ! -s "$i" ] ; then # ignore zero sized files
echo "Ignoring zero size file $n"
continue
fi
echo "Applying $n"
if ! kubectl create -n kube-system -f "$i" ; then
touch /var/lib/kubeadm/.kubeadm-init.sh-kube-system.init-failed
touch /var/lib/kubeadm/.kubeadm-init.sh-kube-system.init-"$n"-failed
echo "Failed to apply $n"
continue
fi
fi
done
if [ -f /run/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
touch /var/lib/kubeadm/.kubeadm-init.sh-finished