From ab7e693d76500b6cdc2068221bdfce16633a8b01 Mon Sep 17 00:00:00 2001 From: Orzelius Date: Mon, 5 May 2025 21:28:35 +0900 Subject: [PATCH] chore: make qemu lb address bind work on darwin The loadbalancer is bound to all interfaces on macos. The bridge interface address is not used as the bridge is not yet created at this stage. Multiple loadbalancers can be assigned via different ports. Signed-off-by: Orzelius <33936483+Orzelius@users.noreply.github.com> --- pkg/provision/providers/vm/loadbalancer.go | 2 +- pkg/provision/providers/vm/loadbalancer_darwin.go | 14 ++++++++++++++ pkg/provision/providers/vm/loadbalancer_linux.go | 12 ++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 pkg/provision/providers/vm/loadbalancer_darwin.go create mode 100644 pkg/provision/providers/vm/loadbalancer_linux.go diff --git a/pkg/provision/providers/vm/loadbalancer.go b/pkg/provision/providers/vm/loadbalancer.go index 635fb273e..27379323b 100644 --- a/pkg/provision/providers/vm/loadbalancer.go +++ b/pkg/provision/providers/vm/loadbalancer.go @@ -38,7 +38,7 @@ func (p *Provisioner) CreateLoadBalancer(state *State, clusterReq provision.Clus args := []string{ "loadbalancer-launch", - "--loadbalancer-addr", clusterReq.Network.GatewayAddrs[0].String(), + "--loadbalancer-addr", getLbBindIP(clusterReq.Network.GatewayAddrs[0]), "--loadbalancer-upstreams", strings.Join(controlPlaneIPs, ","), } diff --git a/pkg/provision/providers/vm/loadbalancer_darwin.go b/pkg/provision/providers/vm/loadbalancer_darwin.go new file mode 100644 index 000000000..ce9dd2e4c --- /dev/null +++ b/pkg/provision/providers/vm/loadbalancer_darwin.go @@ -0,0 +1,14 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +package vm + +import "net/netip" + +// getLbBindIP returns the 0.0.0.0 address to bind to all interfaces on macos. +// The bridge interface address is not used as the bridge is not yet created at this stage. +// Multiple loadbalancers can be assigned via different ports. +func getLbBindIP(_ netip.Addr) string { + return "0.0.0.0" +} diff --git a/pkg/provision/providers/vm/loadbalancer_linux.go b/pkg/provision/providers/vm/loadbalancer_linux.go new file mode 100644 index 000000000..a93d03a7b --- /dev/null +++ b/pkg/provision/providers/vm/loadbalancer_linux.go @@ -0,0 +1,12 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +package vm + +import "net/netip" + +// getLbBindIP returns the gateway address to bind the loadbalancer to the bridge interface. +func getLbBindIP(gateway netip.Addr) string { + return gateway.String() +}