Skip to content

Commit b0164ea

Browse files
committed
openstack: Reserve addresses for load balancer
When using Octavia, we use the .5 and .7 addresses on the first machine network for API and Ingress VIP, respectively [1]. However, we were not reserving these address when creating the network. This can result in an IP collision if another service happens to allocate one of these two IPs before the load balancer is created. This can happen if DHCP agents are running on the controller/network nodes, as each agent creates its own DHCP port on the subnet. The solution is to use allocation pools - which are designed exactly for this purpose - and configure one on the subnet we create (via CAPO). We reserve everything < .10 in case we need more addresses down the line. [1] `SetPlatformDefaults` in `pkg/types/openstack/defaults/platform.go` Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
1 parent f7fc26d commit b0164ea

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

pkg/asset/manifests/openstack/cluster.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"os"
66

7+
"github.com/apparentlymart/go-cidr/cidr"
78
"github.com/gophercloud/utils/v2/openstack/clientconfig"
89
corev1 "k8s.io/api/core/v1"
910
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -81,10 +82,22 @@ func GenerateClusterAssets(installConfig *installconfig.InstallConfig, clusterID
8182
}
8283
}
8384
} else {
85+
networkCIDR := capiutils.CIDRFromInstallConfig(installConfig)
86+
allocationStart, err := cidr.Host(&networkCIDR.IPNet, 10)
87+
if err != nil {
88+
return nil, err
89+
}
90+
_, allocationEnd := cidr.AddressRange(&networkCIDR.IPNet)
8491
openStackCluster.Spec.ManagedSubnets = []capo.SubnetSpec{
8592
{
86-
CIDR: capiutils.CIDRFromInstallConfig(installConfig).String(),
93+
CIDR: networkCIDR.String(),
8794
DNSNameservers: openstackInstallConfig.ExternalDNS,
95+
AllocationPools: []capo.AllocationPool{
96+
{
97+
Start: allocationStart.String(),
98+
End: allocationEnd.String(),
99+
},
100+
},
88101
},
89102
}
90103
}

0 commit comments

Comments
 (0)