-
Notifications
You must be signed in to change notification settings - Fork 427
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
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 |
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
Hey @rpahli 👋🏼 , how is this PR coming along ? |
125c187
to
2556a3c
Compare
[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 |
423e1ec
to
3ad59ca
Compare
Hey @nawazkh I'm currently trying to fix the e2e tests. But all other tests look ok to me. |
@nawazkh can someone maybe support me with the e2e tests? Is it possible to debug the tests locally? Or do I need a azure account for that? |
/retest |
I have triggered a retest since on the first look it looked like a timeout errors. Will dig deeper once it fails. The best way to debug this would be to run the tests locally with an Azure account. |
Ok now it looks only the API die is failing which is expected. |
3ad59ca
to
21d3915
Compare
21d3915
to
0571951
Compare
@rpahli: The following test 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. |
/assign @mboersma |
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: