Skip to content

Commit 7e34a22

Browse files
authored
Merge pull request kubernetes-sigs#2004 from shiftstack/apiserver-lb-azs
Add opt to use AZ for APISeverLoadBalancer
2 parents 7925a4b + 6d74e98 commit 7e34a22

15 files changed

+77
-10
lines changed

api/v1alpha5/zz_generated.conversion.go

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

api/v1alpha6/conversion_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,4 +793,5 @@ func Test_FuzzRestorers(t *testing.T) {
793793
testhelpers.FuzzRestorer(t, "restorev1beta1SubnetParam", restorev1beta1SubnetParam)
794794
testhelpers.FuzzRestorer(t, "restorev1alpha6Port", restorev1alpha6Port)
795795
testhelpers.FuzzRestorer(t, "restorev1alpha6SecurityGroup", restorev1alpha6SecurityGroup)
796+
testhelpers.FuzzRestorer(t, "restorev1beta1APIServerLoadBalancer", restorev1beta1APIServerLoadBalancer)
796797
}

api/v1alpha6/openstackcluster_conversion.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ func restorev1beta1ClusterSpec(previous *infrav1.OpenStackClusterSpec, dst *infr
232232
optional.RestoreBool(&previous.DisableAPIServerFloatingIP, &dst.DisableAPIServerFloatingIP)
233233
optional.RestoreBool(&previous.ControlPlaneOmitAvailabilityZone, &dst.ControlPlaneOmitAvailabilityZone)
234234
optional.RestoreBool(&previous.DisablePortSecurity, &dst.DisablePortSecurity)
235+
236+
restorev1beta1APIServerLoadBalancer(previous.APIServerLoadBalancer, dst.APIServerLoadBalancer)
235237
}
236238

237239
func Convert_v1alpha6_OpenStackClusterSpec_To_v1beta1_OpenStackClusterSpec(in *OpenStackClusterSpec, out *infrav1.OpenStackClusterSpec, s apiconversion.Scope) error {

api/v1alpha6/types_conversion.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,6 @@ func Convert_v1alpha6_SecurityGroup_To_v1beta1_SecurityGroupStatus(in *SecurityG
497497
}
498498

499499
/* SecurityGroupRule */
500-
/* APIServerLoadBalancer */
501500
/* ValueSpec */
502501
/* OpenStackIdentityReference */
503502

@@ -510,6 +509,17 @@ func Convert_v1beta1_OpenStackIdentityReference_To_v1alpha6_OpenStackIdentityRef
510509
return nil
511510
}
512511

512+
/* APIServerLoadBalancer */
513+
514+
func restorev1beta1APIServerLoadBalancer(previous *infrav1.APIServerLoadBalancer, dst *infrav1.APIServerLoadBalancer) {
515+
if dst == nil || previous == nil {
516+
return
517+
}
518+
519+
// AZ doesn't exist in v1alpha6, so always restore.
520+
dst.AvailabilityZone = previous.AvailabilityZone
521+
}
522+
513523
/* Placeholders */
514524

515525
// conversion-gen registers these functions so we must provider stubs, but

api/v1alpha6/zz_generated.conversion.go

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

api/v1alpha7/conversion_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,4 +405,5 @@ func Test_FuzzRestorers(t *testing.T) {
405405
testhelpers.FuzzRestorer(t, "restorev1beta1RouterParam", restorev1beta1RouterParam)
406406
testhelpers.FuzzRestorer(t, "restorev1alpha7Port", restorev1alpha7Port)
407407
testhelpers.FuzzRestorer(t, "restorev1beta1Port", restorev1beta1Port)
408+
testhelpers.FuzzRestorer(t, "restorev1beta1APIServerLoadBalancer", restorev1beta1APIServerLoadBalancer)
408409
}

api/v1alpha7/openstackcluster_conversion.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ func restorev1beta1ClusterSpec(previous *infrav1.OpenStackClusterSpec, dst *infr
239239
optional.RestoreBool(&previous.DisableAPIServerFloatingIP, &dst.DisableAPIServerFloatingIP)
240240
optional.RestoreBool(&previous.ControlPlaneOmitAvailabilityZone, &dst.ControlPlaneOmitAvailabilityZone)
241241
optional.RestoreBool(&previous.DisablePortSecurity, &dst.DisablePortSecurity)
242+
243+
restorev1beta1APIServerLoadBalancer(previous.APIServerLoadBalancer, dst.APIServerLoadBalancer)
242244
}
243245

244246
func Convert_v1alpha7_OpenStackClusterSpec_To_v1beta1_OpenStackClusterSpec(in *OpenStackClusterSpec, out *infrav1.OpenStackClusterSpec, s apiconversion.Scope) error {

api/v1alpha7/types_conversion.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,17 @@ func Convert_v1beta1_OpenStackIdentityReference_To_v1alpha7_OpenStackIdentityRef
510510
return nil
511511
}
512512

513+
/* APIServerLoadBalancer */
514+
515+
func restorev1beta1APIServerLoadBalancer(previous *infrav1.APIServerLoadBalancer, dst *infrav1.APIServerLoadBalancer) {
516+
if dst == nil || previous == nil {
517+
return
518+
}
519+
520+
// AZ doesn't exist in v1alpha6, so always restore.
521+
dst.AvailabilityZone = previous.AvailabilityZone
522+
}
523+
513524
/* Placeholders */
514525

515526
// conversion-gen registers these functions so we must provider stubs, but

api/v1alpha7/zz_generated.conversion.go

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

api/v1beta1/types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,13 +812,18 @@ type APIServerLoadBalancer struct {
812812
// Network defines which network should the load balancer be allocated on.
813813
//+optional
814814
Network *NetworkParam `json:"network,omitempty"`
815+
815816
// Subnets define which subnets should the load balancer be allocated on.
816817
// It is expected that subnets are located on the network specified in this resource.
817818
// Only the first element is taken into account.
818819
// +optional
819820
// +listType=atomic
820821
// kubebuilder:validation:MaxLength:=2
821822
Subnets []SubnetParam `json:"subnets,omitempty"`
823+
824+
// AvailabilityZone is the failure domain that will be used to create the APIServerLoadBalancer Spec.
825+
//+optional
826+
AvailabilityZone optional.String `json:"availabilityZone,omitempty"`
822827
}
823828

824829
func (s *APIServerLoadBalancer) IsZero() bool {

0 commit comments

Comments
 (0)