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

feat: add script for import controller migration #574

Conversation

salasberryfin
Copy link
Contributor

kind/feature

What this PR does / why we need it:

Migrating to the new import controller based on clusters.management.cattle.io (v3 clusters) means we need to apply changes to the existing Rancher cluster resources to let the new controller identify CAPI clusters as already imported. As described in the migration proposal #573, the v3 controller looks for cluster resources marked with the following labels:

cluster-api.cattle.io/capi-cluster-owner
cluster-api.cattle.io/capi-cluster-owner-ns
cluster-api.cattle.io/owned

cluster-api.cattle.io/owned is added to all clusters imported via Turtles, even if using the existing clusters.provisioning.cattle.io (v1 clusters) based controller. The other two labels must be added to the existing clusters.management.cattle.io resources to let the new controller's label selector find a match and hence detect that the CAPI cluster is properly imported and no new resource needs to be created.

This PR adds a basic bash script for users to run pre-controller-migration so clusters are labeled accordingly. It simply gets one or multiple namespaces as input and applies labels to all Turtles clusters in that namespace.

We'll also be adding instructions on how to do it manually at the cluster level on a migration guide.

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Checklist:

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

scripts/import-controller-migration.sh Outdated Show resolved Hide resolved
scripts/import-controller-migration.sh Outdated Show resolved Hide resolved
scripts/import-controller-migration.sh Outdated Show resolved Hide resolved
scripts/import-controller-migration.sh Outdated Show resolved Hide resolved
Signed-off-by: Carlos Salas <carlos.salas@suse.com>
@salasberryfin salasberryfin force-pushed the script-add-migrationg-to-new-import-controller branch from 277025f to 4456e93 Compare June 18, 2024 15:18
@salasberryfin
Copy link
Contributor Author

Thanks for the comments @alexander-demicev. I reviewed the code and I think all of them have been addressed now.

@salasberryfin salasberryfin enabled auto-merge June 25, 2024 08:33
@salasberryfin salasberryfin merged commit 78fd337 into rancher:main Jun 25, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants