wait cluster status to be ready at exec local-up-karmada.sh

Signed-off-by: calvin0327 <wen.chen@daocloud.io>
This commit is contained in:
calvin0327 2022-06-25 17:09:23 +08:00
parent 7d25a7275b
commit 082758937f
2 changed files with 23 additions and 0 deletions

View File

@ -142,6 +142,11 @@ kind load docker-image "${REGISTRY}/karmada-agent:${VERSION}" --name="${PULL_MOD
#step7. deploy karmada agent in pull mode member clusters
"${REPO_ROOT}"/hack/deploy-agent-and-estimator.sh "${MAIN_KUBECONFIG}" "${HOST_CLUSTER_NAME}" "${MAIN_KUBECONFIG}" "${KARMADA_APISERVER_CLUSTER_NAME}" "${MEMBER_CLUSTER_KUBECONFIG}" "${PULL_MODE_CLUSTER_NAME}"
# wait all of clusters member1, member2 and member3 status is ready
util:wait_cluster_ready "${MEMBER_CLUSTER_1_NAME}"
util:wait_cluster_ready "${MEMBER_CLUSTER_2_NAME}"
util:wait_cluster_ready "${PULL_MODE_CLUSTER_NAME}"
function print_success() {
echo -e "$KARMADA_GREETING"
echo "Local Karmada is running."

View File

@ -352,6 +352,24 @@ function util::wait_apiservice_ready() {
return ${ret}
}
# util::wait_cluster_ready waits for cluster state becomes ready until timeout.
# Parmeters:
# - $1: cluster name, such as "member1"
function util:wait_cluster_ready() {
local cluster_name=$1
echo "wait the cluster $cluster_name onBoard..."
set +e
util::kubectl_with_retry wait --for=condition=Ready --timeout=60s clusters ${cluster_name}
ret=$?
set -e
if [ $ret -ne 0 ];then
echo "kubectl describe info:"
kubectl describe clusters ${cluster_name}
fi
return ${ret}
}
# util::kubectl_with_retry will retry if execute kubectl command failed
# tolerate kubectl command failure that may happen before the pod is created by StatefulSet/Deployment.
function util::kubectl_with_retry() {