@@ -31,6 +31,8 @@ KUSTOMIZE="${REPO_ROOT}/hack/tools/bin/kustomize"
3131make --directory=" ${REPO_ROOT} " " ${KUBECTL##*/ } " " ${HELM##*/ } " " ${KIND##*/ } " " ${KUSTOMIZE##*/ } "
3232KIND_CLUSTER_NAME=" ${KIND_CLUSTER_NAME:- capz} "
3333WORKER_MACHINE_COUNT=" ${WORKER_MACHINE_COUNT:- 2} "
34+ EXTRA_NODES=" ${EXTRA_NODES:- 0} "
35+ EXTRA_NODES_PER_SCALEOUT=" ${EXTRA_NODES_PER_SCALEOUT:- 100} "
3436export KIND_CLUSTER_NAME
3537# export the variables so they are available in bash -c wait_for_nodes below
3638export KUBECTL
@@ -214,6 +216,29 @@ wait_for_pods() {
214216 done
215217}
216218
219+ # wait_for_extra_nodes accommodates building large clusters gradually
220+ wait_for_extra_nodes () {
221+ local existing_nodes=" ${WORKER_MACHINE_COUNT} "
222+ local remaining_extra_nodes=" ${EXTRA_NODES} "
223+ local total_nodes=" $(( CONTROL_PLANE_MACHINE_COUNT + WORKER_MACHINE_COUNT + WINDOWS_WORKER_MACHINE_COUNT)) "
224+ while [[ " ${remaining_extra_nodes} " -gt " ${EXTRA_NODES_PER_SCALEOUT} " ]]; do
225+ NEW_REPLICA_COUNT=$(( existing_nodes + "${EXTRA_NODES_PER_SCALEOUT} "))
226+ " ${KUBECTL} " --kubeconfig " ${REPO_ROOT} /${KIND_CLUSTER_NAME} .kubeconfig" scale machinedeployment/" ${CLUSTER_NAME} " -md-0 --replicas=" ${NEW_REPLICA_COUNT} "
227+ total_nodes=$(( total_nodes + EXTRA_NODES_PER_SCALEOUT))
228+ while [[ $( " ${KUBECTL} " get nodes -ojson | jq ' .items | length' ) -ne " ${total_nodes} " ]]; do
229+ sleep 10
230+ done
231+ existing_nodes=$(( existing_nodes + EXTRA_NODES_PER_SCALEOUT))
232+ remaining_extra_nodes=$(( remaining_extra_nodes - EXTRA_NODES_PER_SCALEOUT))
233+ done
234+ NEW_REPLICA_COUNT=$(( existing_nodes + remaining_extra_nodes))
235+ " ${KUBECTL} " --kubeconfig " ${REPO_ROOT} /${KIND_CLUSTER_NAME} .kubeconfig" scale machinedeployment/" ${CLUSTER_NAME} " -md-0 --replicas=" ${NEW_REPLICA_COUNT} "
236+ total_nodes=$(( total_nodes + remaining_extra_nodes))
237+ while [[ $( " ${KUBECTL} " get nodes -ojson | jq ' .items | length' ) -ne " ${total_nodes} " ]]; do
238+ sleep 10
239+ done
240+ }
241+
217242install_addons () {
218243 export -f copy_kubeadm_config_map wait_for_copy_kubeadm_config_map
219244 timeout --foreground 600 bash -c wait_for_copy_kubeadm_config_map
@@ -224,6 +249,8 @@ install_addons() {
224249 timeout --foreground 1800 bash -c wait_for_nodes
225250 export -f wait_for_pods
226251 timeout --foreground 1800 bash -c wait_for_pods
252+ export -f wait_for_extra_nodes
253+ timeout --foreground 10800 bash -c wait_for_extra_nodes
227254}
228255
229256copy_secret () {
0 commit comments