Skip to content

Commit

Permalink
docs(proposal): add docs for using cascading deletion
Browse files Browse the repository at this point in the history
Signed-off-by: chang.qiangqiang <chang.qiangqiang@immomo.com>
  • Loading branch information
CharlesQQ committed Jul 9, 2024
1 parent c426e97 commit 5315523
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 0 deletions.
128 changes: 128 additions & 0 deletions docs/proposals/use-cascading-deletion/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
---
title: Use Cascading Deletion in Karmada

authors:
- "@CharlesQQ"

reviewers:
- "@robot"
- TBD

approvers:
- "@robot"
- TBD

creation-date: 2024-07-01

# Use Cascading Deletion in Karmada

## Summary
<!--
一种级联删除机制, 类似于[级联删除](https://kubernetes.io/docs/tasks/administer-cluster/use-cascading-deletion/)
-->
A cascading deletion mechanism, similar to [cascade deletion](https://kubernetes.io/docs/tasks/administer-cluster/use-cascading-deletion/)

## Motivation
<!--
默认情况下, 当用户删除Karmada控制面的资源模版之后,成员集群的资源也会被删除。但是仍然在某些场景下,用户希望仅仅删除控制面的资源,而保留成员集群资源;亦或是删除资源模版动作之后立即返回
-->

By default, when the user deletes the resource template of the Karmada control plane, the resources of the member cluster will also be deleted. However,in some scenarios,users want to delete only the control plane resources and retain the member cluster resources; or they want to return immediately after deleting the resource template action.

### Goals
<!--
- 提供只删除控制面资源模板,而成员集群资源不删除,同时清理Karmada附加给成员集群资源的labels/annotations的能力
- 提供控制面资源模版删除之后,不阻塞等待成员集群资源删除的能力
- 其他直接产生work对象的资源如namespace(ns-controller开启)/cronfederatedhpa/federaredhpa/federatedresourcequota,需要有和资源模板相同的能力
- 提供karmadactl命令行,可以执行级联删除策略, 如 `karmadactl delete deployment --cascade=orphan`
-->

- Provides the ability to delete only the control plane resource templates without deleting the member cluster resources, and at the same time clean up the labels/annotations attached to the member cluster resources by Karmada.
- Provides the ability to not block waiting for member cluster resource deletion after the control plane resource template is deleted.
- Other resources that directly generate work objects, such as namespace (ns-controller is turned on)/cronfederatedhpa/federaredhpa/federatedresourcequota, need to have the same capabilities as resource templates.
- Provides karmadactl command line to execute cascade deletion strategy, such as `karmadactl delete deployment --cascade=orphan`

### Non-Goals
<!--
- 不考虑不同的成员集群需要有不同的删除策略的情况
- 其他删除策略, 比如保留work对象
-->
- Does not consider the situation that different member clusters need different deletion strategies
- Other deletion strategies, such as retaining work objects

## Proposal

### User Stories (Optional)

#### Story 1
<!--
作为管理员,我希望在工作负载迁移到Karmada期间有一个回滚机制,以便在出现任何意外情况时可以恢复到迁移前的状态。
-->
As an administrator, I would like to have a rollback mechanism during workload migration to Karmada so that in case of any unexpected situation, I can revert to the pre-migration state.

#### Story 2
<!--
作为管理员, 我希望可以有一种手段可以将某个测试集群从Karmada控制面移除,同时测试集群上面的workload不受影响
-->
As an administrator, I hope there is a way to remove a test cluster from the Karmada control plane without affecting the workload on the test cluster.

#### Story 3
<!--
作为管理员,为了降低接口耗时,我希望在删除控制面资源模板之后可以立即返回,不阻塞等待直到成员集群资源删除。
-->
As an administrator, in order to reduce the interface time-consuming, I hope that I can return immediately after deleting the control plane resource template without blocking and waiting until the member cluster resources are deleted.

### Notes/Constraints/Caveats (Optional)

### Risks and Mitigations

## Design Details

### API changes
<!--
- 由于删除操作的对象是资源模板, 所以为资源模板添加Annotation, 名称为: `resourcetemplate.karmada.io/cascadedeletion`
- 为了可扩展性,value应该是一个枚举类型
- orphan: 删除work对象,清理Karmada附加给成员集群的workload的annotation/labels,不删除成员集群workload对象.
- foreground: 默认情况前台删除,等同于不存在上述注解或者注解的值为空;删除动作会阻塞等待直到成员集群workload被删除掉.
- background: 后台删除表示删除资源模板之后立即返回,由控制器在后台逐步清理成员集群workload.
-->

- Since the object of the deletion operation is the resource template, add Annotation to the resource template, named: `resourcetemplate.karmada.io/cascadedeletion`
- For scalability, value should be an enum type
- orphan: Delete the work object, clean up the annotation/labels of the workload attached by Karmada to the member cluster, and do not delete the member cluster workload object.
- foreground: By default, the foreground is deleted, which means that the above annotation does not exist or the value of the annotation is empty; the deletion action will block and wait until the member cluster workload is deleted.
- background: Background deletion means returning immediately after deleting the resource template, and the controller gradually cleans up the member cluster workload in the background.
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
propagationpolicy.karmada.io/name: foo
propagationpolicy.karmada.io/namespace: default
resourcetemplate.karmada.io/cascadedeletion: orphan
```

<!--
- 用户触发删除动作
- execution-controller 根据级联删除策略执行相应的动作
![Dependencies resource deletion policy](statics/dependencies-resource-deletion-policy.png)
-->

- User triggers deletion action
- execution-controller performs corresponding actions according to the cascade deletion policy
![use-cascading-deletion](statics/use-cascading-deletion.png)

### The cascading deletion policy of dependent resources and main resources does not force binding
<!--
依赖资源和主资源的级联删除策略不强制绑定
由于依赖资源可能被多个资源模版共享,在这种情况下很难决策依赖资源的删除策略以哪个删除策略为准; 不强制和主资源绑定,由用户自己决策,灵活性和扩展性更好
-->
Since dependent resources may be shared by multiple resource templates, in this case it is difficult to decide which deletion strategy should be used for the dependent resources; it is not forced to be bound to the main resource, and is left to the user to decide, with greater flexibility and scalability. good

### karmadactl adds command line parameters related to cascade deletion
<!--
karmadactl 增加级联删除相关的命令行参数
- `karmadactl delete deployment <name> --cascade=orphan` 给资源增加级联删除策略并删除资源
-->

`karmadactl delete deployment <name> --cascade=orphan` adds a cascade deletion policy to the resource and deletes the resource
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5315523

Please sign in to comment.