-
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?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Welcome @rpahli! |
Hi @rpahli. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
APIServerLB LoadBalancerSpec `json:"apiServerLB,omitempty"` | ||
APIServerLB *LoadBalancerSpec `json:"apiServerLB,omitempty"` |
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.
Instead of using a pointer, what about moving the additional field you introduced (ControlPlaneEnabled
) here?
With such approach we could introduce the feature smoothly with no breaking changes, and maintain the current state of the pointers.
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.
The "problem" is that der is a mutation inside the webhook and if this is no pointer then some fields will be filled which makes problems later. To me the question is omitempty
means it can be null so the pointer also makes sense to me.
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.
LGTM, it makes sense.
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
/remove-lifecycle stale |
c.setAPIServerLBDefaults() | ||
if c.Spec.ControlPlaneEnabled { | ||
c.setAPIServerLBDefaults() | ||
} | ||
c.SetNodeOutboundLBDefaults() | ||
c.SetControlPlaneOutboundLBDefaults() |
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.
c.SetControlPlaneOutboundLBDefaults() | ||
} | ||
if !c.Spec.ControlPlaneEnabled { | ||
c.Spec.NetworkSpec.APIServerLB = nil | ||
} |
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.
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.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Do worker nodes use the node outbound LB too?
api/v1beta1/azurecluster_types.go
Outdated
// ControlPlaneEnabled enable control plane cluster components. | ||
// +kubebuilder:default=true | ||
// +optional | ||
ControlPlaneEnabled bool `json:"controlPlaneEnabled"` |
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.
ControlPlaneEnabled bool `json:"controlPlaneEnabled"` | |
ControlPlaneEnabled bool `json:"controlPlaneEnabled,omitempty"` |
requiredSubnetRoles := map[string]bool{ | ||
"control-plane": false, | ||
"control-plane": !controlPlaneEnabled, | ||
"node": false, | ||
} |
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.
This should be refactored this way:
requiredSubnetRoles := map[string]bool{
"node": false,
}
if controlPlaneEnabled {
requiredSubnetRoles["control-plane"] = false
}
The key control-plane
must not be present when the Control Plane is externally managed.
APIServerLB LoadBalancerSpec `json:"apiServerLB,omitempty"` | ||
APIServerLB *LoadBalancerSpec `json:"apiServerLB,omitempty"` |
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.
LGTM, it makes sense.
azure/scope/cluster.go
Outdated
for _, ip := range s.ControlPlaneOutboundLB().FrontendIPs { | ||
controlPlaneOutboundIPSpecs = append(controlPlaneOutboundIPSpecs, &publicips.PublicIPSpec{ | ||
Name: ip.PublicIP.Name, | ||
if s.ControlPlaneEnabled() { |
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.
We could avoid the multiple if
nesting here, just having the IsAPIServerPrivate
block, and put the ControlPlaneEnabled
function in the else
clause, since we need outbound LB only if the CP Load Balancer is enabled.
azure/scope/cluster.go
Outdated
PublicIP: &infrav1.PublicIPSpec{ | ||
Name: ip, | ||
DNSName: dns, | ||
if s.ControlPlaneEnabled() { |
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.
Rather than nesting with if
conditions, let's return if the Control Plane is not enabled.
if !s.ControlPlaneEnabled() {
return
}
config/capz/manager_image_patch.yaml
Outdated
@@ -8,5 +8,5 @@ spec: | |||
spec: | |||
containers: | |||
# Change the value of image field below to your controller image URL | |||
- image: gcr.io/k8s-staging-cluster-api-azure/cluster-api-azure-controller:main | |||
- image: localhost:5000/cluster-api-azure-controller-amd64:dev |
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.
Just a reminder, amend the changes here.
} | ||
if azureCluster.Spec.ControlPlaneEndpoint.Port == 0 { | ||
azureCluster.Spec.ControlPlaneEndpoint.Port = clusterScope.APIServerPort() | ||
if azureCluster.Spec.ControlPlaneEnabled { |
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.
We need to check the values also when the Control Plane is externally managed, something like this:
if !azureCluster.Spec.ControlPlaneEnabled {
if azureCluster.Spec.ControlPlaneEndpoint.Host == "" {
conditions.MarkFalse(azureCluster, infrav1.NetworkInfrastructureReadyCondition, "ExternallyManagedControlPlane", clusterv1.ConditionSeverityInfo, "Waiting for the Control Plane host")
return reconcile.Result{}, nil
} else if azureCluster.Spec.ControlPlaneEndpoint.Port == 0 {
conditions.MarkFalse(azureCluster, infrav1.NetworkInfrastructureReadyCondition, "ExternallyManagedControlPlane", clusterv1.ConditionSeverityInfo, "Waiting for the Control Plane port")
return reconcile.Result{}, nil
}
}
/ok-to-test |
@rpahli: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
There are still some unanswered questions, especially about grouping some functions (here) besides my personal question on the outbound LB: since the Control Plane is externally managed, is the said outbound used only for the worker nodes? |
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.
This lgtm overall, thanks @rpahli and @prometherion. Maybe there's a way to have fewer if controlPlaneEnabled
checks by deferring some validation to a webhook as suggested in one comment?
// ControlPlaneEnabled enable control plane cluster components. | ||
// +kubebuilder:default=true | ||
// +optional | ||
ControlPlaneEnabled bool `json:"controlPlaneEnabled,omitempty"` |
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.
Is ControlPlaneEnabled
the same field name in other provider implementations? Would be good to keep that consistent if possible.
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.
Unfortunately, there's no consistency across providers since this setting may vary.
e.g. on AWS:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: AWSCluster
metadata:
name: capi-quickstart
namespace: default
spec:
region: us-east-1
sshKeyName: default
controlPlaneLoadBalancer:
loadBalancerType: disabled
PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
What type of PR is this?
/kind feature
This PR enables the use off an external control plane (e.g. https://github.com/clastix/cluster-api-control-plane-provider-kamaji)
What this PR does / why we need it:
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #
Special notes for your reviewer:
TODOs:
Release note: