Skip to content

Commit

Permalink
Enable configurable API Server Load Balancer
Browse files Browse the repository at this point in the history
validation tests

fix build

tests

Update cluster.go

dns name

wip

Update azurecluster_conversion.go

remove internal role

Update cluster.go

Add NodeOutboundLBName

generate

fix apiserver dns

Update kubectl-capz-ssh

Update loadbalancers.go

fixes

internal lb private IP webhook default

Update publicips.go

improve webhook validation

Update cluster.go

fix deep copy
  • Loading branch information
Cecile Robert-Michon committed Oct 9, 2020
1 parent 6d7647a commit 8c3a794
Show file tree
Hide file tree
Showing 32 changed files with 1,016 additions and 667 deletions.
5 changes: 0 additions & 5 deletions api/v1alpha2/azurecluster_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,6 @@ func Convert_v1alpha3_AzureClusterStatus_To_v1alpha2_AzureClusterStatus(in *infr
return nil
}

// Convert_v1alpha2_Network_To_v1alpha3_Network.
func Convert_v1alpha2_Network_To_v1alpha3_Network(in *Network, out *infrav1alpha3.Network, s apiconversion.Scope) error { //nolint
return autoConvert_v1alpha2_Network_To_v1alpha3_Network(in, out, s)
}

// Convert_v1alpha2_NetworkSpec_To_v1alpha3_NetworkSpec.
func Convert_v1alpha2_NetworkSpec_To_v1alpha3_NetworkSpec(in *NetworkSpec, out *infrav1alpha3.NetworkSpec, s apiconversion.Scope) error { //nolint
if err := Convert_v1alpha2_VnetSpec_To_v1alpha3_VnetSpec(&in.Vnet, &out.Vnet, s); err != nil {
Expand Down
188 changes: 2 additions & 186 deletions api/v1alpha2/zz_generated.conversion.go

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

71 changes: 70 additions & 1 deletion api/v1alpha3/azurecluster_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const (
DefaultControlPlaneSubnetCIDR = "10.0.0.0/16"
// DefaultNodeSubnetCIDR is the default Node Subnet CIDR
DefaultNodeSubnetCIDR = "10.1.0.0/16"
// DefaultInternalLBIPAddress is the default internal load balancer ip address
DefaultInternalLBIPAddress = "10.0.0.100"
)

const (
Expand All @@ -36,16 +38,19 @@ const (
DefaultControlPlaneSubnetIPv6CIDR = "2001:1234:5678:9abc::/64"
// DefaultNodeSubnetIPv6CIDR is the default Node Subnet CIDR
DefaultNodeSubnetIPv6CIDR = "2001:1234:5678:9abd::/64"
// DefaultInternalLBIPv6Address is the default internal load balancer ip address
DefaultInternalLBIPv6Address = "2001:1234:5678:9abc::100"
)

func (c *AzureCluster) setDefaults() {
c.setResourceGroupDefault()
c.setNetworkSpecDefaults()
}

func (c *AzureCluster) setNetworkSpecDefaults() {
c.setResourceGroupDefault()
c.setVnetDefaults()
c.setSubnetDefaults()
c.setAPIServerLBDefaults()
}

func (c *AzureCluster) setResourceGroupDefault() {
Expand Down Expand Up @@ -103,6 +108,50 @@ func (c *AzureCluster) setSubnetDefaults() {
}
}

func (c *AzureCluster) setAPIServerLBDefaults() {
lb := &c.Spec.NetworkSpec.APIServerLB
if lb.Type == "" {
lb.Type = Public
}
if lb.SKU == "" {
lb.SKU = SKUStandard
}

if lb.Type == Public {
if lb.Name == "" {
lb.Name = generatePublicLBName(c.ObjectMeta.Name)
}
if len(lb.FrontendIPs) == 0 {
lb.FrontendIPs = []FrontendIP{
{
Name: generateFrontendIPConfigName(lb.Name),
PublicIP: &PublicIPSpec{
Name: generatePublicIPName(c.ObjectMeta.Name),
},
},
}
}

} else if lb.Type == Internal {
if lb.Name == "" {
lb.Name = generateInternalLBName(c.ObjectMeta.Name)
}
if len(lb.FrontendIPs) == 0 {
// for back compat, set the private IP to the subnet InternalLBIPAddress value.
privateIP := c.Spec.NetworkSpec.GetControlPlaneSubnet().InternalLBIPAddress
if privateIP == "" {
privateIP = DefaultInternalLBIPAddress
}
lb.FrontendIPs = []FrontendIP{
{
Name: generateFrontendIPConfigName(lb.Name),
PrivateIPAddress: privateIP,
},
}
}
}
}

// generateVnetName generates a virtual network name, based on the cluster name.
func generateVnetName(clusterName string) string {
return fmt.Sprintf("%s-%s", clusterName, "vnet")
Expand Down Expand Up @@ -132,3 +181,23 @@ func generateNodeSecurityGroupName(clusterName string) string {
func generateNodeRouteTableName(clusterName string) string {
return fmt.Sprintf("%s-%s", clusterName, "node-routetable")
}

// generateInternalLBName generates a internal load balancer name, based on the cluster name.
func generateInternalLBName(clusterName string) string {
return fmt.Sprintf("%s-%s", clusterName, "internal-lb")
}

// generatePublicLBName generates a public load balancer name, based on the cluster name.
func generatePublicLBName(clusterName string) string {
return fmt.Sprintf("%s-%s", clusterName, "public-lb")
}

// generatePublicIPName generates a public IP name, based on the cluster name and a hash.
func generatePublicIPName(clusterName string) string {
return fmt.Sprintf("pip-%s-apiserver", clusterName)
}

// generateFrontendIPConfigName generates a load balancer frontend IP config name.
func generateFrontendIPConfigName(lbName string) string {
return fmt.Sprintf("%s-%s", lbName, "frontEnd")
}
Loading

0 comments on commit 8c3a794

Please sign in to comment.