-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
✨ making SetNodeProviderID no more blocking although Control Plane is externally managed #6640
Conversation
Welcome @prometherion! |
Hi @prometherion. 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. |
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.
/ok-to-test
@@ -399,7 +399,7 @@ func (m *Machine) SetNodeProviderID(ctx context.Context) error { | |||
patch := fmt.Sprintf(`{"spec": {"providerID": %q}}`, m.ProviderID()) | |||
cmd := kubectlNode.Commander.Command( | |||
"kubectl", | |||
"--kubeconfig", "/etc/kubernetes/admin.conf", | |||
"--kubeconfig", "/etc/kubernetes/kubelet.conf", |
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 the kubelet.conf on any machine have the rights to patch any other node?
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.
I wonder why we are doing this via kubectl. Is there something which prevents us from simply using a Client configured against the workload cluster API server in the controller?
(maybe it doesn't work for the first control plane node and we get stuck?)
(cc @fabriziopandini)
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.
Any kubelet.conf
seems not work, I think the kubelet.conf of a node is only able to patch himself:
Trying to patch itself: allowed (still throws an error due to invalid patch, could be ignored in this case)
root@capi-quickstart-md-0-bj6ch-79956b7999-dvpx9:/# kubectl --kubeconfig /etc/kubernetes/kubelet.conf patch no capi-quickstart-md-0-bj6ch-79956b7999-dvpx9 -p '{"spec": {"providerID": "docker:////capi-quickstart-md-0-bj6ch-79956b7999-dvpx9-foo"}}'
The Node "capi-quickstart-md-0-bj6ch-79956b7999-dvpx9" is invalid: spec.providerID: Forbidden: node updates may not change providerID except from "" to valid
Trying to patch other node: fails because forbidden
root@capi-quickstart-md-0-bj6ch-79956b7999-dvpx9:/# kubectl --kubeconfig /etc/kubernetes/kubelet.conf patch no capi-quickstart-md-0-bj6ch-79956b7999-7hpkk -p '{"spec": {"providerID": "docker:////capi-quickstart-md-0-bj6ch-79956b7999-7hpkk-foo"}}'
Error from server (Forbidden): nodes "capi-quickstart-md-0-bj6ch-79956b7999-7hpkk" is forbidden: node "capi-quickstart-md-0-bj6ch-79956b7999-dvpx9" is not allowed to modify node "capi-quickstart-md-0-bj6ch-79956b7999-7hpkk"
This is due to the Node
authorization mode in kube-apiserver
: --authorization-mode=Node,RBAC
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.
Yup. That's what I expected
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.
I changed the code to launch the patch command from the node itself. CI is green now.
However, I don't see a real benefit here on launching the command from the node, besides reducing the number of lines of code. If we all agree on using the controller-runtime
client, I can rework the PR.
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.
As I'm not really sure about why we use kubectl I would say let's just keep it that way (at least for this PR) as the current PR will definitely already fix your issue and is an improvement
/retest |
/test pull-cluster-api-e2e-full-main |
2eddc5e
to
a8b832f
Compare
/test pull-cluster-api-e2e-full-main |
/lgtm /assign @fabriziopandini |
/lgtm |
// This will happen when the current machine is the only machine. | ||
return kubectlNodes[0], nil | ||
|
||
return nil, 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.
We should avoid returning nil, nil
, shouldn't we have an error if we haven't found the node?
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.
Good point. We also did this before, but let's fix / improve it
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.
Address with d4b2a03, let me know if it should be squashed in a single commit.
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.
Looks good. Yup, please squash
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.
Thanks, squashed.
d4b2a03
to
3ce889f
Compare
/lgtm |
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.
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: vincepri The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What this PR does / why we need it:
The current code-base gave for granted that in a Docker-based CAPI installation, the Control Plane is managed in the same infrastructure. However, this assumption couldn't be entirely correct, and due to this, the reconciliation is blocking the operations required to assign the Provider IDs to the machines.
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 #6639