diff --git a/api/v1alpha5/zz_generated.conversion.go b/api/v1alpha5/zz_generated.conversion.go index 999c555fb4..95f181a279 100644 --- a/api/v1alpha5/zz_generated.conversion.go +++ b/api/v1alpha5/zz_generated.conversion.go @@ -458,6 +458,7 @@ func autoConvert_v1beta1_APIServerLoadBalancer_To_v1alpha5_APIServerLoadBalancer // WARNING: in.Provider requires manual conversion: does not exist in peer-type // WARNING: in.Network requires manual conversion: does not exist in peer-type // WARNING: in.Subnets requires manual conversion: does not exist in peer-type + // WARNING: in.AvailabilityZone requires manual conversion: does not exist in peer-type return nil } diff --git a/api/v1alpha6/conversion_test.go b/api/v1alpha6/conversion_test.go index 67a394d801..c451091929 100644 --- a/api/v1alpha6/conversion_test.go +++ b/api/v1alpha6/conversion_test.go @@ -793,4 +793,5 @@ func Test_FuzzRestorers(t *testing.T) { testhelpers.FuzzRestorer(t, "restorev1beta1SubnetParam", restorev1beta1SubnetParam) testhelpers.FuzzRestorer(t, "restorev1alpha6Port", restorev1alpha6Port) testhelpers.FuzzRestorer(t, "restorev1alpha6SecurityGroup", restorev1alpha6SecurityGroup) + testhelpers.FuzzRestorer(t, "restorev1beta1APIServerLoadBalancer", restorev1beta1APIServerLoadBalancer) } diff --git a/api/v1alpha6/openstackcluster_conversion.go b/api/v1alpha6/openstackcluster_conversion.go index 16375c2c07..626ffd198c 100644 --- a/api/v1alpha6/openstackcluster_conversion.go +++ b/api/v1alpha6/openstackcluster_conversion.go @@ -232,6 +232,8 @@ func restorev1beta1ClusterSpec(previous *infrav1.OpenStackClusterSpec, dst *infr optional.RestoreBool(&previous.DisableAPIServerFloatingIP, &dst.DisableAPIServerFloatingIP) optional.RestoreBool(&previous.ControlPlaneOmitAvailabilityZone, &dst.ControlPlaneOmitAvailabilityZone) optional.RestoreBool(&previous.DisablePortSecurity, &dst.DisablePortSecurity) + + restorev1beta1APIServerLoadBalancer(previous.APIServerLoadBalancer, dst.APIServerLoadBalancer) } func Convert_v1alpha6_OpenStackClusterSpec_To_v1beta1_OpenStackClusterSpec(in *OpenStackClusterSpec, out *infrav1.OpenStackClusterSpec, s apiconversion.Scope) error { diff --git a/api/v1alpha6/types_conversion.go b/api/v1alpha6/types_conversion.go index b855b9e473..e9f1ea72a9 100644 --- a/api/v1alpha6/types_conversion.go +++ b/api/v1alpha6/types_conversion.go @@ -497,7 +497,6 @@ func Convert_v1alpha6_SecurityGroup_To_v1beta1_SecurityGroupStatus(in *SecurityG } /* SecurityGroupRule */ -/* APIServerLoadBalancer */ /* ValueSpec */ /* OpenStackIdentityReference */ @@ -510,6 +509,17 @@ func Convert_v1beta1_OpenStackIdentityReference_To_v1alpha6_OpenStackIdentityRef return nil } +/* APIServerLoadBalancer */ + +func restorev1beta1APIServerLoadBalancer(previous *infrav1.APIServerLoadBalancer, dst *infrav1.APIServerLoadBalancer) { + if dst == nil || previous == nil { + return + } + + // AZ doesn't exist in v1alpha6, so always restore. + dst.AvailabilityZone = previous.AvailabilityZone +} + /* Placeholders */ // conversion-gen registers these functions so we must provider stubs, but diff --git a/api/v1alpha6/zz_generated.conversion.go b/api/v1alpha6/zz_generated.conversion.go index 93dfea061a..541bef18aa 100644 --- a/api/v1alpha6/zz_generated.conversion.go +++ b/api/v1alpha6/zz_generated.conversion.go @@ -472,6 +472,7 @@ func autoConvert_v1beta1_APIServerLoadBalancer_To_v1alpha6_APIServerLoadBalancer } // WARNING: in.Network requires manual conversion: does not exist in peer-type // WARNING: in.Subnets requires manual conversion: does not exist in peer-type + // WARNING: in.AvailabilityZone requires manual conversion: does not exist in peer-type return nil } diff --git a/api/v1alpha7/conversion_test.go b/api/v1alpha7/conversion_test.go index d44eabf604..ac3d00cddf 100644 --- a/api/v1alpha7/conversion_test.go +++ b/api/v1alpha7/conversion_test.go @@ -405,4 +405,5 @@ func Test_FuzzRestorers(t *testing.T) { testhelpers.FuzzRestorer(t, "restorev1beta1RouterParam", restorev1beta1RouterParam) testhelpers.FuzzRestorer(t, "restorev1alpha7Port", restorev1alpha7Port) testhelpers.FuzzRestorer(t, "restorev1beta1Port", restorev1beta1Port) + testhelpers.FuzzRestorer(t, "restorev1beta1APIServerLoadBalancer", restorev1beta1APIServerLoadBalancer) } diff --git a/api/v1alpha7/openstackcluster_conversion.go b/api/v1alpha7/openstackcluster_conversion.go index f273d98760..4183ad9a84 100644 --- a/api/v1alpha7/openstackcluster_conversion.go +++ b/api/v1alpha7/openstackcluster_conversion.go @@ -239,6 +239,8 @@ func restorev1beta1ClusterSpec(previous *infrav1.OpenStackClusterSpec, dst *infr optional.RestoreBool(&previous.DisableAPIServerFloatingIP, &dst.DisableAPIServerFloatingIP) optional.RestoreBool(&previous.ControlPlaneOmitAvailabilityZone, &dst.ControlPlaneOmitAvailabilityZone) optional.RestoreBool(&previous.DisablePortSecurity, &dst.DisablePortSecurity) + + restorev1beta1APIServerLoadBalancer(previous.APIServerLoadBalancer, dst.APIServerLoadBalancer) } func Convert_v1alpha7_OpenStackClusterSpec_To_v1beta1_OpenStackClusterSpec(in *OpenStackClusterSpec, out *infrav1.OpenStackClusterSpec, s apiconversion.Scope) error { diff --git a/api/v1alpha7/types_conversion.go b/api/v1alpha7/types_conversion.go index aeb1c756a6..ac09a5d3dc 100644 --- a/api/v1alpha7/types_conversion.go +++ b/api/v1alpha7/types_conversion.go @@ -510,6 +510,17 @@ func Convert_v1beta1_OpenStackIdentityReference_To_v1alpha7_OpenStackIdentityRef return nil } +/* APIServerLoadBalancer */ + +func restorev1beta1APIServerLoadBalancer(previous *infrav1.APIServerLoadBalancer, dst *infrav1.APIServerLoadBalancer) { + if dst == nil || previous == nil { + return + } + + // AZ doesn't exist in v1alpha6, so always restore. + dst.AvailabilityZone = previous.AvailabilityZone +} + /* Placeholders */ // conversion-gen registers these functions so we must provider stubs, but diff --git a/api/v1alpha7/zz_generated.conversion.go b/api/v1alpha7/zz_generated.conversion.go index 407c862a75..554345da6c 100644 --- a/api/v1alpha7/zz_generated.conversion.go +++ b/api/v1alpha7/zz_generated.conversion.go @@ -507,6 +507,7 @@ func autoConvert_v1beta1_APIServerLoadBalancer_To_v1alpha7_APIServerLoadBalancer } // WARNING: in.Network requires manual conversion: does not exist in peer-type // WARNING: in.Subnets requires manual conversion: does not exist in peer-type + // WARNING: in.AvailabilityZone requires manual conversion: does not exist in peer-type return nil } diff --git a/api/v1beta1/types.go b/api/v1beta1/types.go index b141d2731b..b6789489d1 100644 --- a/api/v1beta1/types.go +++ b/api/v1beta1/types.go @@ -812,6 +812,7 @@ type APIServerLoadBalancer struct { // Network defines which network should the load balancer be allocated on. //+optional Network *NetworkParam `json:"network,omitempty"` + // Subnets define which subnets should the load balancer be allocated on. // It is expected that subnets are located on the network specified in this resource. // Only the first element is taken into account. @@ -819,6 +820,10 @@ type APIServerLoadBalancer struct { // +listType=atomic // kubebuilder:validation:MaxLength:=2 Subnets []SubnetParam `json:"subnets,omitempty"` + + // AvailabilityZone is the failure domain that will be used to create the APIServerLoadBalancer Spec. + //+optional + AvailabilityZone optional.String `json:"availabilityZone,omitempty"` } func (s *APIServerLoadBalancer) IsZero() bool { diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index c1a66427d4..fe06c1285c 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -62,6 +62,11 @@ func (in *APIServerLoadBalancer) DeepCopyInto(out *APIServerLoadBalancer) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.AvailabilityZone != nil { + in, out := &in.AvailabilityZone, &out.AvailabilityZone + *out = new(string) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIServerLoadBalancer. diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclusters.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclusters.yaml index eca9ad728f..10074be068 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclusters.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclusters.yaml @@ -4873,6 +4873,10 @@ spec: type: string type: array x-kubernetes-list-type: set + availabilityZone: + description: AvailabilityZone is the failure domain that will + be used to create the APIServerLoadBalancer Spec. + type: string enabled: default: true description: |- diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclustertemplates.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclustertemplates.yaml index cebc2b2a04..956f46dc3a 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclustertemplates.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclustertemplates.yaml @@ -2306,6 +2306,10 @@ spec: type: string type: array x-kubernetes-list-type: set + availabilityZone: + description: AvailabilityZone is the failure domain that + will be used to create the APIServerLoadBalancer Spec. + type: string enabled: default: true description: |- diff --git a/docs/book/src/api/v1beta1/api.md b/docs/book/src/api/v1beta1/api.md index 087efc5310..19dfeb31e3 100644 --- a/docs/book/src/api/v1beta1/api.md +++ b/docs/book/src/api/v1beta1/api.md @@ -933,6 +933,18 @@ Only the first element is taken into account. kubebuilder:validation:MaxLength:=2
+availabilityZone
AvailabilityZone is the failure domain that will be used to create the APIServerLoadBalancer Spec.
+