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

docs: managementv3 cluster support strategy #357

Merged

Conversation

salasberryfin
Copy link
Contributor

@salasberryfin salasberryfin commented Jan 25, 2024

What this PR does / why we need it:

This ADR is a proposal on how support for management.cattle.io/v3 clusters is implemented, based on investigation during the development process.

The main point of concern here is how we manage cluster naming. Since management.cattle.io/v3 clusters are required to have a name that satisfies the string c- followed by exactly five characters, we cannot use the display name (the one that appears in Rancher dashboard) as we do with provisioning.cattle.io/v1 clusters (where name and display name are the same).

Creating a randomized 5-character suffix presents the challenge of not being able to track the resource while reconciling like we do in the existing provisioning.cattle.io/v1 import controller, since we fetch the cluster on Name and Namespace (refer to here).

A reasonable alternative is to compute the SHA256 hash of the display name and then truncate the result to fit in the 5-character prefix of the name. This would make it easy and cheap to deterministically get the resource name based on the display name. The problem with this approach is that we could potentially encounter collisions if the number of clusters is large.

We will be tracking the cluster based on two new labels that will be applied to all management.cattle.io/v3 Rancher clusters that uniquely reference the CAPI cluster that owns the resource. Using this approach, we can leverage the built-in functionality of Kubernetes by passing the field GenerateName with the prefix c- so that it randomly generates a 5 character suffix that satisfies the regular expression, and retries if a name collision occurs.

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

Special notes for your reviewer:

Checklist:

  • squashed commits into logical changes
  • includes documentation
  • adds unit tests
  • adds or updates e2e tests

@salasberryfin salasberryfin added the kind/documentation Improvements or additions to documentation label Jan 25, 2024
@salasberryfin salasberryfin requested a review from a team as a code owner January 25, 2024 08:40
@salasberryfin salasberryfin force-pushed the adr-managementv3-clusters branch 2 times, most recently from 2e3bca9 to cb9f670 Compare January 25, 2024 09:09
@salasberryfin salasberryfin changed the title "docs: managementv3 cluster support strategy" docs: managementv3 cluster support strategy Jan 25, 2024
@salasberryfin
Copy link
Contributor Author

I updated the ADR document and the PR description based on the feedback. Thanks @Danil-Grigorev @richardcase.

Signed-off-by: Carlos Salas <carlos.salas@suse.com>
@salasberryfin salasberryfin requested a review from a team January 30, 2024 18:48
@salasberryfin
Copy link
Contributor Author

Thanks for the comments and reviews folks.

@salasberryfin salasberryfin merged commit 487cfe5 into rancher:main Feb 1, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ADR: support management.cattle.io/v3 cluster import
4 participants