Skip to content

add resourceCleanup featureGate introduction #473

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions content/en/docs/getting-started/installation/register-a-cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,3 +316,39 @@ Check the klusterlet is removed from the managed cluster.
kubectl get klusterlet --context ${CTX_MANAGED_CLUSTER}
error: the server doesn't have a resource type "klusterlet
```

### Resource cleanup when the managed cluster is deleted

When a user deletes the managedCluster resource, all associated resources within the cluster namespace must also be removed. This includes managedClusterAddons, manifestWorks, and the roleBindings for the klusterlet agent. Resource cleanup follows a specific sequence to prevent resources from being stuck in a terminating state:

1. managedClusterAddons are deleted first.
2. manifestWorks are removed subsequently after all managedClusterAddons are deleted.
3. For the same resource as managedClusterAddon or manifestWork, custom deletion ordering can be defined using the `open-cluster-management.io/cleanup-priority` annotation:
- Priority values range from 0 to 100 (lower values execute first).

The `open-cluster-management.io/cleanup-priority` annotation controls deletion order when resource instances have dependencies. For example:

A manifestWork that applies a CRD and operator should be deleted after a manifestWork that creates a CR instance, allowing the operator to perform cleanup after the CR is removed.


Copy link
Member

Choose a reason for hiding this comment

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

add a short description that

when the user deletes the managedcluster resource, the related resource under the cluster namespace should also be removed, including managedclusteraddon, manifestworks and the rolebindings for the klusterlet agent. There is a certain sequence for cleanup to ensure no resource will be blocked in the deleting state.

Copy link
Member Author

Choose a reason for hiding this comment

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

updated

The `ResourceCleanup` featureGate for cluster registration on the Hub cluster enables automatic cleanup of managedClusterAddons and manifestWorks within the cluster namespace after cluster unjoining.

**Version Compatibility:**
- The `ResourceCleanup` featureGate was introdueced in OCM v0.13.0, and was **disabled by default** in OCM v0.16.0 and earlier versions. To activate it, need to modify the clusterManager CR configuration:
```yaml
registrationConfiguration:
featureGates:
- feature: ResourceCleanup
mode: Enable
```

- Starting with OCM v0.17.0, the `ResourceCleanup` featureGate has been upgraded from Alpha to Beta status and is **enabled by default**.

**Disabling the Feature:**
To deactivate this functionality, update the clusterManager CR on the hub cluster:
```yaml
registrationConfiguration:
featureGates:
- feature: ResourceCleanup
mode: Disable
```