Skip to content

Commit

Permalink
use default backend pool name in capz controller if empty
Browse files Browse the repository at this point in the history
Ref issue kubernetes-sigs#3252

Signed-off-by: Ashutosh Kumar <[email protected]>
  • Loading branch information
sonasingh46 committed May 4, 2023
1 parent fecb3a5 commit fd84079
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
34 changes: 34 additions & 0 deletions azure/scope/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
1 change: 1 addition & 0 deletions controllers/azurecluster_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit fd84079

Please sign in to comment.