Skip to content

Commit e2897fb

Browse files
committed
feat: add configurable loadbalancer network
Previously when loadbalacer was created it used the same network/subnet as the control plane nodes for the VIP. This was not always the right assumption as some users might want to be able to customize this according to their env. This commit fixes the above by adding two fields into OpenStackClusterSpec/Status two fields `network` and `subnets` under `APIServerLoadBalancer` so that user can define which network/subnet to use for allocation of the loadbalancer. Signed-off-by: Ondrej Blazek <[email protected]>
1 parent acc680d commit e2897fb

13 files changed

+738
-74
lines changed

api/v1alpha5/zz_generated.conversion.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha6/openstackcluster_conversion.go

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,13 @@ func restorev1beta1ClusterSpec(previous *infrav1.OpenStackClusterSpec, dst *infr
210210
dst.APIServerLoadBalancer.Enabled = previous.APIServerLoadBalancer.Enabled
211211
}
212212
optional.RestoreString(&previous.APIServerLoadBalancer.Provider, &dst.APIServerLoadBalancer.Provider)
213+
214+
if previous.APIServerLoadBalancer.Network != nil {
215+
dst.APIServerLoadBalancer.Network = previous.APIServerLoadBalancer.Network
216+
}
217+
if previous.APIServerLoadBalancer.Subnets != nil {
218+
dst.APIServerLoadBalancer.Subnets = previous.APIServerLoadBalancer.Subnets
219+
}
213220
}
214221
if dst.APIServerLoadBalancer.IsZero() {
215222
dst.APIServerLoadBalancer = previous.APIServerLoadBalancer
@@ -294,6 +301,18 @@ func Convert_v1alpha6_OpenStackClusterSpec_To_v1beta1_OpenStackClusterSpec(in *O
294301
return nil
295302
}
296303

304+
func Convert_v1beta1_APIServerLoadBalancer_To_v1alpha6_APIServerLoadBalancer(in *infrav1.APIServerLoadBalancer, out *APIServerLoadBalancer, s apiconversion.Scope) error {
305+
return autoConvert_v1beta1_APIServerLoadBalancer_To_v1alpha6_APIServerLoadBalancer(in, out, s)
306+
}
307+
308+
func Convert_v1beta1_LoadBalancer_To_v1alpha6_LoadBalancer(in *infrav1.LoadBalancer, out *LoadBalancer, s apiconversion.Scope) error {
309+
return autoConvert_v1beta1_LoadBalancer_To_v1alpha6_LoadBalancer(in, out, s)
310+
}
311+
312+
func Convert_v1alpha6_APIServerLoadBalancer_To_v1beta1_APIServerLoadBalancer(in *APIServerLoadBalancer, out *infrav1.APIServerLoadBalancer, s apiconversion.Scope) error {
313+
return autoConvert_v1alpha6_APIServerLoadBalancer_To_v1beta1_APIServerLoadBalancer(in, out, s)
314+
}
315+
297316
func Convert_v1beta1_OpenStackClusterSpec_To_v1alpha6_OpenStackClusterSpec(in *infrav1.OpenStackClusterSpec, out *OpenStackClusterSpec, s apiconversion.Scope) error {
298317
err := autoConvert_v1beta1_OpenStackClusterSpec_To_v1alpha6_OpenStackClusterSpec(in, out, s)
299318
if err != nil {
@@ -375,6 +394,10 @@ func restorev1beta1ClusterStatus(previous *infrav1.OpenStackClusterStatus, dst *
375394
dst.BastionSecurityGroup = previous.BastionSecurityGroup
376395

377396
restorev1beta1BastionStatus(previous.Bastion, dst.Bastion)
397+
398+
if previous.APIServerLoadBalancer != nil {
399+
dst.APIServerLoadBalancer = previous.APIServerLoadBalancer
400+
}
378401
}
379402

380403
func Convert_v1beta1_OpenStackClusterStatus_To_v1alpha6_OpenStackClusterStatus(in *infrav1.OpenStackClusterStatus, out *OpenStackClusterStatus, s apiconversion.Scope) error {
@@ -390,7 +413,16 @@ func Convert_v1beta1_OpenStackClusterStatus_To_v1alpha6_OpenStackClusterStatus(i
390413
}
391414

392415
out.Network.Router = (*Router)(in.Router)
393-
out.Network.APIServerLoadBalancer = (*LoadBalancer)(in.APIServerLoadBalancer)
416+
if in.APIServerLoadBalancer != nil {
417+
out.Network.APIServerLoadBalancer = &LoadBalancer{
418+
Name: in.APIServerLoadBalancer.Name,
419+
ID: in.APIServerLoadBalancer.ID,
420+
IP: in.APIServerLoadBalancer.IP,
421+
InternalIP: in.APIServerLoadBalancer.InternalIP,
422+
AllowedCIDRs: in.APIServerLoadBalancer.AllowedCIDRs,
423+
Tags: in.APIServerLoadBalancer.Tags,
424+
}
425+
}
394426
}
395427

396428
return nil
@@ -405,7 +437,16 @@ func Convert_v1alpha6_OpenStackClusterStatus_To_v1beta1_OpenStackClusterStatus(i
405437
// Router and APIServerLoadBalancer have been moved out of Network in v1beta1
406438
if in.Network != nil {
407439
out.Router = (*infrav1.Router)(in.Network.Router)
408-
out.APIServerLoadBalancer = (*infrav1.LoadBalancer)(in.Network.APIServerLoadBalancer)
440+
if in.Network.APIServerLoadBalancer != nil {
441+
out.APIServerLoadBalancer = &infrav1.LoadBalancer{
442+
Name: in.Network.APIServerLoadBalancer.Name,
443+
ID: in.Network.APIServerLoadBalancer.ID,
444+
IP: in.Network.APIServerLoadBalancer.IP,
445+
InternalIP: in.Network.APIServerLoadBalancer.InternalIP,
446+
AllowedCIDRs: in.Network.APIServerLoadBalancer.AllowedCIDRs,
447+
Tags: in.Network.APIServerLoadBalancer.Tags,
448+
}
449+
}
409450
}
410451

411452
return nil

api/v1alpha6/zz_generated.conversion.go

Lines changed: 18 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha7/openstackcluster_conversion.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,14 @@ func restorev1beta1ClusterSpec(previous *infrav1.OpenStackClusterSpec, dst *infr
216216
dst.APIServerLoadBalancer.Enabled = previous.APIServerLoadBalancer.Enabled
217217
}
218218
optional.RestoreString(&previous.APIServerLoadBalancer.Provider, &dst.APIServerLoadBalancer.Provider)
219+
220+
if previous.APIServerLoadBalancer.Network != nil {
221+
dst.APIServerLoadBalancer.Network = previous.APIServerLoadBalancer.Network
222+
}
223+
224+
if previous.APIServerLoadBalancer.Subnets != nil {
225+
dst.APIServerLoadBalancer.Subnets = previous.APIServerLoadBalancer.Subnets
226+
}
219227
}
220228
if dst.APIServerLoadBalancer.IsZero() {
221229
dst.APIServerLoadBalancer = previous.APIServerLoadBalancer
@@ -300,6 +308,18 @@ func Convert_v1alpha7_OpenStackClusterSpec_To_v1beta1_OpenStackClusterSpec(in *O
300308
return nil
301309
}
302310

311+
func Convert_v1beta1_LoadBalancer_To_v1alpha7_LoadBalancer(in *infrav1.LoadBalancer, out *LoadBalancer, s apiconversion.Scope) error {
312+
return autoConvert_v1beta1_LoadBalancer_To_v1alpha7_LoadBalancer(in, out, s)
313+
}
314+
315+
func Convert_v1beta1_APIServerLoadBalancer_To_v1alpha7_APIServerLoadBalancer(in *infrav1.APIServerLoadBalancer, out *APIServerLoadBalancer, s apiconversion.Scope) error {
316+
return autoConvert_v1beta1_APIServerLoadBalancer_To_v1alpha7_APIServerLoadBalancer(in, out, s)
317+
}
318+
319+
func Convert_v1alpha7_APIServerLoadBalancer_To_v1beta1_APIServerLoadBalancer(in *APIServerLoadBalancer, out *infrav1.APIServerLoadBalancer, s apiconversion.Scope) error {
320+
return autoConvert_v1alpha7_APIServerLoadBalancer_To_v1beta1_APIServerLoadBalancer(in, out, s)
321+
}
322+
303323
func Convert_v1beta1_OpenStackClusterSpec_To_v1alpha7_OpenStackClusterSpec(in *infrav1.OpenStackClusterSpec, out *OpenStackClusterSpec, s apiconversion.Scope) error {
304324
err := autoConvert_v1beta1_OpenStackClusterSpec_To_v1alpha7_OpenStackClusterSpec(in, out, s)
305325
if err != nil {
@@ -362,6 +382,10 @@ func restorev1beta1ClusterStatus(previous *infrav1.OpenStackClusterStatus, dst *
362382
}
363383

364384
restorev1beta1BastionStatus(previous.Bastion, dst.Bastion)
385+
386+
if previous.APIServerLoadBalancer != nil {
387+
dst.APIServerLoadBalancer = previous.APIServerLoadBalancer
388+
}
365389
}
366390

367391
func Convert_v1beta1_OpenStackClusterStatus_To_v1alpha7_OpenStackClusterStatus(in *infrav1.OpenStackClusterStatus, out *OpenStackClusterStatus, s apiconversion.Scope) error {

0 commit comments

Comments
 (0)