Add delete in order policy
Signed-off-by: Jianbo Sun <jianbo.sjb@alibaba-inc.com>
This commit is contained in:
parent
510b834f8f
commit
2bf2b57f54
|
|
@ -248,3 +248,58 @@ spec:
|
|||
- example-addon-namespace
|
||||
strategy: never
|
||||
```
|
||||
|
||||
## Delete resource in the dependency order
|
||||
|
||||
If you want to garbage collect resources in the order of reverse dependency, you can add `order: dependency` in the `garbage-collect` policy.
|
||||
|
||||
:::note
|
||||
This delete in order feature is only available for the resources that created in the components. Custom Resources deployed in WorkflowStep will not be included.
|
||||
:::
|
||||
|
||||
|
||||
```yaml
|
||||
apiVersion: core.oam.dev/v1beta1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: gc-dependency
|
||||
namespace: default
|
||||
spec:
|
||||
components:
|
||||
- name: test1
|
||||
type: webservice
|
||||
properties:
|
||||
image: crccheck/hello-world
|
||||
port: 8000
|
||||
dependsOn:
|
||||
- "test2"
|
||||
- name: test2
|
||||
type: webservice
|
||||
properties:
|
||||
image: crccheck/hello-world
|
||||
port: 8000
|
||||
inputs:
|
||||
- from: test3-output
|
||||
parameterKey: test
|
||||
- name: test3
|
||||
type: webservice
|
||||
properties:
|
||||
image: crccheck/hello-world
|
||||
port: 8000
|
||||
outputs:
|
||||
- name: test3-output
|
||||
valueFrom: output.metadata.name
|
||||
|
||||
policies:
|
||||
- name: gc-dependency
|
||||
type: garbage-collect
|
||||
properties:
|
||||
order: dependency
|
||||
```
|
||||
|
||||
|
||||
In the example above, component `test1` depends on `test2`, and `test2` need the output from `test3`.
|
||||
|
||||
So the creation order of deployment is: `test3 -> test2 -> test1`.
|
||||
|
||||
When we add `order: dependency` in `garbage-collect` policy and delete the application, the order of garbage collection is: `test1 -> test2 -> test3`.
|
||||
|
|
|
|||
|
|
@ -255,3 +255,56 @@ spec:
|
|||
strategy: never
|
||||
```
|
||||
|
||||
## 按依赖顺序回收资源
|
||||
|
||||
如果你期望按照资源的依赖顺序删除资源,也可以使用本策略,添加 `order: dependency` 即可。
|
||||
|
||||
:::note
|
||||
本策略只会按顺序删除在 Component 中声明的资源,在 Workflow 步骤中自定义创建的资源不包括。
|
||||
:::
|
||||
|
||||
```yaml
|
||||
apiVersion: core.oam.dev/v1beta1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: gc-dependency
|
||||
namespace: default
|
||||
spec:
|
||||
components:
|
||||
- name: test1
|
||||
type: webservice
|
||||
properties:
|
||||
image: crccheck/hello-world
|
||||
port: 8000
|
||||
dependsOn:
|
||||
- "test2"
|
||||
- name: test2
|
||||
type: webservice
|
||||
properties:
|
||||
image: crccheck/hello-world
|
||||
port: 8000
|
||||
inputs:
|
||||
- from: test3-output
|
||||
parameterKey: test
|
||||
- name: test3
|
||||
type: webservice
|
||||
properties:
|
||||
image: crccheck/hello-world
|
||||
port: 8000
|
||||
outputs:
|
||||
- name: test3-output
|
||||
valueFrom: output.metadata.name
|
||||
|
||||
policies:
|
||||
- name: gc-dependency
|
||||
type: garbage-collect
|
||||
properties:
|
||||
order: dependency
|
||||
```
|
||||
|
||||
在上述例子中,我们有三个组件,依赖关系是 `test1` 依赖 `test2`, `test2` 依赖 `test3` 的输出。
|
||||
|
||||
所以组件的部署顺序为:`test3 -> test2 -> test1`.
|
||||
|
||||
当我们在资源回收策略(`garbage-collect`)中指定 `order: dependency` 时,资源的删除顺序为: `test1 -> test2 -> test3`。
|
||||
|
||||
|
|
|
|||
|
|
@ -255,3 +255,56 @@ spec:
|
|||
strategy: never
|
||||
```
|
||||
|
||||
## 按依赖顺序回收资源
|
||||
|
||||
如果你期望按照资源的依赖顺序删除资源,也可以使用本策略,添加 `order: dependency` 即可。
|
||||
|
||||
:::note
|
||||
本策略只会按顺序删除在 Component 中声明的资源,在 Workflow 步骤中自定义创建的资源不包括。
|
||||
:::
|
||||
|
||||
```yaml
|
||||
apiVersion: core.oam.dev/v1beta1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: gc-dependency
|
||||
namespace: default
|
||||
spec:
|
||||
components:
|
||||
- name: test1
|
||||
type: webservice
|
||||
properties:
|
||||
image: crccheck/hello-world
|
||||
port: 8000
|
||||
dependsOn:
|
||||
- "test2"
|
||||
- name: test2
|
||||
type: webservice
|
||||
properties:
|
||||
image: crccheck/hello-world
|
||||
port: 8000
|
||||
inputs:
|
||||
- from: test3-output
|
||||
parameterKey: test
|
||||
- name: test3
|
||||
type: webservice
|
||||
properties:
|
||||
image: crccheck/hello-world
|
||||
port: 8000
|
||||
outputs:
|
||||
- name: test3-output
|
||||
valueFrom: output.metadata.name
|
||||
|
||||
policies:
|
||||
- name: gc-dependency
|
||||
type: garbage-collect
|
||||
properties:
|
||||
order: dependency
|
||||
```
|
||||
|
||||
在上述例子中,我们有三个组件,依赖关系是 `test1` 依赖 `test2`, `test2` 依赖 `test3` 的输出。
|
||||
|
||||
所以组件的部署顺序为:`test3 -> test2 -> test1`.
|
||||
|
||||
当我们在资源回收策略(`garbage-collect`)中指定 `order: dependency` 时,资源的删除顺序为: `test1 -> test2 -> test3`。
|
||||
|
||||
|
|
|
|||
|
|
@ -248,3 +248,58 @@ spec:
|
|||
- example-addon-namespace
|
||||
strategy: never
|
||||
```
|
||||
|
||||
## Delete resource in the dependency order
|
||||
|
||||
If you want to garbage collect resources in the order of reverse dependency, you can add `order: dependency` in the `garbage-collect` policy.
|
||||
|
||||
:::note
|
||||
This delete in order feature is only available for the resources that created in the components. Custom Resources deployed in WorkflowStep will not be included.
|
||||
:::
|
||||
|
||||
|
||||
```yaml
|
||||
apiVersion: core.oam.dev/v1beta1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: gc-dependency
|
||||
namespace: default
|
||||
spec:
|
||||
components:
|
||||
- name: test1
|
||||
type: webservice
|
||||
properties:
|
||||
image: crccheck/hello-world
|
||||
port: 8000
|
||||
dependsOn:
|
||||
- "test2"
|
||||
- name: test2
|
||||
type: webservice
|
||||
properties:
|
||||
image: crccheck/hello-world
|
||||
port: 8000
|
||||
inputs:
|
||||
- from: test3-output
|
||||
parameterKey: test
|
||||
- name: test3
|
||||
type: webservice
|
||||
properties:
|
||||
image: crccheck/hello-world
|
||||
port: 8000
|
||||
outputs:
|
||||
- name: test3-output
|
||||
valueFrom: output.metadata.name
|
||||
|
||||
policies:
|
||||
- name: gc-dependency
|
||||
type: garbage-collect
|
||||
properties:
|
||||
order: dependency
|
||||
```
|
||||
|
||||
|
||||
In the example above, component `test1` depends on `test2`, and `test2` need the output from `test3`.
|
||||
|
||||
So the creation order of deployment is: `test3 -> test2 -> test1`.
|
||||
|
||||
When we add `order: dependency` in `garbage-collect` policy and delete the application, the order of garbage collection is: `test1 -> test2 -> test3`.
|
||||
|
|
|
|||
Loading…
Reference in New Issue