diff --git a/azure/scope/cluster.go b/azure/scope/cluster.go index a19053dc3889..66c25b68b9fa 100644 --- a/azure/scope/cluster.go +++ b/azure/scope/cluster.go @@ -230,6 +230,40 @@ func (s *ClusterScope) PublicIPSpecs() []azure.ResourceSpecGetter { return publicIPSpecs } +// SetAPIServerLBBackendPoolName sets the name of the backend pool for apiserver LB. +func (s *ClusterScope) SetAPIServerLBBackendPoolName() { + // Ref issue #3253 + if s.APIServerLB().BackendPool.Name == "" { + s.APIServerLB().BackendPool.Name = s.APIServerLBPoolName(s.APIServerLB().Name) + } +} + +// SetNodeOutboundLBBackendPoolName sets the name of the backend pool for node outbound LB. +func (s *ClusterScope) SetNodeOutboundLBBackendPoolName() { + // Ref issue #3253 + if s.NodeOutboundLB() != nil && s.NodeOutboundLB().BackendPool.Name == "" { + s.NodeOutboundLB().BackendPool.Name = s.OutboundPoolName(s.NodeOutboundLB().Name) + } +} + +// SetControlPlaneOutboundLBBackendPoolName sets the name of the backend pool for control plane outbound LB. +func (s *ClusterScope) SetControlPlaneOutboundLBBackendPoolName() { + // Ref issue #3253 + if s.ControlPlaneOutboundLB() != nil && s.ControlPlaneOutboundLB().BackendPool.Name == "" { + s.ControlPlaneOutboundLB().BackendPool.Name = s.OutboundPoolName(azure.GenerateControlPlaneOutboundLBName(s.ClusterName())) + } +} + +// SetLBBackendPoolName sets the backend pool name for different LBs. +// Note: This logic exists only for the purpose of backwards compatibility for old clusters for which +// backend pool name was not required and may be removed in the future. +// Please refer to issue #3252 for more details (@sonasingh46). +func (s *ClusterScope) SetLBBackendPoolName() { + s.SetAPIServerLBBackendPoolName() + s.SetNodeOutboundLBBackendPoolName() + s.SetControlPlaneOutboundLBBackendPoolName() +} + // LBSpecs returns the load balancer specs. func (s *ClusterScope) LBSpecs() []azure.ResourceSpecGetter { specs := []azure.ResourceSpecGetter{ diff --git a/controllers/azurecluster_reconciler.go b/controllers/azurecluster_reconciler.go index a4e3787978c4..58800627584f 100644 --- a/controllers/azurecluster_reconciler.go +++ b/controllers/azurecluster_reconciler.go @@ -85,6 +85,7 @@ func (s *azureClusterService) Reconcile(ctx context.Context) error { return errors.Wrap(err, "failed to get availability zones") } + s.scope.SetLBBackendPoolName() s.scope.SetDNSName() s.scope.SetControlPlaneSecurityRules()