@@ -204,10 +204,7 @@ func (c *AzureCluster) setAPIServerLBDefaults() {
204204 }
205205 }
206206 }
207-
208- if lb .BackendPool .Name == "" {
209- lb .BackendPool .Name = generateBackendAddressPoolName (lb .Name )
210- }
207+ c .SetAPIServerLBBackendPoolNameDefault ()
211208}
212209
213210// SetNodeOutboundLBDefaults sets the default values for the NodeOutboundLB.
@@ -247,10 +244,7 @@ func (c *AzureCluster) SetNodeOutboundLBDefaults() {
247244 }
248245
249246 c .setOutboundLBFrontendIPs (lb , generateNodeOutboundIPName )
250-
251- if lb .BackendPool .Name == "" {
252- lb .BackendPool .Name = generateOutboundBackendAddressPoolName (lb .Name )
253- }
247+ c .SetNodeOutboundLBBackendPoolNameDefault ()
254248}
255249
256250// SetControlPlaneOutboundLBDefaults sets the default values for the control plane's outbound LB.
@@ -269,9 +263,37 @@ func (c *AzureCluster) SetControlPlaneOutboundLBDefaults() {
269263 lb .FrontendIPsCount = pointer .Int32 (1 )
270264 }
271265 c .setOutboundLBFrontendIPs (lb , generateControlPlaneOutboundIPName )
266+ c .SetControlPlaneOutboundLBBackendPoolNameDefault ()
267+ }
268+
269+ // SetBackendPoolNameDefault defaults the backend pool name of the LBs.
270+ func (c * AzureCluster ) SetBackendPoolNameDefault () {
271+ c .SetAPIServerLBBackendPoolNameDefault ()
272+ c .SetNodeOutboundLBBackendPoolNameDefault ()
273+ c .SetControlPlaneOutboundLBBackendPoolNameDefault ()
274+ }
275+
276+ // SetAPIServerLBBackendPoolNameDefault defaults the name of the backend pool for apiserver LB.
277+ func (c * AzureCluster ) SetAPIServerLBBackendPoolNameDefault () {
278+ apiServerLB := & c .Spec .NetworkSpec .APIServerLB
279+ if apiServerLB .BackendPool .Name == "" {
280+ apiServerLB .BackendPool .Name = generateBackendAddressPoolName (apiServerLB .Name )
281+ }
282+ }
283+
284+ // SetNodeOutboundLBBackendPoolNameDefault defaults the name of the backend pool for node outbound LB.
285+ func (c * AzureCluster ) SetNodeOutboundLBBackendPoolNameDefault () {
286+ nodeOutboundLB := c .Spec .NetworkSpec .NodeOutboundLB
287+ if nodeOutboundLB != nil && nodeOutboundLB .BackendPool .Name == "" {
288+ nodeOutboundLB .BackendPool .Name = generateOutboundBackendAddressPoolName (nodeOutboundLB .Name )
289+ }
290+ }
272291
273- if lb .BackendPool .Name == "" {
274- lb .BackendPool .Name = generateOutboundBackendAddressPoolName (generateControlPlaneOutboundLBName (c .ObjectMeta .Name ))
292+ // SetControlPlaneOutboundLBBackendPoolNameDefault defaults the name of the backend pool for control plane outbound LB.
293+ func (c * AzureCluster ) SetControlPlaneOutboundLBBackendPoolNameDefault () {
294+ controlPlaneOutboundLB := c .Spec .NetworkSpec .ControlPlaneOutboundLB
295+ if controlPlaneOutboundLB != nil && controlPlaneOutboundLB .BackendPool .Name == "" {
296+ controlPlaneOutboundLB .BackendPool .Name = generateOutboundBackendAddressPoolName (generateControlPlaneOutboundLBName (c .ObjectMeta .Name ))
275297 }
276298}
277299
0 commit comments