Skip to content

Commit dc2299f

Browse files
committed
build large clusters gradually
1 parent fde4351 commit dc2299f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

scripts/ci-entrypoint.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ KUSTOMIZE="${REPO_ROOT}/hack/tools/bin/kustomize"
3131
make --directory="${REPO_ROOT}" "${KUBECTL##*/}" "${HELM##*/}" "${KIND##*/}" "${KUSTOMIZE##*/}"
3232
KIND_CLUSTER_NAME="${KIND_CLUSTER_NAME:-capz}"
3333
WORKER_MACHINE_COUNT="${WORKER_MACHINE_COUNT:-2}"
34+
EXTRA_NODES="${EXTRA_NODES:-0}"
3435
export KIND_CLUSTER_NAME
3536
# export the variables so they are available in bash -c wait_for_nodes below
3637
export KUBECTL
@@ -214,6 +215,22 @@ wait_for_pods() {
214215
done
215216
}
216217

218+
# wait_for_extra_nodes accommodates building large clusters gradually
219+
wait_for_extra_nodes() {
220+
local existing_nodes="${WORKER_MACHINE_COUNT}"
221+
local remaining_extra_nodes="${EXTRA_NODES}"
222+
while [[ "${remaining_extra_nodes}" -gt 10 ]]; do
223+
NEW_REPLICA_COUNT=$((existing_nodes + 10))
224+
"${KUBECTL}" --kubeconfig "${REPO_ROOT}/${KIND_CLUSTER_NAME}.kubeconfig" scale machinedeployment/"${CLUSTER_NAME}"-md-0 --replicas="${NEW_REPLICA_COUNT}"
225+
sleep 120
226+
existing_nodes=$((existing_nodes + 10))
227+
remaining_extra_nodes=$((remaining_extra_nodes - 10))
228+
done
229+
NEW_REPLICA_COUNT=$((existing_nodes + remaining_extra_nodes))
230+
"${KUBECTL}" --kubeconfig "${REPO_ROOT}/${KIND_CLUSTER_NAME}.kubeconfig" scale machinedeployment/"${CLUSTER_NAME}"-md-0 --replicas="${NEW_REPLICA_COUNT}"
231+
sleep 120
232+
}
233+
217234
install_addons() {
218235
export -f copy_kubeadm_config_map wait_for_copy_kubeadm_config_map
219236
timeout --foreground 600 bash -c wait_for_copy_kubeadm_config_map
@@ -224,6 +241,8 @@ install_addons() {
224241
timeout --foreground 1800 bash -c wait_for_nodes
225242
export -f wait_for_pods
226243
timeout --foreground 1800 bash -c wait_for_pods
244+
export -f wait_for_extra_nodes
245+
timeout --foreground 10800 bash -c wait_for_pods
227246
}
228247

229248
copy_secret() {

0 commit comments

Comments
 (0)