@@ -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
0 commit comments