[zh] Resync pages under working-with-objects
This commit is contained in:
@@ -32,32 +32,37 @@ Kubernetes 自动指定了一些 Finalizers,但你也可以指定你自己的
|
||||
|
||||
When you create a resource using a manifest file, you can specify finalizers in
|
||||
the `metadata.finalizers` field. When you attempt to delete the resource, the
|
||||
controller that manages it notices the values in the `finalizers` field and does
|
||||
the following:
|
||||
API server handling the delete request notices the values in the `finalizers` field
|
||||
and does the following:
|
||||
|
||||
* Modifies the object to add a `metadata.deletionTimestamp` field with the
|
||||
time you started the deletion.
|
||||
* Marks the object as read-only until its `metadata.finalizers` field is empty.
|
||||
* Prevents the object from being removed until its `metadata.finalizers` field is empty.
|
||||
* Returns a `202` status code (HTTP "Accepted")
|
||||
-->
|
||||
## Finalizers 如何工作 {#how-finalizers-work}
|
||||
|
||||
当你使用清单文件创建资源时,你可以在 `metadata.finalizers` 字段指定 Finalizers。
|
||||
当你试图删除该资源时,管理该资源的控制器会注意到 `finalizers` 字段中的值,
|
||||
当你试图删除该资源时,处理删除请求的 API 服务器会注意到 `finalizers` 字段中的值,
|
||||
并进行以下操作:
|
||||
|
||||
* 修改对象,将你开始执行删除的时间添加到 `metadata.deletionTimestamp` 字段。
|
||||
* 将该对象标记为只读,直到其 `metadata.finalizers` 字段为空。
|
||||
* 禁止对象被删除,直到其 `metadata.finalizers` 字段为空。
|
||||
* 返回 `202` 作为状态码(HTTP "Accepted")。
|
||||
|
||||
<!--
|
||||
The controller managing that finalizer notices the update to the object setting the
|
||||
`metadata.deletionTimestamp`, indicating deletion of the object has been requested.
|
||||
The controller then attempts to satisfy the requirements of the finalizers
|
||||
specified for that resource. Each time a finalizer condition is satisfied, the
|
||||
controller removes that key from the resource's `finalizers` field. When the
|
||||
field is empty, garbage collection continues. You can also use finalizers to
|
||||
prevent deletion of unmanaged resources.
|
||||
`finalizers` field is emptied, an object with a `deletionTimestamp` field set
|
||||
is automatically deleted. You can also use finalizers to prevent deletion of unmanaged resources.
|
||||
-->
|
||||
然后,控制器试图满足资源的 Finalizers 的条件。
|
||||
管理 finalizer 的控制器注意到对象上发生的更新操作,对象的 `metadata.deletionTimestamp`
|
||||
被设置,意味着已经请求删除该对象。然后,控制器会试图满足资源的 Finalizers 的条件。
|
||||
每当一个 Finalizer 的条件被满足时,控制器就会从资源的 `finalizers` 字段中删除该键。
|
||||
当该字段为空时,垃圾收集继续进行。
|
||||
当 `finalizers` 字段为空时,`deletionTimestamp` 字段被设置的对象会被自动删除。
|
||||
你也可以使用 Finalizers 来阻止删除未被管理的资源。
|
||||
|
||||
<!--
|
||||
@@ -111,7 +116,7 @@ Kubernetes also processes finalizers when it identifies owner references on a
|
||||
resource targeted for deletion.
|
||||
|
||||
In some situations, finalizers can block the deletion of dependent objects,
|
||||
which can cause the targeted owner object to remain in a read-only state for
|
||||
which can cause the targeted owner object to remain for
|
||||
longer than expected without being fully deleted. In these situations, you
|
||||
should check finalizers and owner references on the target owner and dependent
|
||||
objects to troubleshoot the cause.
|
||||
@@ -123,20 +128,24 @@ Kubernetes 会使用属主引用(而不是标签)来确定集群中哪些 Po
|
||||
当 Kubernetes 识别到要删除的资源上的属主引用时,它也会处理 Finalizers。
|
||||
|
||||
在某些情况下,Finalizers 会阻止依赖对象的删除,
|
||||
这可能导致目标属主对象,保持在只读状态的时间比预期的长,且没有被完全删除。
|
||||
这可能导致目标属主对象被保留的时间比预期的长,而没有被完全删除。
|
||||
在这些情况下,你应该检查目标属主和附属对象上的 Finalizers 和属主引用,来排查原因。
|
||||
|
||||
{{<note>}}
|
||||
{{< note >}}
|
||||
<!--
|
||||
In cases where objects are stuck in a deleting state, try to avoid manually
|
||||
In cases where objects are stuck in a deleting state, avoid manually
|
||||
removing finalizers to allow deletion to continue. Finalizers are usually added
|
||||
to resources for a reason, so forcefully removing them can lead to issues in
|
||||
your cluster.
|
||||
-->
|
||||
在对象卡在删除状态的情况下,尽量避免手动移除 Finalizers,以允许继续删除操作。
|
||||
Finalizers 通常因为特殊原因被添加到资源上,所以强行删除它们会导致集群出现问题。
|
||||
{{</note>}}
|
||||
your cluster. This should only be done when the purpose of the finalizer is
|
||||
understood and is accomplished in another way (for example, manually cleaning
|
||||
up some dependent object).
|
||||
|
||||
-->
|
||||
在对象卡在删除状态的情况下,要避免手动移除 Finalizers,以允许继续删除操作。
|
||||
Finalizers 通常因为特殊原因被添加到资源上,所以强行删除它们会导致集群出现问题。
|
||||
只有了解 finalizer 的用途时才能这样做,并且应该通过一些其他方式来完成
|
||||
(例如,手动清除其余的依赖对象)。
|
||||
{{< /note >}}
|
||||
|
||||
## {{% heading "whatsnext" %}}
|
||||
|
||||
@@ -144,4 +153,5 @@ Finalizers 通常因为特殊原因被添加到资源上,所以强行删除它
|
||||
* Read [Using Finalizers to Control Deletion](/blog/2021/05/14/using-finalizers-to-control-deletion/)
|
||||
on the Kubernetes blog.
|
||||
-->
|
||||
* 阅读 Kubernetes 博客的[使用 Finalizers 控制删除](/blog/2021/05/14/using-finalizers-to-control-deletion/)。
|
||||
* 在 Kubernetes 博客上阅读[使用 Finalizers 控制删除](/blog/2021/05/14/using-finalizers-to-control-deletion/)。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user