Skip to content

Commit c186c62

Browse files
authored
Merge pull request #3539 from k8s-infra-cherrypick-robot/cherry-pick-3517-to-release-1.8
[release-1.8] use default backend pool name in capz controller if empty
2 parents 64c74e2 + a5d9f33 commit c186c62

File tree

2 files changed

+33
-10
lines changed

2 files changed

+33
-10
lines changed

api/v1beta1/azurecluster_default.go

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,7 @@ func (c *AzureCluster) setAPIServerLBDefaults() {
193193
}
194194
}
195195
}
196-
197-
if lb.BackendPool.Name == "" {
198-
lb.BackendPool.Name = generateBackendAddressPoolName(lb.Name)
199-
}
196+
c.SetAPIServerLBBackendPoolNameDefault()
200197
}
201198

202199
// SetNodeOutboundLBDefaults sets the default values for the NodeOutboundLB.
@@ -236,10 +233,7 @@ func (c *AzureCluster) SetNodeOutboundLBDefaults() {
236233
}
237234

238235
c.setOutboundLBFrontendIPs(lb, generateNodeOutboundIPName)
239-
240-
if lb.BackendPool.Name == "" {
241-
lb.BackendPool.Name = generateOutboundBackendAddressPoolName(lb.Name)
242-
}
236+
c.SetNodeOutboundLBBackendPoolNameDefault()
243237
}
244238

245239
// SetControlPlaneOutboundLBDefaults sets the default values for the control plane's outbound LB.
@@ -258,9 +252,37 @@ func (c *AzureCluster) SetControlPlaneOutboundLBDefaults() {
258252
lb.FrontendIPsCount = pointer.Int32(1)
259253
}
260254
c.setOutboundLBFrontendIPs(lb, generateControlPlaneOutboundIPName)
255+
c.SetControlPlaneOutboundLBBackendPoolNameDefault()
256+
}
257+
258+
// SetBackendPoolNameDefault defaults the backend pool name of the LBs.
259+
func (c *AzureCluster) SetBackendPoolNameDefault() {
260+
c.SetAPIServerLBBackendPoolNameDefault()
261+
c.SetNodeOutboundLBBackendPoolNameDefault()
262+
c.SetControlPlaneOutboundLBBackendPoolNameDefault()
263+
}
264+
265+
// SetAPIServerLBBackendPoolNameDefault defaults the name of the backend pool for apiserver LB.
266+
func (c *AzureCluster) SetAPIServerLBBackendPoolNameDefault() {
267+
apiServerLB := &c.Spec.NetworkSpec.APIServerLB
268+
if apiServerLB.BackendPool.Name == "" {
269+
apiServerLB.BackendPool.Name = generateBackendAddressPoolName(apiServerLB.Name)
270+
}
271+
}
272+
273+
// SetNodeOutboundLBBackendPoolNameDefault defaults the name of the backend pool for node outbound LB.
274+
func (c *AzureCluster) SetNodeOutboundLBBackendPoolNameDefault() {
275+
nodeOutboundLB := c.Spec.NetworkSpec.NodeOutboundLB
276+
if nodeOutboundLB != nil && nodeOutboundLB.BackendPool.Name == "" {
277+
nodeOutboundLB.BackendPool.Name = generateOutboundBackendAddressPoolName(nodeOutboundLB.Name)
278+
}
279+
}
261280

262-
if lb.BackendPool.Name == "" {
263-
lb.BackendPool.Name = generateOutboundBackendAddressPoolName(generateControlPlaneOutboundLBName(c.ObjectMeta.Name))
281+
// SetControlPlaneOutboundLBBackendPoolNameDefault defaults the name of the backend pool for control plane outbound LB.
282+
func (c *AzureCluster) SetControlPlaneOutboundLBBackendPoolNameDefault() {
283+
controlPlaneOutboundLB := c.Spec.NetworkSpec.ControlPlaneOutboundLB
284+
if controlPlaneOutboundLB != nil && controlPlaneOutboundLB.BackendPool.Name == "" {
285+
controlPlaneOutboundLB.BackendPool.Name = generateOutboundBackendAddressPoolName(generateControlPlaneOutboundLBName(c.ObjectMeta.Name))
264286
}
265287
}
266288

controllers/azurecluster_reconciler.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ func (s *azureClusterService) Reconcile(ctx context.Context) error {
8585
return errors.Wrap(err, "failed to get availability zones")
8686
}
8787

88+
s.scope.AzureCluster.SetBackendPoolNameDefault()
8889
s.scope.SetDNSName()
8990
s.scope.SetControlPlaneSecurityRules()
9091

0 commit comments

Comments
 (0)