-
Notifications
You must be signed in to change notification settings - Fork 425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enable the use of an external control plane #4611
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,9 +58,16 @@ func (c *AzureCluster) setNetworkSpecDefaults() { | |
c.setBastionDefaults() | ||
c.setSubnetDefaults() | ||
c.setVnetPeeringDefaults() | ||
c.setAPIServerLBDefaults() | ||
if c.Spec.ControlPlaneEnabled { | ||
c.setAPIServerLBDefaults() | ||
} | ||
c.SetNodeOutboundLBDefaults() | ||
c.SetControlPlaneOutboundLBDefaults() | ||
if c.Spec.ControlPlaneEnabled { | ||
c.SetControlPlaneOutboundLBDefaults() | ||
} | ||
if !c.Spec.ControlPlaneEnabled { | ||
c.Spec.NetworkSpec.APIServerLB = nil | ||
} | ||
Comment on lines
+66
to
+70
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than nulling values, it would be interesting to have a validation webhook complaining about the disparity of values: if the CP is disabled no values are allowed for the APIServerLB, if provided. |
||
} | ||
|
||
func (c *AzureCluster) setResourceGroupDefault() { | ||
|
@@ -93,16 +100,18 @@ func (c *AzureCluster) setSubnetDefaults() { | |
c.Spec.NetworkSpec.UpdateSubnet(clusterSubnet, SubnetCluster) | ||
} | ||
|
||
/* if there is a cp subnet set defaults | ||
if no cp subnet and cluster subnet create a default cp subnet */ | ||
cpSubnet, errcp := c.Spec.NetworkSpec.GetSubnet(SubnetControlPlane) | ||
if errcp == nil { | ||
cpSubnet.setControlPlaneSubnetDefaults(c.ObjectMeta.Name) | ||
c.Spec.NetworkSpec.UpdateSubnet(cpSubnet, SubnetControlPlane) | ||
} else if !clusterSubnetExists { | ||
cpSubnet = SubnetSpec{SubnetClassSpec: SubnetClassSpec{Role: SubnetControlPlane}} | ||
cpSubnet.setControlPlaneSubnetDefaults(c.ObjectMeta.Name) | ||
c.Spec.NetworkSpec.Subnets = append(c.Spec.NetworkSpec.Subnets, cpSubnet) | ||
if c.Spec.ControlPlaneEnabled { | ||
/* if there is a cp subnet set defaults | ||
if no cp subnet and cluster subnet create a default cp subnet */ | ||
cpSubnet, errcp := c.Spec.NetworkSpec.GetSubnet(SubnetControlPlane) | ||
if errcp == nil { | ||
cpSubnet.setControlPlaneSubnetDefaults(c.ObjectMeta.Name) | ||
c.Spec.NetworkSpec.UpdateSubnet(cpSubnet, SubnetControlPlane) | ||
} else if !clusterSubnetExists { | ||
cpSubnet = SubnetSpec{SubnetClassSpec: SubnetClassSpec{Role: SubnetControlPlane}} | ||
cpSubnet.setControlPlaneSubnetDefaults(c.ObjectMeta.Name) | ||
c.Spec.NetworkSpec.Subnets = append(c.Spec.NetworkSpec.Subnets, cpSubnet) | ||
} | ||
} | ||
|
||
var nodeSubnetFound bool | ||
|
@@ -210,7 +219,15 @@ func (c *AzureCluster) setVnetPeeringDefaults() { | |
} | ||
|
||
func (c *AzureCluster) setAPIServerLBDefaults() { | ||
lb := &c.Spec.NetworkSpec.APIServerLB | ||
if c.Spec.NetworkSpec.APIServerLB == nil { | ||
lbSpec := LoadBalancerSpec{ | ||
LoadBalancerClassSpec: LoadBalancerClassSpec{ | ||
Type: "Public", | ||
}, | ||
} | ||
c.Spec.NetworkSpec.APIServerLB = &lbSpec | ||
} | ||
lb := c.Spec.NetworkSpec.APIServerLB | ||
|
||
lb.LoadBalancerClassSpec.setAPIServerLBDefaults() | ||
|
||
|
@@ -249,7 +266,7 @@ func (c *AzureCluster) setAPIServerLBDefaults() { | |
// SetNodeOutboundLBDefaults sets the default values for the NodeOutboundLB. | ||
func (c *AzureCluster) SetNodeOutboundLBDefaults() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do worker nodes use the node outbound LB too? |
||
if c.Spec.NetworkSpec.NodeOutboundLB == nil { | ||
if c.Spec.NetworkSpec.APIServerLB.Type == Internal { | ||
if !c.Spec.ControlPlaneEnabled || c.Spec.NetworkSpec.APIServerLB.Type == Internal { | ||
return | ||
} | ||
|
||
|
@@ -314,7 +331,7 @@ func (c *AzureCluster) SetBackendPoolNameDefault() { | |
|
||
// SetAPIServerLBBackendPoolNameDefault defaults the name of the backend pool for apiserver LB. | ||
func (c *AzureCluster) SetAPIServerLBBackendPoolNameDefault() { | ||
apiServerLB := &c.Spec.NetworkSpec.APIServerLB | ||
apiServerLB := c.Spec.NetworkSpec.APIServerLB | ||
if apiServerLB.BackendPool.Name == "" { | ||
apiServerLB.BackendPool.Name = generateBackendAddressPoolName(apiServerLB.Name) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does order here matter?
It would be cool if we could group these functions together to reduce cyclomatic complexity.