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.