From d0cd27d64399a599768339ae6a3bd11d60347f5a Mon Sep 17 00:00:00 2001 From: Michael Nairn Date: Mon, 13 Jan 2025 14:44:00 +0000 Subject: [PATCH] Allow setting metallb CIDR value for local env The default CIDR value (/28) allows for 16 ips to be assigned which is fine for the majority of dev/test/demo needs. However, when trying to test at scale it is useful to be able to create more Gateways on a single cluster and therefore more IPs can be required. Changes here allow the CIDR and number of IP values used by the local setup script to be set as required, default is the same as before (/28 & 16 IPs). ``` make local-setup SUBNET_OFFSET=0 CIDR=26 NUM_IPS=64 ``` Signed-off-by: Michael Nairn --- make/development-environments.mk | 6 ++++-- utils/docker-network-ipaddresspool.sh | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/make/development-environments.mk b/make/development-environments.mk index 3c8efb58a..941867bd7 100644 --- a/make/development-environments.mk +++ b/make/development-environments.mk @@ -8,12 +8,14 @@ uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified $(KUSTOMIZE) build config/crd | kubectl delete -f - .PHONY: install-metallb -install-metallb: SUBNET_OFFSET=1 +install-metallb: SUBNET_OFFSET=0 +install-metallb: CIDR=28 +install-metallb: NUM_IPS=16 install-metallb: kustomize yq ## Installs the metallb load balancer allowing use of an LoadBalancer type with a gateway $(KUSTOMIZE) build config/metallb | kubectl apply -f - kubectl -n metallb-system wait --for=condition=Available deployments controller --timeout=300s kubectl -n metallb-system wait --for=condition=ready pod --selector=app=metallb --timeout=60s - ./utils/docker-network-ipaddresspool.sh kind $(YQ) ${SUBNET_OFFSET} | kubectl apply -n metallb-system -f - + ./utils/docker-network-ipaddresspool.sh kind $(YQ) ${SUBNET_OFFSET} ${CIDR} ${NUM_IPS} | kubectl apply -n metallb-system -f - .PHONY: uninstall-metallb uninstall-metallb: $(KUSTOMIZE) diff --git a/utils/docker-network-ipaddresspool.sh b/utils/docker-network-ipaddresspool.sh index 2e0b1b18f..f3342a455 100755 --- a/utils/docker-network-ipaddresspool.sh +++ b/utils/docker-network-ipaddresspool.sh @@ -11,8 +11,8 @@ set -euo pipefail networkName=$1 YQ="${2:-yq}" offset=${3:-0} -cidr=28 -numIPs=16 +cidr=${4:-28} +numIPs=${5:-16} ## Parse kind network subnet ## Take only IPv4 subnets, exclude IPv6