Skip to content

Commit d147d57

Browse files
authored
Merge pull request #40801 from my-git9/path-6384
[zh-cn] sync configure-liveness-readiness-startup-probes.md security-context.md and assign-memory-resource.md
2 parents a73d6b4 + 8c9dab4 commit d147d57

File tree

3 files changed

+70
-45
lines changed

3 files changed

+70
-45
lines changed

content/zh-cn/docs/tasks/configure-pod-container/assign-memory-resource.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ for the Pod:
9898
-->
9999
## 指定内存请求和限制 {#specify-a-memory-request-and-a-memory-limit}
100100

101-
要为容器指定内存请求,请在容器资源清单中包含 `resourcesrequests` 字段。
102-
同理,要指定内存限制,请包含 `resourceslimits`
101+
要为容器指定内存请求,请在容器资源清单中包含 `resources: requests` 字段。
102+
同理,要指定内存限制,请包含 `resources: limits`
103103

104104
在本练习中,你将创建一个拥有一个容器的 Pod。
105105
容器将会请求 100 MiB 内存,并且内存会被限制在 200 MiB 以内。
@@ -544,6 +544,8 @@ kubectl delete namespace mem-example
544544
* [Configure a Pod Quota for a Namespace](/docs/tasks/administer-cluster/manage-resources/quota-pod-namespace/)
545545
546546
* [Configure Quotas for API Objects](/docs/tasks/administer-cluster/quota-api-object/)
547+
548+
* [Resize CPU and Memory Resources assigned to Containers](/docs/tasks/configure-pod-container/resize-container-resources/)
547549
-->
548550
### 集群管理员扩展阅读 {#for-cluster-administrators}
549551

@@ -554,4 +556,5 @@ kubectl delete namespace mem-example
554556
* [为命名空间配置内存和 CPU 配额](/zh-cn/docs/tasks/administer-cluster/manage-resources/quota-memory-cpu-namespace/)
555557
* [配置命名空间下 Pod 总数](/zh-cn/docs/tasks/administer-cluster/manage-resources/quota-pod-namespace/)
556558
* [配置 API 对象配额](/zh-cn/docs/tasks/administer-cluster/quota-api-object/)
559+
* [调整分配给容器的 CPU 和内存资源的大小](/docs/tasks/configure-pod-container/resize-container-resources/)
557560

content/zh-cn/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes.md

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ A common pattern for liveness probes is to use the same low-cost HTTP endpoint
3131
s for readiness probes, but with a higher failureThreshold. This ensures that the pod
3232
is observed as not-ready for some period of time before it is hard killed.
3333
-->
34-
3534
存活探针的常见模式是为就绪探针使用相同的低成本 HTTP 端点,但具有更高的 failureThreshold。
3635
这样可以确保在硬性终止 Pod 之前,将观察到 Pod 在一段时间内处于非就绪状态。
3736

@@ -75,8 +74,9 @@ scalable; and increased workload on remaining pods due to some failed pods.
7574
Understand the difference between readiness and liveness probes and when to apply them for your app.
7675
-->
7776
错误的存活探针可能会导致级联故障。
78-
这会导致在高负载下容器重启;例如由于应用程序无法扩展,导致客户端请求失败;以及由于某些 Pod 失败而导致剩余 Pod 的工作负载增加。
79-
了解就绪探针和存活探针之间的区别,以及何时为应用程序配置使用它们非常重要。
77+
这会导致在高负载下容器重启;例如由于应用程序无法扩展,导致客户端请求失败;以及由于某些
78+
Pod 失败而导致剩余 Pod 的工作负载增加。了解就绪探针和存活探针之间的区别,
79+
以及何时为应用程序配置使用它们非常重要。
8080
{{< /note >}}
8181

8282
## {{% heading "prerequisites" %}}
@@ -247,7 +247,7 @@ and restarts it.
247247
`periodSeconds` 字段指定了 kubelet 每隔 3 秒执行一次存活探测。
248248
`initialDelaySeconds` 字段告诉 kubelet 在执行第一次探测前应该等待 3 秒。
249249
kubelet 会向容器内运行的服务(服务在监听 8080 端口)发送一个 HTTP GET 请求来执行探测。
250-
如果服务器上 `/healthz` 路径下的处理程序返回成功代码,则 kubelet 认为容器是健康存活的。
250+
如果服务器上 `/healthz` 路径下的处理程序返回成功代码,则 kubelet 认为容器是健康存活的。
251251
如果处理程序返回失败代码,则 kubelet 会杀死这个容器并将其重启。
252252

253253
<!--
@@ -262,7 +262,7 @@ returns a status of 200. After that, the handler returns a status of 500.
262262
-->
263263
返回大于或等于 200 并且小于 400 的任何代码都标示成功,其它返回代码都标示失败。
264264

265-
你可以访问 [server.go](https://github.com/kubernetes/kubernetes/blob/master/test/images/agnhost/liveness/server.go)
265+
你可以访问 [server.go](https://github.com/kubernetes/kubernetes/blob/master/test/images/agnhost/liveness/server.go)
266266
阅读服务的源码。
267267
容器存活期间的最开始 10 秒中,`/healthz` 处理程序返回 200 的状态码。
268268
之后处理程序返回 500 的状态码。
@@ -380,11 +380,9 @@ kubectl describe pod goproxy
380380
{{< feature-state for_k8s_version="v1.24" state="beta" >}}
381381

382382
<!--
383-
If your application implements [gRPC Health Checking Protocol](https://github.com/grpc/grpc/blob/master/doc/health-checking.md),
384-
kubelet can be configured to use it for application liveness checks.
385-
You must enable the `GRPCContainerProbe`
386-
[feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
387-
in order to configure checks that rely on gRPC.
383+
If your application implements the [gRPC Health Checking Protocol](https://github.com/grpc/grpc/blob/master/doc/health-checking.md),
384+
this example shows how to configure Kubernetes to use it for application liveness checks.
385+
Similarly you can configure readiness and startup probes.
388386
389387
Here is an example manifest:
390388
-->
@@ -395,22 +393,40 @@ kubelet 可以配置为使用该协议来执行应用存活性检查。
395393
[特性门控](/zh-cn/docs/reference/command-line-tools-reference/feature-gates/)
396394
才能配置依赖于 gRPC 的检查机制。
397395

396+
这个例子展示了如何配置 Kubernetes 以将其用于应用程序的存活性检查。
397+
类似地,你可以配置就绪探针和启动探针。
398+
398399
下面是一个示例清单:
399400

400401
{{< codenew file="pods/probe/grpc-liveness.yaml" >}}
401402

402403
<!--
403-
To use a gRPC probe, `port` must be configured. If the health endpoint is configured
404-
on a non-default service, you must also specify the `service`.
405-
-->
406-
要使用 gRPC 探针,必须配置 `port` 属性。如果健康状态端点配置在非默认服务之上,
407-
你还必须设置 `service` 属性。
404+
To use a gRPC probe, `port` must be configured. If you want to distinguish probes of different types
405+
and probes for different features you can use the `service` field.
406+
You can set `service` to the value `liveness` and make your gRPC Health Checking endpoint
407+
respond to this request differently then when you set `service` set to `readiness`.
408+
This lets you use the same endpoint for different kinds of container health check
409+
(rather than needing to listen on two different ports).
410+
If you want to specify your own custom service name and also specify a probe type,
411+
the Kubernetes project recommends that you use a name that concatenates
412+
those. For example: `myservice-liveness` (using `-` as a separator).
413+
-->
414+
要使用 gRPC 探针,必须配置 `port` 属性。
415+
如果要区分不同类型的探针和不同功能的探针,可以使用 `service` 字段。
416+
你可以将 `service` 设置为 `liveness`,并使你的 gRPC
417+
健康检查端点对该请求的响应与将 `service` 设置为 `readiness` 时不同。
418+
这使你可以使用相同的端点进行不同类型的容器健康检查(而不需要在两个不同的端口上侦听)。
419+
如果你想指定自己的自定义服务名称并指定探测类型,Kubernetes
420+
项目建议你使用使用一个可以关联服务和探测类型的名称来命名。
421+
例如:`myservice-liveness`(使用 `-` 作为分隔符)。
408422

409423
{{< note >}}
410424
<!--
411-
Unlike HTTP and TCP probes, named ports cannot be used and custom host cannot be configured.
425+
Unlike HTTP and TCP probes, you cannot specify the healthcheck port by name, and you
426+
cannot configure a custom hostname.
412427
-->
413-
与 HTTP 和 TCP 探针不同,gRPC 探测不能使用命名端口或定制主机。
428+
与 HTTP 和 TCP 探针不同,gRPC 探测不能使用按名称指定端口,
429+
也不能自定义主机名。
414430
{{< /note >}}
415431

416432
<!--
@@ -580,7 +596,7 @@ Readiness probes runs on the container during its whole lifecycle.
580596
<!--
581597
Liveness probes *do not* wait for readiness probes to succeed. If you want to wait before executing a liveness probe you should use initialDelaySeconds or a startupProbe.
582598
-->
583-
存活探针 **不等待** 就绪性探针成功。
599+
存活探针**不等待**就绪性探针成功。
584600
如果要在执行存活探针之前等待,应该使用 `initialDelaySeconds` 或 `startupProbe`。
585601
{{< /caution >}}
586602

@@ -751,8 +767,8 @@ in the range 1 to 65535.
751767
[HTTP Probes](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#httpgetaction-v1-core)
752768
允许针对 `httpGet` 配置额外的字段:
753769

754-
* `host`:连接使用的主机名,默认是 Pod 的 IP。也可以在 HTTP 头中设置 Host 来代替。
755-
* `scheme` :用于设置连接主机的方式(HTTP 还是 HTTPS)。默认是 "HTTP"。
770+
* `host`:连接使用的主机名,默认是 Pod 的 IP。也可以在 HTTP 头中设置 "Host" 来代替。
771+
* `scheme`:用于设置连接主机的方式(HTTP 还是 HTTPS)。默认是 "HTTP"。
756772
* `path`:访问 HTTP 服务的路径。默认值为 "/"。
757773
* `httpHeaders`:请求中自定义的 HTTP 头。HTTP 头字段允许重复。
758774
* `port`:访问容器的端口号或者端口名。如果数字必须在 1~65535 之间。
@@ -840,7 +856,7 @@ to resolve it.
840856
-->
841857
### 探针层面的 `terminationGracePeriodSeconds`
842858

843-
{{< feature-state for_k8s_version="v1.25" state="beta" >}}
859+
{{< feature-state for_k8s_version="v1.27" state="stable" >}}
844860

845861
<!--
846862
Prior to release 1.21, the pod-level `terminationGracePeriodSeconds` was used
@@ -871,7 +887,6 @@ by default. For users choosing to disable this feature, please note the followin
871887
* The `ProbeTerminationGracePeriod` feature gate is only available on the API Server.
872888
The kubelet always honors the probe-level `terminationGracePeriodSeconds` field if
873889
it is present on a Pod.
874-
875890
-->
876891
{{< note >}}
877892
从 Kubernetes 1.25 开始,默认启用 `ProbeTerminationGracePeriod` 特性。

content/zh-cn/docs/tasks/configure-pod-container/security-context.md

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ To assign SELinux labels, the SELinux security module must be loaded on the host
710710
-->
711711
### 高效重打 SELinux 卷标签
712712

713-
{{< feature-state for_k8s_version="v1.25" state="alpha" >}}
713+
{{< feature-state for_k8s_version="v1.27" state="beta" >}}
714714

715715
<!--
716716
By default, the container runtime recursively assigns SELinux label to all
@@ -727,10 +727,11 @@ To benefit from this speedup, all these conditions must be met:
727727
要使用这项加速功能,必须满足下列条件:
728728

729729
<!--
730-
* Alpha feature gates `ReadWriteOncePod` and `SELinuxMountReadWriteOncePod` must
731-
be enabled.
730+
* The [feature gates](/docs/reference/command-line-tools-reference/feature-gates/) `ReadWriteOncePod`
731+
and `SELinuxMountReadWriteOncePod` must be enabled.
732732
-->
733-
* 必须启用 Alpha 特性门控 `ReadWriteOncePod` 和 `SELinuxMountReadWriteOncePod`。
733+
* 必须启用 `ReadWriteOncePod` 和 `SELinuxMountReadWriteOncePod`
734+
[特性门控](/zh-cn/docs/reference/command-line-tools-reference/feature-gates/)。
734735

735736
<!--
736737
* Pod must use PersistentVolumeClaim with `accessModes: ["ReadWriteOncePod"]`.
@@ -750,11 +751,18 @@ To benefit from this speedup, all these conditions must be met:
750751
* If you use a volume backed by a CSI driver, that CSI driver must announce that it
751752
supports mounting with `-o context` by setting `spec.seLinuxMount: true` in
752753
its CSIDriver instance.
754+
755+
* The corresponding PersistentVolume must be either:
756+
* A volume that uses the legacy in-tree `iscsi`, `rbd` or `fc` volume type.
757+
* Or a volume that uses a {{< glossary_tooltip text="CSI" term_id="csi" >}} driver.
758+
The CSI driver must announce that it supports mounting with `-o context` by setting
759+
`spec.seLinuxMount: true` in its CSIDriver instance.
753760
-->
754-
* 对应的 PersistentVolume 必须是使用 {< glossary_tooltip text="CSI" term_id="csi" >}}
755-
驱动程序的卷,或者是传统的 `iscsi` 卷类型的卷。
756-
* 如果使用基于 CSI 驱动程序的卷,CSI 驱动程序必须能够通过在 CSIDriver
757-
实例中设置 `spec.seLinuxMount: true` 以支持 `-o context` 挂载。
761+
* 对应的 PersistentVolume 必须是:
762+
* 使用传统树内(In-Tree) `iscsi`、`rbd` 或 `fs` 卷类型的卷。
763+
* 或者是使用 {< glossary_tooltip text="CSI" term_id="csi" >}} 驱动程序的卷
764+
CSI 驱动程序必须能够通过在 CSIDriver 实例中设置 `spec.seLinuxMount: true`
765+
以支持 `-o context` 挂载。
758766

759767
<!--
760768
For any other volume types, SELinux relabelling happens another way: the container
@@ -767,19 +775,18 @@ The more files and directories in the volume, the longer that relabelling takes.
767775
卷中的文件和目录越多,重打标签需要耗费的时间就越长。
768776

769777
{{< note >}}
770-
<!--
771-
In Kubernetes 1.25, the kubelet loses track of volume labels after restart. In
772-
other words, then kubelet may refuse to start Pods with errors similar to "conflicting
773-
SELinux labels of volume", while there are no conflicting labels in Pods. Make sure
774-
nodes are
775-
[fully drained](https://kubernetes.io/docs/tasks/administer-cluster/safely-drain-node/)
776-
before restarting kubelet.
777-
-->
778-
在 Kubernetes 1.25 中,kubelet 在重启后会丢失对卷标签的追踪记录。
779-
换言之,kubelet 可能会拒绝启动 Pod,原因类似于 “conflicting
780-
SELinux labels of volume”,
781-
但实际上 Pod 中并没有冲突的标签。在重启 kubelet
782-
之前确保节点已被[完全腾空](/zh-cn/docs/tasks/administer-cluster/safely-drain-node/)。
778+
<!-- remove after Kubernetes v1.30 is released -->
779+
<!--
780+
If you are running Kubernetes v1.25, refer to the v1.25 version of this task page:
781+
[Configure a Security Context for a Pod or Container](https://v1-25.docs.kubernetes.io/docs/tasks/configure-pod-container/security-context/) (v1.25).
782+
There is an important note in that documentation about a situation where the kubelet
783+
can lose track of volume labels after restart. This deficiency has been fixed
784+
in Kubernetes 1.26.
785+
-->
786+
如果你的 Kubernetes 版本是 v1.25,请参阅此任务页面的 v1.25 版本:
787+
[为 Pod 或 Container 配置安全上下文](https://v1-25.docs.kubernetes.io/docs/tasks/configure-pod-container/security-context/)(v1.25)。
788+
该文档中有一个重要的说明:kubelet 在重启后会丢失对卷标签的追踪记录。
789+
这个缺陷已经在 Kubernetes 1.26 中修复。
783790
{{< /note >}}
784791

785792
<!--

0 commit comments

Comments
 (0)