Garbage Collection

2020-09-13  本文已影响0人  allenhaozi
apiVersion: v1
kind: Pod
metadata:
  ...
  ownerReferences:
  - apiVersion: apps/v1
    controller: true
    blockOwnerDeletion: true
    kind: ReplicaSet
    name: my-repset
    uid: d9607e19-f88f-11e6-a518-42010a800195
  ...

The role of the Kubernetes garbage collector is to delete certain objects that once had an owner, but no longer have an owner.

Deleting dependents automatically is called cascading deletion

有两种级联删除

background and foreground

There are two modes of cascading deletion: background and foreground.

orphaned

If you delete an object without deleting its dependents automatically, the dependents are said to be orphaned.

Foreground cascading deletion

在前台级联删除中,根对象首先进入“正在删除”状态

一旦设置了“正在删除”状态,垃圾收集器就会删除对象的依赖项。一旦垃圾收集器删除了所有的“阻塞”依赖项(ownerreference.blockownerdelete =true的对象),它就会删除owner对象

Background cascading deletion

Kubernetes立即删除owner对象,垃圾收集器然后删除后台的依赖项

To delete dependents automatically using kubectl, set --cascade to true
To orphan dependents, set --cascade to false.

The default value for --cascade is true.

Here's an example that orphans the dependents of a ReplicaSet:

kubectl delete replicaset my-repset --cascade=false
上一篇 下一篇

猜你喜欢

热点阅读