Various checks bugfixes

This commit is contained in:
Guillaume 2023-06-25 19:47:27 +02:00
parent 4877387140
commit a805e5d513

View File

@ -21,7 +21,7 @@ checkup() {
while : while :
do do
pinfo "Checking availability of node $host..." pinfo "Checking availability of node $host..."
if true | sshcmd root@${hosts[$host]}; if true | sshcmd -q root@${hosts[$host]};
then then
pinfo "VM $host is up!" pinfo "VM $host is up!"
break break
@ -39,7 +39,7 @@ checkup() {
start_control_plane() { start_control_plane() {
for host in ${!hosts[*]}; do for host in ${!hosts[*]}; do
sshcmd root@${hosts[$host]} << EOF sshcmd -q root@${hosts[$host]} << EOF
if ls /etc/kubernetes/manifests.static/* &>/dev/null ; then if ls /etc/kubernetes/manifests.static/* &>/dev/null ; then
mv /etc/kubernetes/manifests.static/* /var/lib/kubelet/manifests/ mv /etc/kubernetes/manifests.static/* /var/lib/kubelet/manifests/
fi fi
@ -51,7 +51,6 @@ wait_for_apiserver() {
vip=$(extract_var clusters public_vip) vip=$(extract_var clusters public_vip)
vip_api_port=$(extract_var clusters api_port) vip_api_port=$(extract_var clusters api_port)
sleep 20
while : while :
do do
pinfo "Waiting for apiserver availability ($vip:$vip_api_port). Images may still being pulled... " pinfo "Waiting for apiserver availability ($vip:$vip_api_port). Images may still being pulled... "
@ -59,7 +58,7 @@ wait_for_apiserver() {
pinfo "API is up!" pinfo "API is up!"
break break
else else
sleep 30 sleep 20
fi fi
done done
@ -73,20 +72,20 @@ install_addons() {
} }
approve_kubelet_certificates() { approve_kubelet_certificates() {
tries=5 tries=10
nodes_num=$(kctl get node -oname|wc -l) nodes_num=$(kctl get node -oname|wc -l)
while [ "$nodes_num" != "${#hosts[*]}" ] ; do while [ "$nodes_num" -lt "${#hosts[*]}" ] ; do
pinfo "Waiting for certificates requests to be created by Kubelet when it's ready... ($tries/5)" pinfo "Waiting for certificates requests to be created by Kubelet when it's ready... ($tries tries out of 10)"
sleep 60s sleep 20s
csrs="$(kctl get csr|awk '/Pending/ {print $1}')" csrs="$(kctl get csr|awk '/Pending/ {print $1}')"
if [ "$csrs" != "" ]; then if [ "$csrs" != "" ]; then
kctl certificate approve $csrs kctl certificate approve $csrs
fi fi
((tries--)) ((tries--))
if [ "$tries" -lt "1" ]; then if [ "$tries" -lt "1" ]; then
pinfo "Timeout waiting for kubelet certificates creation, please investigate why all nodes are not up by now" perror "Timeout waiting for kubelet certificates creation, please investigate why all nodes are not up by now"
break
fi fi
nodes_num=$(kctl get node -oname|wc -l)
done done
pinfo "All kubelets ($nodes_num) are up, enjoy !" pinfo "All kubelets ($nodes_num) are up, enjoy !"
} }
@ -100,8 +99,8 @@ unlock_store
declare -A hosts && get_hosts declare -A hosts && get_hosts
checkup checkup
start_control_plane start_control_plane
wait_for_apiserver
create_kubeconfig create_kubeconfig
wait_for_apiserver
install_addons install_addons
approve_kubelet_certificates # clients and serving certs approve_kubelet_certificates # clients and serving certs