avoid waiting when creating calico cluster with kind (#5064)

Currently the --wait flag times out when creating a calico cluster. The result is that we end up waiting for 5 minutes to simply emit a warning and continue. Instead we can check the readiness of some k8s components to ensure our cluster is up and running and avoid the delay.

Signed-off-by: Zahari Dichev zaharidichev@gmail.com
This commit is contained in:
Zahari Dichev 2020-10-12 18:26:00 +03:00 committed by GitHub
parent 777b06ac55
commit 60d8f34095
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 1 deletions

View File

@ -138,7 +138,29 @@ check_linkerd_binary() {
create_kind_cluster() { create_kind_cluster() {
local name=$1 local name=$1
local config=$2 local config=$2
"$bindir"/kind create cluster --name "$name" --config "$test_directory"/configs/"$config".yaml --wait 300s 2>&1 if [ "$config" = "cni-calico" ]; then
# this is a workaround the fact that the --wait
# flag always times out with the calico setup
# the result of that is that we are always
# wasting 5m on this job
# issue: https://github.com/kubernetes-sigs/kind/issues/1889
cp_pod="kube-apiserver-cni-calico-deep-control-plane"
cm_pod="kube-controller-manager-cni-calico-deep-control-plane"
ks_pod="kube-scheduler-cni-calico-deep-control-plane"
etcd_pod="etcd-cni-calico-deep-control-plane"
"$bindir"/kind create cluster --name "$name" --config "$test_directory"/configs/"$config".yaml 2>&1
echo 'Waiting for api server'
kubectl --context="$context" -n kube-system wait --for=condition=initialized --timeout=120s pod/"$cp_pod" > /dev/null 2>&1
echo 'Waiting for kube controller'
kubectl --context="$context" -n kube-system wait --for=condition=initialized --timeout=120s pod/"$cm_pod" > /dev/null 2>&1
echo 'Waiting for kube scheduler'
kubectl --context="$context" -n kube-system wait --for=condition=initialized --timeout=120s pod/"$ks_pod" > /dev/null 2>&1
echo 'Waiting for kube etcd'
kubectl --context="$context" -n kube-system wait --for=condition=initialized --timeout=120s pod/"$etcd_pod" > /dev/null 2>&1
else
"$bindir"/kind create cluster --name "$name" --config "$test_directory"/configs/"$config".yaml --wait 300s 2>&1
fi
exit_on_err 'error creating KinD cluster' exit_on_err 'error creating KinD cluster'
export context="kind-$name" export context="kind-$name"
} }