diff --git a/azure/scope/cluster.go b/azure/scope/cluster.go index a19053dc388..63e3976353a 100644 --- a/azure/scope/cluster.go +++ b/azure/scope/cluster.go @@ -235,21 +235,29 @@ func (s *ClusterScope) LBSpecs() []azure.ResourceSpecGetter { specs := []azure.ResourceSpecGetter{ &loadbalancers.LBSpec{ // API Server LB - Name: s.APIServerLB().Name, - ResourceGroup: s.ResourceGroup(), - SubscriptionID: s.SubscriptionID(), - ClusterName: s.ClusterName(), - Location: s.Location(), - ExtendedLocation: s.ExtendedLocation(), - VNetName: s.Vnet().Name, - VNetResourceGroup: s.Vnet().ResourceGroup, - SubnetName: s.ControlPlaneSubnet().Name, - FrontendIPConfigs: s.APIServerLB().FrontendIPs, - APIServerPort: s.APIServerPort(), - Type: s.APIServerLB().Type, - SKU: s.APIServerLB().SKU, - Role: infrav1.APIServerRole, - BackendPoolName: s.APIServerLB().BackendPool.Name, + Name: s.APIServerLB().Name, + ResourceGroup: s.ResourceGroup(), + SubscriptionID: s.SubscriptionID(), + ClusterName: s.ClusterName(), + Location: s.Location(), + ExtendedLocation: s.ExtendedLocation(), + VNetName: s.Vnet().Name, + VNetResourceGroup: s.Vnet().ResourceGroup, + SubnetName: s.ControlPlaneSubnet().Name, + FrontendIPConfigs: s.APIServerLB().FrontendIPs, + APIServerPort: s.APIServerPort(), + Type: s.APIServerLB().Type, + SKU: s.APIServerLB().SKU, + Role: infrav1.APIServerRole, + // @sonasingh46: Ref issue #3253 + // Change the code to be using only s.ControlPlaneOutboundLB().BackendPool.Name in the upcoming + // release when folks have upgraded. + BackendPoolName: func() string { + if s.APIServerLB().BackendPool.Name == "" { + return s.APIServerLBPoolName(s.APIServerLB().Name) + } + return s.APIServerLB().BackendPool.Name + }(), IdleTimeoutInMinutes: s.APIServerLB().IdleTimeoutInMinutes, AdditionalTags: s.AdditionalTags(), }, @@ -258,18 +266,26 @@ func (s *ClusterScope) LBSpecs() []azure.ResourceSpecGetter { // Node outbound LB if s.NodeOutboundLB() != nil { specs = append(specs, &loadbalancers.LBSpec{ - Name: s.NodeOutboundLB().Name, - ResourceGroup: s.ResourceGroup(), - SubscriptionID: s.SubscriptionID(), - ClusterName: s.ClusterName(), - Location: s.Location(), - ExtendedLocation: s.ExtendedLocation(), - VNetName: s.Vnet().Name, - VNetResourceGroup: s.Vnet().ResourceGroup, - FrontendIPConfigs: s.NodeOutboundLB().FrontendIPs, - Type: s.NodeOutboundLB().Type, - SKU: s.NodeOutboundLB().SKU, - BackendPoolName: s.NodeOutboundLB().BackendPool.Name, + Name: s.NodeOutboundLB().Name, + ResourceGroup: s.ResourceGroup(), + SubscriptionID: s.SubscriptionID(), + ClusterName: s.ClusterName(), + Location: s.Location(), + ExtendedLocation: s.ExtendedLocation(), + VNetName: s.Vnet().Name, + VNetResourceGroup: s.Vnet().ResourceGroup, + FrontendIPConfigs: s.NodeOutboundLB().FrontendIPs, + Type: s.NodeOutboundLB().Type, + SKU: s.NodeOutboundLB().SKU, + // @sonasingh46: Ref issue #3253 + // Change the code to be using only s.ControlPlaneOutboundLB().BackendPool.Name in the upcoming + // release when folks have upgraded. + BackendPoolName: func() string { + if s.NodeOutboundLB().BackendPool.Name == "" { + s.OutboundPoolName(s.NodeOutboundLB().Name) + } + return s.NodeOutboundLB().BackendPool.Name + }(), IdleTimeoutInMinutes: s.NodeOutboundLB().IdleTimeoutInMinutes, Role: infrav1.NodeOutboundRole, AdditionalTags: s.AdditionalTags(), @@ -279,18 +295,26 @@ func (s *ClusterScope) LBSpecs() []azure.ResourceSpecGetter { // Control Plane Outbound LB if s.ControlPlaneOutboundLB() != nil { specs = append(specs, &loadbalancers.LBSpec{ - Name: s.ControlPlaneOutboundLB().Name, - ResourceGroup: s.ResourceGroup(), - SubscriptionID: s.SubscriptionID(), - ClusterName: s.ClusterName(), - Location: s.Location(), - ExtendedLocation: s.ExtendedLocation(), - VNetName: s.Vnet().Name, - VNetResourceGroup: s.Vnet().ResourceGroup, - FrontendIPConfigs: s.ControlPlaneOutboundLB().FrontendIPs, - Type: s.ControlPlaneOutboundLB().Type, - SKU: s.ControlPlaneOutboundLB().SKU, - BackendPoolName: s.ControlPlaneOutboundLB().BackendPool.Name, + Name: s.ControlPlaneOutboundLB().Name, + ResourceGroup: s.ResourceGroup(), + SubscriptionID: s.SubscriptionID(), + ClusterName: s.ClusterName(), + Location: s.Location(), + ExtendedLocation: s.ExtendedLocation(), + VNetName: s.Vnet().Name, + VNetResourceGroup: s.Vnet().ResourceGroup, + FrontendIPConfigs: s.ControlPlaneOutboundLB().FrontendIPs, + Type: s.ControlPlaneOutboundLB().Type, + SKU: s.ControlPlaneOutboundLB().SKU, + // @sonasingh46: Ref issue #3253 + // Change the code to be using only s.ControlPlaneOutboundLB().BackendPool.Name in the upcoming + // release when folks have upgraded. + BackendPoolName: func() string { + if s.ControlPlaneOutboundLB().BackendPool.Name == "" { + s.OutboundPoolName(azure.GenerateControlPlaneOutboundLBName(s.ClusterName())) + } + return s.ControlPlaneOutboundLB().BackendPool.Name + }(), IdleTimeoutInMinutes: s.ControlPlaneOutboundLB().IdleTimeoutInMinutes, Role: infrav1.ControlPlaneOutboundRole, AdditionalTags: s.AdditionalTags(),