Skip to content

Commit

Permalink
cleanup OutboundPoolName/APIServerLBName
Browse files Browse the repository at this point in the history
  • Loading branch information
Cecile Robert-Michon committed Oct 30, 2020
1 parent 513ac97 commit dd5318e
Show file tree
Hide file tree
Showing 11 changed files with 229 additions and 11 deletions.
2 changes: 1 addition & 1 deletion api/v1alpha3/azurecluster_default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ func TestAPIServerLBDefaults(t *testing.T) {
SKU: SKUStandard,
FrontendIPs: []FrontendIP{
{
Name: "cluster-test-internal-lb-frontEnd",
Name: "cluster-test-internal-lb-frontEnd",
PrivateIPAddress: DefaultInternalLBIPAddress,
},
},
Expand Down
2 changes: 2 additions & 0 deletions cloud/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ type NetworkDescriber interface {
NodeRouteTable() *infrav1.RouteTable
ControlPlaneRouteTable() *infrav1.RouteTable
APIServerLBName() string
APIServerLBPoolName(string) string
IsAPIServerPrivate() bool
OutboundLBName(string) string
OutboundPoolName(string) string
}

// ClusterDescriber is an interface which can get common Azure Cluster information.
Expand Down
56 changes: 56 additions & 0 deletions cloud/mocks/service_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 15 additions & 5 deletions cloud/scope/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (s *ClusterScope) LBSpecs() []azure.LBSpec {
Type: s.APIServerLB().Type,
SKU: infrav1.SKUStandard,
Role: infrav1.APIServerRole,
BackendPoolName: azure.GenerateBackendAddressPoolName(s.APIServerLB().Name),
BackendPoolName: s.APIServerLBPoolName(s.APIServerLB().Name),
},
{
// Public Node outbound LB
Expand All @@ -152,7 +152,7 @@ func (s *ClusterScope) LBSpecs() []azure.LBSpec {
},
Type: infrav1.Public,
SKU: infrav1.SKUStandard,
BackendPoolName: azure.GenerateOutboundBackendAddressPoolName(s.NodeOutboundLBName()),
BackendPoolName: s.OutboundPoolName(s.NodeOutboundLBName()),
Role: infrav1.NodeOutboundRole,
},
}
Expand All @@ -172,9 +172,9 @@ func (s *ClusterScope) LBSpecs() []azure.LBSpec {
},
},
},
Type: infrav1.Public,
SKU: infrav1.SKUStandard,
BackendPoolName: azure.GenerateOutboundBackendAddressPoolName(azure.GenerateControlPlaneOutboundLBName(s.ClusterName())),
Type: infrav1.Public,
SKU: infrav1.SKUStandard,
BackendPoolName: s.OutboundPoolName(azure.GenerateControlPlaneOutboundLBName(s.ClusterName())),
Role: infrav1.ControlPlaneOutboundRole,
})

Expand Down Expand Up @@ -310,6 +310,11 @@ func (s *ClusterScope) APIServerPrivateIP() string {
return s.APIServerLB().FrontendIPs[0].PrivateIPAddress
}

// APIServerLBPoolName returns the API Server LB backend pool name.
func (s *ClusterScope) APIServerLBPoolName(loadBalancerName string) string {
return azure.GenerateBackendAddressPoolName(loadBalancerName)
}

// NodeOutboundLBName returns the name of the node outbound LB.
func (s *ClusterScope) NodeOutboundLBName() string {
return s.ClusterName()
Expand All @@ -326,6 +331,11 @@ func (s *ClusterScope) OutboundLBName(role string) string {
return s.APIServerLBName()
}

// OutboundPoolName returns the outbound LB backend pool name.
func (s *ClusterScope) OutboundPoolName(loadBalancerName string) string {
return azure.GenerateOutboundBackendAddressPoolName(loadBalancerName)
}

// ResourceGroup returns the cluster resource group.
func (s *ClusterScope) ResourceGroup() string {
return s.AzureCluster.Spec.ResourceGroup
Expand Down
6 changes: 3 additions & 3 deletions cloud/scope/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,15 @@ func (m *MachineScope) NICSpecs() []azure.NICSpec {
IPv6Enabled: m.IsIPv6Enabled(),
EnableIPForwarding: m.AzureMachine.Spec.EnableIPForwarding,
PublicLBName: m.OutboundLBName(m.Role()),
PublicLBAddressPoolName: azure.GenerateOutboundBackendAddressPoolName(m.OutboundLBName(m.Role())),
PublicLBAddressPoolName: m.OutboundPoolName(m.OutboundLBName(m.Role())),
}
if m.Role() == infrav1.ControlPlane {
if m.IsAPIServerPrivate() {
spec.InternalLBName = m.APIServerLBName()
spec.InternalLBAddressPoolName = azure.GenerateBackendAddressPoolName(m.APIServerLBName())
spec.InternalLBAddressPoolName = m.APIServerLBPoolName(m.APIServerLBName())
} else {
spec.PublicLBNATRuleName = m.Name()
spec.PublicLBAddressPoolName = azure.GenerateBackendAddressPoolName(m.APIServerLBName())
spec.PublicLBAddressPoolName = m.APIServerLBPoolName(m.APIServerLBName())
}
}
specs := []azure.NICSpec{spec}
Expand Down
14 changes: 12 additions & 2 deletions cloud/scope/managedcontrolplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,12 @@ func (s *ManagedControlPlaneScope) IsVnetManaged() bool {

// APIServerLBName returns the API Server LB name.
func (s *ManagedControlPlaneScope) APIServerLBName() string {
return ""
return "" // does not apply for AKS
}

// APIServerLBPoolName returns the API Server LB backend pool name.
func (s *ManagedControlPlaneScope) APIServerLBPoolName(loadBalancerName string) string {
return "" // does not apply for AKS
}

// IsAPIServerPrivate returns true if the API Server LB is of type Internal.
Expand All @@ -226,6 +231,11 @@ func (s *ManagedControlPlaneScope) IsAPIServerPrivate() bool {

// OutboundLBName returns the name of the outbound LB.
// Note: for managed clusters, the outbound LB lifecycle is not managed.
func (s *ManagedControlPlaneScope) OutboundLBName(string) string {
func (s *ManagedControlPlaneScope) OutboundLBName(_ string) string {
return "kubernetes"
}

// OutboundPoolName returns the outbound LB backend pool name.
func (s *ManagedControlPlaneScope) OutboundPoolName(_ string) string {
return "aksOutboundBackendPool" // hard-coded in aks
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions cloud/services/routetables/mock_routetables/routetables_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit dd5318e

Please sign in to comment.