Signed-off-by: Fish-pro <zechun.chen@daocloud.io> |
||
|---|---|---|
| .. | ||
| README.md | ||
README.md
| short-desc | title | authors | reviewers | approvers | creation-date | last-updated | status | |||
|---|---|---|---|---|---|---|---|---|---|---|
| Cleanup member cluster resources on unjoin | Cleanup Member Cluster Resources |
|
|
2021-07-03 | 2020-07-03 | provisional |
Cleanup propagated resources
Table of Contents
This document proposes a mechanism to specify that a member cluster resource should be removed from a managed cluster when leaving.
Motivation
When a cluster is unjoined, Karmada should provide a mechanism to clean up the resources propagated by Karmada. Currently, when unjoining a cluster, Karmada first tries to remove the propagated resources, and will skip the removal if the cluster is not ready.
Goals
- Define how users can indicate that propagated resource should be removed when a cluster leaves
- Define cluster removal strategies
Proposals
The Cluster struct should be updated to contain a RemoveStrategy member. RemoveStrategy now supports Needless and Required.
- The
Needlessstrategy will not clean up any propagated resources. - The
Requiredstrategy will halt the unjoin process and set theCluster resourcein a failed state when encountering errors. Unjoining is blocked until all propagated resources have been removed successfully.
RemoveStrategy defaults to needless on all cluster. A user must explicitly set a removal strategy for the joined cluster.
Implementation details
-
Update cluster to add a new attribute:
RemoveStrategy *RemoveStrategy `json:"removeStrategy,omitempty"`type RemoveStrategy string const ( RemoveStrategyNeedless RemoveStrategy = "Needless" RemoveStrategyRequired RemoveStrategy = "Required" ) -
Add a flag
remove-strategytokarmadactl join, and set the value toRemoveStrategyattribute -
During unjoin cluster,
karmadashould consider remove strategy
In kubefed's propose, the author suggest add a BestEffort strategy, reviewers say we need a certain value, so we should not use it too. Karmada use the BestEffort strategy, currently.
Needless Strategy
Not need cleanup propagated resources when unjoining cluster. Karmada should use this strategy as default value, condsider the business risk.
Required Strategy
Clusters with the "required" removal strategy must remove execution namespaces successfully on unjoin. After removing the work resource, the client must verify that the propagated resource is no longer present. If a resource cannot be removed:
- UnjoinCluster should return a formatted error containing which
workcould not be removed - A ClusterCondition should be added to the
clusterstatus with a message indicating which resources could not be removed - (optional) Set the ConditionType to
Failed
Execution Controller
When cluster is unjoined, karmada should process by cluster remove strategy:
Needlessstrategy ignoreworkdelete eventRequiredstrategy return true if theworkdelete success, and set clustercondition if delete fail
Additional ClusterConditionTypes (optional)
Presently, there are only two ClusterConditionTypes, Unjoining and UnjoinFailed. Given the required remove strategy, a Cluster may end up in a state where the cluster is Ready but is in the process of "Unjoining". Adding additional conditions will make it easier to understand life cycle of cluster operator.
status:
conditions:
- lastTransitionTime: "2021-05-08T12:34:15Z"
lastUpdateTime: "2021-05-08T12:34:30Z"
message: Unjoining resources.
reason: UnjoinCluster
status: "True"
type: Unjoining
Unjoining ClusterConditionType
The Unjoining condition should be set on a cluster when exec karmadactl unjoin command.
Failed ClusterConditionType
In the event of an error, such as failure to remove a resource with a required remove strategy, the cluster should enter a UnjoinFailed condition.