Skip to content

Commit ba8ef20

Browse files
authored
Merge pull request #32462 from my-git9/safely-drain-node
[zh] Update safely-drain-node
2 parents b9d4734 + b555410 commit ba8ef20

File tree

1 file changed

+4
-142
lines changed

1 file changed

+4
-142
lines changed

content/zh/docs/tasks/administer-cluster/safely-drain-node.md

Lines changed: 4 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -174,154 +174,16 @@ replicas to fall below the specified budget are blocked.
174174
175175
If you prefer not to use [kubectl drain](/docs/reference/generated/kubectl/kubectl-commands/#drain) (such as
176176
to avoid calling to an external command, or to get finer control over the pod
177-
eviction process), you can also programmatically cause evictions using the eviction API.
177+
eviction process), you can also programmatically cause evictions using the
178+
eviction API.
179+
For more information, see [API-initiated eviction](/docs/concepts/scheduling-eviction/api-eviction/).
178180
-->
179181
## 驱逐 API {#the-eviction-api}
180182
如果你不喜欢使用
181183
[kubectl drain](/docs/reference/generated/kubectl/kubectl-commands/#drain)
182184
(比如避免调用外部命令,或者更细化地控制 pod 驱逐过程),
183185
你也可以用驱逐 API 通过编程的方式达到驱逐的效果。
184-
185-
<!--
186-
You should first be familiar with using [Kubernetes language clients](/docs/tasks/administer-cluster/access-cluster-api/#programmatic-access-to-the-api).
187-
188-
The eviction subresource of a
189-
pod can be thought of as a kind of policy-controlled DELETE operation on the pod
190-
itself. To attempt an eviction (perhaps more REST-precisely, to attempt to
191-
*create* an eviction), you POST an attempted operation. Here's an example:
192-
-->
193-
首先应该熟悉使用
194-
[Kubernetes 语言客户端](/zh/docs/tasks/administer-cluster/access-cluster-api/#programmatic-access-to-the-api)
195-
196-
Pod 的 Eviction 子资源可以看作是一种策略控制的 DELETE 操作,作用于 Pod 本身。
197-
要尝试驱逐(更准确地说,尝试 *创建* 一个 Eviction),需要用 POST 发出所尝试的操作。这里有一个例子:
198-
199-
{{< tabs name="Eviction_example" >}}
200-
{{% tab name="policy/v1" %}}
201-
<!--
202-
{{< note >}}
203-
`policy/v1` Eviction is available in v1.22+. Use `policy/v1beta1` with prior releases.
204-
{{< /note >}}
205-
-->
206-
{{< note >}}
207-
`policy/v1` 驱逐在 v1.22+ 中可用。在之前版本中请使用 `policy/v1beta1`
208-
{{< /note >}}
209-
210-
211-
```json
212-
{
213-
"apiVersion": "policy/v1",
214-
"kind": "Eviction",
215-
"metadata": {
216-
"name": "quux",
217-
"namespace": "default"
218-
}
219-
}
220-
```
221-
{{% /tab %}}
222-
{{% tab name="policy/v1beta1" %}}
223-
<!--
224-
{{< note >}}
225-
Deprecated in v1.22 in favor of `policy/v1`
226-
{{< /note >}}
227-
-->
228-
{{< note >}}
229-
在 v1.22 中已弃用,以 `policy/v1` 取代
230-
{{< /note >}}
231-
232-
```json
233-
{
234-
"apiVersion": "policy/v1beta1",
235-
"kind": "Eviction",
236-
"metadata": {
237-
"name": "quux",
238-
"namespace": "default"
239-
}
240-
}
241-
```
242-
{{% /tab %}}
243-
{{< /tabs >}}
244-
245-
<!--
246-
You can attempt an eviction using `curl`:
247-
-->
248-
你可以使用 `curl` 尝试驱逐:
249-
250-
```bash
251-
curl -v -H 'Content-type: application/json' http://127.0.0.1:8080/api/v1/namespaces/default/pods/quux/eviction -d @eviction.json
252-
```
253-
254-
<!--
255-
The API can respond in one of three ways:
256-
257-
- If the eviction is granted, then the Pod is deleted as if you sent
258-
a `DELETE` request to the Pod's URL and received back `200 OK`.
259-
- If the current state of affairs wouldn't allow an eviction by the rules set
260-
forth in the budget, you get back `429 Too Many Requests`. This is
261-
typically used for generic rate limiting of *any* requests, but here we mean
262-
that this request isn't allowed *right now* but it may be allowed later.
263-
Currently, callers do not get any `Retry-After` advice, but they may in
264-
future versions.
265-
- If there is some kind of misconfiguration, like multiple budgets pointing at
266-
the same pod, you will get `500 Internal Server Error`.
267-
-->
268-
API 可以通过以下三种方式之一进行响应:
269-
270-
- 如果驱逐被授权,那么 Pod 将被删掉,并且你会收到 `200 OK`
271-
就像你向 Pod 的 URL 发送了 `DELETE` 请求一样。
272-
- 如果按照预算中规定,目前的情况不允许的驱逐,你会收到 `429 Too Many Requests`
273-
这通常用于对 *一些* 请求进行通用速率限制,
274-
但这里我们的意思是:此请求 *现在* 不允许,但以后可能会允许。
275-
目前,调用者不会得到任何 `Retry-After` 的提示,但在将来的版本中可能会得到。
276-
- 如果有一些错误的配置,比如多个预算指向同一个 Pod,你将得到 `500 Internal Server Error`
277-
278-
<!--
279-
For a given eviction request, there are two cases:
280-
281-
- There is no budget that matches this pod. In this case, the server always
282-
returns `200 OK`.
283-
- There is at least one budget. In this case, any of the three above responses may
284-
apply.
285-
-->
286-
对于一个给定的驱逐请求,有两种情况:
287-
288-
- 没有匹配这个 Pod 的预算。这种情况,服务器总是返回 `200 OK`
289-
- 至少匹配一个预算。在这种情况下,上述三种回答中的任何一种都可能适用。
290-
291-
<!--
292-
## Stuck evictions
293-
294-
In some cases, an application may reach a broken state, one where unless you intervene the
295-
eviction API will never return anything other than 429 or 500.
296-
297-
For example: this can happen if ReplicaSet is creating Pods for your application but
298-
the replacement Pods do not become `Ready`. You can also see similar symptoms if the
299-
last Pod evicted has a very long termination grace period.
300-
-->
301-
## 驱逐阻塞
302-
303-
在某些情况下,应用程序可能会到达一个中断状态,除了 429 或 500 之外,它将永远不会返回任何内容。
304-
例如 ReplicaSet 创建的替换 Pod 没有变成就绪状态,或者被驱逐的最后一个
305-
Pod 有很长的终止宽限期,就会发生这种情况。
306-
307-
<!--
308-
In this case, there are two potential solutions:
309-
310-
- Abort or pause the automated operation. Investigate the reason for the stuck application,
311-
and restart the automation.
312-
- After a suitably long wait, `DELETE` the Pod from your cluster's control plane, instead
313-
of using the eviction API.
314-
315-
Kubernetes does not specify what the behavior should be in this case; it is up to the
316-
application owners and cluster owners to establish an agreement on behavior in these cases.
317-
-->
318-
在这种情况下,有两种可能的解决方案:
319-
320-
- 中止或暂停自动操作。调查应用程序卡住的原因,并重新启动自动化。
321-
- 经过适当的长时间等待后,从集群中删除 Pod 而不是使用驱逐 API。
322-
323-
Kubernetes 并没有具体说明在这种情况下应该采取什么行为,
324-
这应该由应用程序所有者和集群所有者紧密沟通,并达成对行动一致意见。
186+
更多信息,请参阅 [API 发起的驱逐](/zh/docs/concepts/scheduling-eviction/api-eviction/)
325187

326188
## {{% heading "whatsnext" %}}
327189

0 commit comments

Comments
 (0)