Skip to content

Commit

Permalink
fix: metallb addresspool setup
Browse files Browse the repository at this point in the history
Update the docker network ipaddresspool setup script to account for
network configs that do not have the IPv4 address as the first element
of the array.
  • Loading branch information
mikenairn committed Feb 9, 2024
1 parent 133645e commit e2d6f33
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ local-deploy: ## Deploy Kuadrant Operator in the cluster pointed by KUBECONFIG
@echo

.PHONY: local-setup
local-setup: $(KIND) ## Deploy locally kuadrant operator from the current code
local-setup: kind ## Deploy locally kuadrant operator from the current code
$(MAKE) local-env-setup
$(MAKE) local-deploy

Expand Down Expand Up @@ -408,11 +408,11 @@ undeploy-policy-controller: ## Undeploy policy-controller from the K8s cluster s
$(KUSTOMIZE) build config/policy-controller | kubectl delete -f -

.PHONY: install-metallb
install-metallb: $(KUSTOMIZE) ## Installs the metallb load balancer allowing use of an LoadBalancer type with a gateway
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 | kubectl apply -n metallb-system -f -
./utils/docker-network-ipaddresspool.sh kind ${YQ} | kubectl apply -n metallb-system -f -

.PHONY: uninstall-metallb
uninstall-metallb: $(KUSTOMIZE)
Expand Down
8 changes: 7 additions & 1 deletion utils/docker-network-ipaddresspool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@
set -euo pipefail

networkName=$1
YQ="${2:-yq}"

subnet=`docker network inspect $networkName -f json | $YQ -r -o=json '.[].IPAM.Config.[] | select(.Gateway | test("^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$")).Subnet'`
if [[ -z "$subnet" ]]; then
echo "Error: parsing IPv4 network address for '$networkName' docker network"
exit 1
fi

subnet=`docker network inspect $networkName -f '{{ (index .IPAM.Config 0).Subnet }}'`
# shellcheck disable=SC2206
subnetParts=(${subnet//./ })
cidr="${subnetParts[0]}.${subnetParts[1]}.200.0/24"
Expand Down

0 comments on commit e2d6f33

Please sign in to comment.