Skip to content
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

Validate that IP addresses for ControlPlane and StaticWorkers are different #3334

Merged
merged 2 commits into from
Aug 7, 2024

Conversation

kron4eg
Copy link
Member

@kron4eg kron4eg commented Aug 6, 2024

Which issue(s) this PR fixes:
Fixes #2632

What type of PR is this?
/kind api-change

Special notes for your reviewer:

Does this PR introduce a user-facing change? Then add your Release Note here:

[ACTION REQUIRED] KubeOne is now validating that IP addresses and hostnames provided for control plane nodes and static worker nodes are different. In other words, it's not possible to use the same machine both as a control plane node and a static worker node. This behavior has never been supported by KubeOne; if you want a control plane node that can schedule any pod, you can provision it as a control plane node and remove the control plane taint (`node-role.kubernetes.io/control-plane:NoSchedule`).

Documentation:

NONE

…ferent

Signed-off-by: Artiom Diomin <artiom@kubermatic.com>
@kron4eg kron4eg requested a review from xmudrii August 6, 2024 15:55
@kubermatic-bot kubermatic-bot added kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API release-note Denotes a PR that will be considered when it comes time to generate release notes. docs/none Denotes a PR that doesn't need documentation (changes). dco-signoff: yes Denotes that all commits in the pull request have the valid DCO signoff message. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 6, 2024
@xmudrii
Copy link
Member

xmudrii commented Aug 7, 2024

@kron4eg What if we add public and private addresses, and hostnames, of CP and static worker nodes to two different sets, and then compare sets? That seems like a great way to prevent any possible combination of what can go wrong, as long as we find any intersection, we error out.

@kron4eg
Copy link
Member Author

kron4eg commented Aug 7, 2024

@kron4eg What if we add public and private addresses, and hostnames, of CP and static worker nodes to two different sets, and then compare sets? That seems like a great way to prevent any possible combination of what can go wrong, as long as we find any intersection, we error out.

Hostnames are optional and may be absent at the time when validation is running. That's why I didn't included them in the check. Given nested for loop almost exactly the same as sets but without fancy APIs/functions, except one thing. It point to the exact index of the problematic static worker with with .Index() function. Which is not possible with sets.

@xmudrii
Copy link
Member

xmudrii commented Aug 7, 2024

Hostnames are optional and may be absent at the time when validation is running. That's why I didn't included them in the check.

That's true, but if we know them, it's useful to do the validation, and with sets this is very easy.

Given nested for loop almost exactly the same as sets but without fancy APIs/functions, except one thing.

They don't function the exactly same, for example, you might "hack" around by inverting public and private addresses. This and some other cases are much easier to catch by doing the intersection.

It point to the exact index of the problematic static worker with with .Index() function. Which is not possible with sets.

This is nice, but IMO it's also enough just to point out to what value is conflicting and you can do that with intersect.

@kron4eg
Copy link
Member Author

kron4eg commented Aug 7, 2024

TBH I don't want to change the thing "just because" with loosing some of the info. There has to be a good reason for that and I don't see sets as one.

@xmudrii
Copy link
Member

xmudrii commented Aug 7, 2024

@kron4eg Can we at least include the information what's the conflicting IP address? I find that much more valuable compared to the index.

Signed-off-by: Artiom Diomin <artiom@kubermatic.com>
@kron4eg
Copy link
Member Author

kron4eg commented Aug 7, 2024

@kron4eg Can we at least include the information what's the conflicting IP address? I find that much more valuable compared to the index.

sure, and as a bonus optional validation on the hostname (excluding empty case).

Copy link
Member

@xmudrii xmudrii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve

@kubermatic-bot kubermatic-bot added the lgtm Indicates that a PR is ready to be merged. label Aug 7, 2024
@kubermatic-bot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 23d1440fc464b6a50de1805cc0cd04d9812c3047

@kubermatic-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: xmudrii

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubermatic-bot kubermatic-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 7, 2024
@kubermatic-bot kubermatic-bot merged commit 9b13e6d into kubermatic:main Aug 7, 2024
14 checks passed
@kubermatic-bot kubermatic-bot added this to the KubeOne 1.9 milestone Aug 7, 2024
@kron4eg kron4eg deleted the validate-cp-static-workers branch August 7, 2024 19:07
@xmudrii
Copy link
Member

xmudrii commented Nov 18, 2024

/release-note-edit

[ACTION REQUIRED] KubeOne is now validating that IP addresses and hostnames provided for control plane nodes and static worker nodes are different. In other words, it's not possible to use the same machine both as a control plane node and a static worker node. This behavior has never been supported by KubeOne; if you want a control plane node that can schedule any pod, you can provision it as a control plane node and remove the control plane taint (`node-role.kubernetes.io/control-plane:NoSchedule`).

@kubermatic-bot kubermatic-bot added release-note-action-required Denotes a PR that introduces potentially breaking changes that require user action. and removed release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Denotes that all commits in the pull request have the valid DCO signoff message. docs/none Denotes a PR that doesn't need documentation (changes). kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API lgtm Indicates that a PR is ready to be merged. release-note-action-required Denotes a PR that introduces potentially breaking changes that require user action. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disallow using same machines for both control plane and static workers
3 participants