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 f3292c4
Showing 1 changed file with 63 additions and 39 deletions.
102 changes: 63 additions & 39 deletions azure/scope/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,21 +235,29 @@ func (s *ClusterScope) LBSpecs() []azure.ResourceSpecGetter {
specs := []azure.ResourceSpecGetter{
&loadbalancers.LBSpec{
// API Server LB
Name: s.APIServerLB().Name,
ResourceGroup: s.ResourceGroup(),
SubscriptionID: s.SubscriptionID(),
ClusterName: s.ClusterName(),
Location: s.Location(),
ExtendedLocation: s.ExtendedLocation(),
VNetName: s.Vnet().Name,
VNetResourceGroup: s.Vnet().ResourceGroup,
SubnetName: s.ControlPlaneSubnet().Name,
FrontendIPConfigs: s.APIServerLB().FrontendIPs,
APIServerPort: s.APIServerPort(),
Type: s.APIServerLB().Type,
SKU: s.APIServerLB().SKU,
Role: infrav1.APIServerRole,
BackendPoolName: s.APIServerLB().BackendPool.Name,
Name: s.APIServerLB().Name,
ResourceGroup: s.ResourceGroup(),
SubscriptionID: s.SubscriptionID(),
ClusterName: s.ClusterName(),
Location: s.Location(),
ExtendedLocation: s.ExtendedLocation(),
VNetName: s.Vnet().Name,
VNetResourceGroup: s.Vnet().ResourceGroup,
SubnetName: s.ControlPlaneSubnet().Name,
FrontendIPConfigs: s.APIServerLB().FrontendIPs,
APIServerPort: s.APIServerPort(),
Type: s.APIServerLB().Type,
SKU: s.APIServerLB().SKU,
Role: infrav1.APIServerRole,
// @sonasingh46: Ref issue #3253
// Change the code to be using only s.ControlPlaneOutboundLB().BackendPool.Name in the upcoming
// release when folks have upgraded.
BackendPoolName: func() string {
if s.APIServerLB().BackendPool.Name == "" {
return s.APIServerLBPoolName(s.APIServerLB().Name)
}
return s.APIServerLB().BackendPool.Name
}(),
IdleTimeoutInMinutes: s.APIServerLB().IdleTimeoutInMinutes,
AdditionalTags: s.AdditionalTags(),
},
Expand All @@ -258,18 +266,26 @@ func (s *ClusterScope) LBSpecs() []azure.ResourceSpecGetter {
// Node outbound LB
if s.NodeOutboundLB() != nil {
specs = append(specs, &loadbalancers.LBSpec{
Name: s.NodeOutboundLB().Name,
ResourceGroup: s.ResourceGroup(),
SubscriptionID: s.SubscriptionID(),
ClusterName: s.ClusterName(),
Location: s.Location(),
ExtendedLocation: s.ExtendedLocation(),
VNetName: s.Vnet().Name,
VNetResourceGroup: s.Vnet().ResourceGroup,
FrontendIPConfigs: s.NodeOutboundLB().FrontendIPs,
Type: s.NodeOutboundLB().Type,
SKU: s.NodeOutboundLB().SKU,
BackendPoolName: s.NodeOutboundLB().BackendPool.Name,
Name: s.NodeOutboundLB().Name,
ResourceGroup: s.ResourceGroup(),
SubscriptionID: s.SubscriptionID(),
ClusterName: s.ClusterName(),
Location: s.Location(),
ExtendedLocation: s.ExtendedLocation(),
VNetName: s.Vnet().Name,
VNetResourceGroup: s.Vnet().ResourceGroup,
FrontendIPConfigs: s.NodeOutboundLB().FrontendIPs,
Type: s.NodeOutboundLB().Type,
SKU: s.NodeOutboundLB().SKU,
// @sonasingh46: Ref issue #3253
// Change the code to be using only s.ControlPlaneOutboundLB().BackendPool.Name in the upcoming
// release when folks have upgraded.
BackendPoolName: func() string {
if s.NodeOutboundLB().BackendPool.Name == "" {
s.OutboundPoolName(s.NodeOutboundLB().Name)
}
return s.NodeOutboundLB().BackendPool.Name
}(),
IdleTimeoutInMinutes: s.NodeOutboundLB().IdleTimeoutInMinutes,
Role: infrav1.NodeOutboundRole,
AdditionalTags: s.AdditionalTags(),
Expand All @@ -279,18 +295,26 @@ func (s *ClusterScope) LBSpecs() []azure.ResourceSpecGetter {
// Control Plane Outbound LB
if s.ControlPlaneOutboundLB() != nil {
specs = append(specs, &loadbalancers.LBSpec{
Name: s.ControlPlaneOutboundLB().Name,
ResourceGroup: s.ResourceGroup(),
SubscriptionID: s.SubscriptionID(),
ClusterName: s.ClusterName(),
Location: s.Location(),
ExtendedLocation: s.ExtendedLocation(),
VNetName: s.Vnet().Name,
VNetResourceGroup: s.Vnet().ResourceGroup,
FrontendIPConfigs: s.ControlPlaneOutboundLB().FrontendIPs,
Type: s.ControlPlaneOutboundLB().Type,
SKU: s.ControlPlaneOutboundLB().SKU,
BackendPoolName: s.ControlPlaneOutboundLB().BackendPool.Name,
Name: s.ControlPlaneOutboundLB().Name,
ResourceGroup: s.ResourceGroup(),
SubscriptionID: s.SubscriptionID(),
ClusterName: s.ClusterName(),
Location: s.Location(),
ExtendedLocation: s.ExtendedLocation(),
VNetName: s.Vnet().Name,
VNetResourceGroup: s.Vnet().ResourceGroup,
FrontendIPConfigs: s.ControlPlaneOutboundLB().FrontendIPs,
Type: s.ControlPlaneOutboundLB().Type,
SKU: s.ControlPlaneOutboundLB().SKU,
// @sonasingh46: Ref issue #3253
// Change the code to be using only s.ControlPlaneOutboundLB().BackendPool.Name in the upcoming
// release when folks have upgraded.
BackendPoolName: func() string {
if s.ControlPlaneOutboundLB().BackendPool.Name == "" {
s.OutboundPoolName(azure.GenerateControlPlaneOutboundLBName(s.ClusterName()))
}
return s.ControlPlaneOutboundLB().BackendPool.Name
}(),
IdleTimeoutInMinutes: s.ControlPlaneOutboundLB().IdleTimeoutInMinutes,
Role: infrav1.ControlPlaneOutboundRole,
AdditionalTags: s.AdditionalTags(),
Expand Down

0 comments on commit f3292c4

Please sign in to comment.