@@ -42,37 +42,42 @@ func (src *AzureCluster) ConvertTo(dstRaw conversion.Hub) error {
4242 dst .Annotations = nil
4343 }
4444 }
45+
46+ // set default control plane outbound lb for private v1alpha3 clusters.
47+ if src .Spec .NetworkSpec .APIServerLB .Type == Internal {
48+ dst .Spec .NetworkSpec .ControlPlaneOutboundLB = & infrav1beta1.LoadBalancerSpec {
49+ FrontendIPsCount : pointer .Int32Ptr (1 ),
50+ }
51+ // We also need to set the defaults here because "get" won't set defaults, and hence there is no mismatch when a client
52+ // gets a v1alpha3 cluster.
53+ dst .SetControlPlaneOutboundLBDefaults ()
54+ }
55+
56+ // set default node plane outbound lb for all v1alpha3 clusters.
57+ dst .Spec .NetworkSpec .NodeOutboundLB = & infrav1beta1.LoadBalancerSpec {
58+ FrontendIPsCount : pointer .Int32Ptr (1 ),
59+ }
60+ // We also need to set the defaults here because "get" won't set defaults, and hence there is no mismatch when a client
61+ // gets a v1alpha3 cluster.
62+ dst .SetNodeOutboundLBDefaults ()
63+
4564 // Manually restore data.
4665 restored := & infrav1beta1.AzureCluster {}
4766 if ok , err := utilconversion .UnmarshalData (src , restored ); err != nil || ! ok {
4867 return err
4968 }
5069
70+ // override outbound lb if it's present in restored.
71+ dst .Spec .NetworkSpec .ControlPlaneOutboundLB = restored .Spec .NetworkSpec .ControlPlaneOutboundLB
72+ dst .Spec .NetworkSpec .NodeOutboundLB = restored .Spec .NetworkSpec .NodeOutboundLB
73+
5174 dst .Spec .NetworkSpec .PrivateDNSZoneName = restored .Spec .NetworkSpec .PrivateDNSZoneName
5275
5376 dst .Spec .NetworkSpec .APIServerLB .FrontendIPsCount = restored .Spec .NetworkSpec .APIServerLB .FrontendIPsCount
5477 dst .Spec .NetworkSpec .APIServerLB .IdleTimeoutInMinutes = restored .Spec .NetworkSpec .APIServerLB .IdleTimeoutInMinutes
5578 dst .Spec .CloudProviderConfigOverrides = restored .Spec .CloudProviderConfigOverrides
5679 dst .Spec .BastionSpec = restored .Spec .BastionSpec
5780
58- // set default control plane outbound lb for private v1alpha3 clusters
59- if src .Spec .NetworkSpec .APIServerLB .Type == Internal && restored .Spec .NetworkSpec .ControlPlaneOutboundLB == nil {
60- dst .Spec .NetworkSpec .ControlPlaneOutboundLB = & infrav1beta1.LoadBalancerSpec {
61- FrontendIPsCount : pointer .Int32Ptr (1 ),
62- }
63- } else {
64- dst .Spec .NetworkSpec .ControlPlaneOutboundLB = restored .Spec .NetworkSpec .ControlPlaneOutboundLB
65- }
66-
67- // set default node plane outbound lb for all v1alpha3 clusters
68- if restored .Spec .NetworkSpec .NodeOutboundLB == nil {
69- dst .Spec .NetworkSpec .NodeOutboundLB = & infrav1beta1.LoadBalancerSpec {
70- FrontendIPsCount : pointer .Int32Ptr (1 ),
71- }
72- } else {
73- dst .Spec .NetworkSpec .NodeOutboundLB = restored .Spec .NetworkSpec .NodeOutboundLB
74- }
75-
7681 // Here we manually restore outbound security rules. Since v1alpha3 only supports ingress ("Inbound") rules, all v1alpha4/v1beta1 outbound rules are dropped when an AzureCluster
7782 // is converted to v1alpha3. We loop through all security group rules. For all previously existing outbound rules we restore the full rule.
7883 for _ , restoredSubnet := range restored .Spec .NetworkSpec .Subnets {
0 commit comments