use http check instead of ssh to detect when controlplane is ready

This commit is contained in:
John Bowdre 2022-12-06 16:42:44 -06:00
parent b93e07740d
commit 1e1d3e4b1a
2 changed files with 17 additions and 4 deletions

View file

@ -63,14 +63,27 @@ EOF
exit 1 exit 1
fi fi
fi fi
echo ">> Waiting up to 15 minutes for all nodes to be Ready..." echo ">> Waiting up to 10 minutes for all control-plane nodes to be Ready..."
python3 -m http.server & python3 -m http.server &
PROC_ID=$! PROC_ID=$!
attempts_max=90 attempts_max=60
attempt=0
until [ "$(kubectl get nodes | grep -c ' control-plane ')" -eq "${K8S_CONTROLPLANE_COUNT}" ]; do
if [ ${attempt} -eq ${attempts_max} ]; then
echo ">> [ERROR] Timeout waiting for control-plane nodes to join! <<"
exit 1
fi
attempt=$((attempt+1))
sleep 10
done
echo ">> Continuing after $((attempt*10)) seconds."
touch .k8s-controlplane-success
echo ">> Waiting up to 10 minutes for all worker nodes to be Ready..."
attempts_max=60
attempt=0 attempt=0
until [ "$(kubectl get nodes | grep -c ' Ready ')" == "${K8S_NODE_COUNT}" ]; do until [ "$(kubectl get nodes | grep -c ' Ready ')" == "${K8S_NODE_COUNT}" ]; do
if [ ${attempt} -eq ${attempts_max} ]; then if [ ${attempt} -eq ${attempts_max} ]; then
echo ">> [ERROR] Timeout waiting for cluster online! <<" echo ">> [ERROR] Timeout waiting for worker nodes to join! <<"
exit 1 exit 1
fi fi
attempt=$((attempt+1)) attempt=$((attempt+1))

View file

@ -17,7 +17,7 @@ echo ">> Continuing after $((attempt*10)) seconds."
echo ">> Waiting up to 10 minutes for all control-plane nodes..." echo ">> Waiting up to 10 minutes for all control-plane nodes..."
attempts_max=60 attempts_max=60
attempt=0 attempt=0
until [ "$(ssh -o StrictHostKeyChecking=no "${K8S_CONTROLPLANE_VIP}" kubectl get nodes | grep -c " control-plane ")" -eq "${K8S_CONTROLPLANE_COUNT}" ]; do until "$(wget http://${K8S_CONTROLPLANE_VIP}:8000/.k8s-controlplane-success)" 2>/dev/null; do
if [ ${attempt} -eq ${attempts_max} ]; then if [ ${attempt} -eq ${attempts_max} ]; then
echo ">> [ERROR] Timeout waiting for control-plane nodes! <<" echo ">> [ERROR] Timeout waiting for control-plane nodes! <<"
exit 1 exit 1