From aa854c106caf6ecaa99ae1f4fc0ec501b1646019 Mon Sep 17 00:00:00 2001 From: zirain Date: Sat, 18 May 2024 07:56:58 +0800 Subject: [PATCH] chore: support multi nodes cluster (#3422) * chore: support multi nodes cluster Signed-off-by: zirain * nit Signed-off-by: zirain --------- Signed-off-by: zirain --- tools/hack/create-cluster.sh | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/tools/hack/create-cluster.sh b/tools/hack/create-cluster.sh index a78adaffd57..992ee5def92 100755 --- a/tools/hack/create-cluster.sh +++ b/tools/hack/create-cluster.sh @@ -6,12 +6,33 @@ set -euo pipefail CLUSTER_NAME=${CLUSTER_NAME:-"envoy-gateway"} METALLB_VERSION=${METALLB_VERSION:-"v0.13.10"} KIND_NODE_TAG=${KIND_NODE_TAG:-"v1.28.0"} +NUM_WORKERS=${NUM_WORKERS:-""} + + +KIND_CFG=$(cat <<-EOM +kind: Cluster +apiVersion: kind.x-k8s.io/v1alpha4 +nodes: +- role: control-plane +EOM +) + +# https://kind.sigs.k8s.io/docs/user/quick-start/#multi-node-clusters +if [[ -n "${NUM_WORKERS}" ]]; then +for _ in $(seq 1 "${NUM_WORKERS}"); do + KIND_CFG+=$(printf "\n%s" "- role: worker") +done +fi ## Create kind cluster. if [[ -z "${KIND_NODE_TAG}" ]]; then - tools/bin/kind create cluster --name "${CLUSTER_NAME}" + cat << EOF | tools/bin/kind create cluster --name "${CLUSTER_NAME}" --config - +${KIND_CFG} +EOF else - tools/bin/kind create cluster --image "kindest/node:${KIND_NODE_TAG}" --name "${CLUSTER_NAME}" + cat << EOF | tools/bin/kind create cluster --image "kindest/node:${KIND_NODE_TAG}" --name "${CLUSTER_NAME}" --config - +${KIND_CFG} +EOF fi ## Install MetalLB.