Skip to content

Commit d352fc3

Browse files
authored
Merge pull request #36221 from windsonsea/marecon
[zh-cn] sync1.25 manage-resources-containers.md
2 parents 7424ed5 + e63c122 commit d352fc3

File tree

1 file changed

+72
-75
lines changed

1 file changed

+72
-75
lines changed

content/zh-cn/docs/concepts/configuration/manage-resources-containers.md

Lines changed: 72 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ feature:
88
根据资源需求和其他约束自动放置容器,同时避免影响可用性。
99
将关键性的和尽力而为性质的工作负载进行混合放置,以提高资源利用率并节省更多资源。
1010
---
11-
1211
<!--
1312
title: Resource Management for Pods and Containers
1413
content_type: concept
@@ -433,22 +432,22 @@ locally-attached writeable devices or, sometimes, by RAM.
433432
Pods use ephemeral local storage for scratch space, caching, and for logs.
434433
The kubelet can provide scratch space to Pods using local ephemeral storage to
435434
mount [`emptyDir`](/docs/concepts/storage/volumes/#emptydir)
436-
{{< glossary_tooltip term_id="volume" text="volumes" >}} into containers.
435+
{{< glossary_tooltip term_id="volume" text="volumes" >}} into containers.
437436
-->
438437
## 本地临时存储 {#local-ephemeral-storage}
439438

440439
<!-- feature gate LocalStorageCapacityIsolation -->
441440

442-
{{< feature-state for_k8s_version="v1.10" state="beta" >}}
441+
{{< feature-state for_k8s_version="v1.25" state="stable" >}}
443442

444443
节点通常还可以具有本地的临时性存储,由本地挂接的可写入设备或者有时也用 RAM
445444
来提供支持。
446445
“临时(Ephemeral)”意味着对所存储的数据不提供长期可用性的保证。
447446

448447
Pods 通常可以使用临时性本地存储来实现缓冲区、保存日志等功能。
449448
kubelet 可以为使用本地临时存储的 Pods 提供这种存储空间,允许后者使用
450-
[`emptyDir`](/zh-cn/docs/concepts/storage/volumes/#emptydir) 类型的
451-
{{< glossary_tooltip term_id="volume" text="卷" >}}将其挂载到容器中。
449+
[`emptyDir`](/zh-cn/docs/concepts/storage/volumes/#emptydir)
450+
类型的{{< glossary_tooltip term_id="volume" text="卷" >}}将其挂载到容器中。
452451

453452
<!--
454453
The kubelet also uses this kind of storage to hold
@@ -515,7 +514,6 @@ and the kubelet is designed with that layout in mind.
515514
Your node can have as many other filesystems, not used for Kubernetes,
516515
as you like.
517516
-->
518-
519517
kubelet 会将日志写入到所配置的日志目录(默认为 `/var/log`)下的文件中;
520518
还会针对其他本地存储的数据使用同一个基础目录(默认为 `/var/lib/kubelet`)。
521519

@@ -566,40 +564,43 @@ kubelet 将容器镜像层和可写层保存到这第二个文件系统上的某
566564

567565
<!--
568566
The kubelet can measure how much local storage it is using. It does this provided
569-
that:
567+
that you have set up the node using one of the supported configurations for local
568+
ephemeral storage.
570569

571570
- the `LocalStorageCapacityIsolation`
572571
[feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
573-
is enabled (the feature is on by default), and
574-
- you have set up the node using one of the supported configurations
575-
for local ephemeral storage.
572+
is enabled (the feature is on by default), and you have set up the node using one
573+
of the supported configurations for local ephemeral storage.
574+
- Quotas are faster and more accurate than directory scanning. The
575+
`LocalStorageCapacityIsolationFSQuotaMonitoring` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/) is enabled (the feature is on by default),
576576

577577
If you have a different configuration, then the kubelet does not apply resource
578578
limits for ephemeral local storage.
579-
580-
{{< note >}}
581-
The kubelet tracks `tmpfs` emptyDir volumes as container memory use, rather
582-
than as local ephemeral storage.
583-
{{< /note >}}
584579
-->
585580

586-
kubelet 能够度量其本地存储的用量。实现度量机制的前提是:
581+
kubelet 能够度量其本地存储的用量。
582+
实现度量机制的前提是你已使用本地临时存储所支持的配置之一对节点进行配置。
587583

588584
- `LocalStorageCapacityIsolation`
589-
[特性门控](/zh-cn/docs/reference/command-line-tools-reference/feature-gates/)
590-
被启用(默认状态),并且
591-
- 你已经对节点进行了配置,使之使用所支持的本地临时性储存配置方式之一
585+
[特性门控](/zh-cn/docs/reference/command-line-tools-reference/feature-gates/)被启用(默认状态),
586+
并且你已使用本地临时存储所支持的配置之一对节点进行了配置。
587+
- 配额机制比目录扫描更快、更准确。`LocalStorageCapacityIsolationFSQuotaMonitoring`
588+
[特性门控](/zh-cn/docs/reference/command-line-tools-reference/feature-gates/)被启用(默认状态)。
592589

593590
如果你的节点配置不同于以上预期,kubelet 就无法对临时性本地存储的资源约束实施限制。
594591

595592
{{< note >}}
593+
<!--
594+
The kubelet tracks `tmpfs` emptyDir volumes as container memory use, rather
595+
than as local ephemeral storage.
596+
-->
596597
kubelet 会将 `tmpfs` emptyDir 卷的用量当作容器内存用量,而不是本地临时性存储来统计。
597598
{{< /note >}}
598599

599600
<!--
600601
### Setting requests and limits for local ephemeral storage
601602

602-
You can use `ephemeral-storage` for managing local ephemeral storage. Each
603+
You can specify `ephemeral-storage` for managing local ephemeral storage. Each
603604
container of a Pod can specify either or both of the following:
604605

605606
* `spec.containers[].resources.limits.ephemeral-storage`
@@ -612,7 +613,7 @@ Mi, Ki. For example, the following quantities all represent roughly the same val
612613
-->
613614
### 为本地临时性存储设置请求和约束值 {#setting-requests-and-limits-for-local-ephemeral-storage}
614615

615-
你可以使用 `ephemeral-storage` 来管理本地临时性存储。
616+
你可以指定 `ephemeral-storage` 来管理本地临时性存储。
616617
Pod 中的每个容器可以设置以下属性:
617618

618619
* `spec.containers[].resources.limits.ephemeral-storage`
@@ -694,9 +695,9 @@ The scheduler ensures that the sum of the resource requests of the scheduled con
694695
### 带临时性存储的 Pods 的调度行为 {#how-pods-with-ephemeral-storage-requests-are-scheduled}
695696

696697
当你创建一个 Pod 时,Kubernetes 调度器会为 Pod 选择一个节点来运行之。
697-
每个节点都有一个本地临时性存储的上限,是其可提供给 Pods 使用的总量。
698-
欲了解更多信息,可参考
699-
[节点可分配资源](/zh-cn/docs/tasks/administer-cluster/reserve-compute-resources/#node-allocatable)
698+
每个节点都有一个本地临时性存储的上限,是其可提供给 Pod 使用的总量。
699+
欲了解更多信息,
700+
可参考[节点可分配资源](/zh-cn/docs/tasks/administer-cluster/reserve-compute-resources/#node-allocatable)
700701
节。
701702

702703
调度器会确保所调度的容器的资源请求总和不会超出节点的资源容量。
@@ -727,7 +728,7 @@ for eviction.
727728

728729
如果 kubelet 将本地临时性存储作为资源来管理,则 kubelet 会度量以下各处的存储用量:
729730

730-
- `emptyDir` 卷,除了 _tmpfs_ `emptyDir` 卷
731+
- `emptyDir` 卷,除了 **tmpfs** `emptyDir` 卷
731732
- 保存节点层面日志的目录
732733
- 可写入的容器镜像层
733734

@@ -741,8 +742,8 @@ kubelet 也会将所在的 Pod 标记为逐出候选。
741742
存储约束的总值。如果所有容器的本地临时性存储用量总和加上 Pod 的 `emptyDir`
742743
卷的用量超出 Pod 存储约束值,kubelet 也会将该 Pod 标记为逐出候选。
743744

744-
<!--
745745
{{< caution >}}
746+
<!--
746747
If the kubelet is not measuring local ephemeral storage, then a Pod
747748
that exceeds its local storage limit will not be evicted for breaching
748749
local storage resource limits.
@@ -754,78 +755,74 @@ and this taint triggers eviction for any Pods that don't specifically tolerate t
754755

755756
See the supported [configurations](#configurations-for-local-ephemeral-storage)
756757
for ephemeral local storage.
757-
{{< /caution >}}
758758
-->
759-
760-
{{< caution >}}
761759
如果 kubelet 没有度量本地临时性存储的用量,即使 Pod
762760
的本地存储用量超出其约束值也不会被逐出。
763761

764762
不过,如果用于可写入容器镜像层、节点层面日志或者 `emptyDir` 卷的文件系统中可用空间太少,
765-
节点会为自身设置本地存储不足的{{< glossary_tooltip text="污点" term_id="taint" >}} 标签。
766-
这一污点会触发对那些无法容忍该污点的 Pods 的逐出操作。
763+
节点会为自身设置本地存储不足的{{< glossary_tooltip text="污点" term_id="taint" >}}标签。
764+
这一污点会触发对那些无法容忍该污点的 Pod 的逐出操作。
767765

768766
关于临时性本地存储的配置信息,请参考[这里](#configurations-for-local-ephemeral-storage)
769767
{{< /caution >}}
770768

771769
<!--
772770
The kubelet supports different ways to measure Pod storage use:
771+
-->
772+
kubelet 支持使用不同方式来度量 Pod 的存储用量:
773773

774+
{{< tabs name="resource-emphemeralstorage-measurement" >}}
775+
{{% tab name="周期性扫描" %}}
776+
777+
<!--
774778
The kubelet performs regular, scheduled checks that scan each
775779
`emptyDir` volume, container log directory, and writeable container layer.
776780

777781
The scan measures how much space is used.
782+
-->
783+
kubelet 按预定周期执行扫描操作,检查 `emptyDir` 卷、容器日志目录以及可写入容器镜像层。
784+
785+
这一扫描会度量存储空间用量。
778786

779787
{{< note >}}
788+
<!--
780789
In this mode, the kubelet does not track open file descriptors
781790
for deleted files.
782791

783792
If you (or a container) create a file inside an `emptyDir` volume,
784793
something then opens that file, and you delete the file while it is
785794
still open, then the inode for the deleted file stays until you close
786795
that file but the kubelet does not categorize the space as in use.
787-
{{< /note >}}
788796
-->
789-
kubelet 支持使用不同方式来度量 Pod 的存储用量:
790-
791-
{{< tabs name="resource-emphemeralstorage-measurement" >}}
792-
{{% tab name="周期性扫描" %}}
793-
kubelet 按预定周期执行扫描操作,检查 `emptyDir` 卷、容器日志目录以及可写入容器镜像层。
794-
795-
这一扫描会度量存储空间用量。
796-
797-
{{< note >}}
798797
在这种模式下,kubelet 并不检查已删除文件所对应的、仍处于打开状态的文件描述符。
799798

800-
如果你(或者容器)在 `emptyDir` 卷中创建了一个文件,写入一些内容之后再次打开
801-
该文件并执行了删除操作,所删除文件对应的 inode 仍然存在,直到你关闭该文件为止。
802-
kubelet 不会将该文件所占用的空间视为已使用空间。
799+
如果你(或者容器)在 `emptyDir` 卷中创建了一个文件,
800+
写入一些内容之后再次打开该文件并执行了删除操作,所删除文件对应的 inode 仍然存在,
801+
直到你关闭该文件为止。kubelet 不会将该文件所占用的空间视为已使用空间。
803802
{{< /note >}}
804803

805804
{{% /tab %}}
806805

806+
{{% tab name="文件系统项目配额" %}}
807+
808+
{{< feature-state for_k8s_version="v1.25" state="beta" >}}
809+
807810
<!--
808811
Project quotas are an operating-system level feature for managing
809812
storage use on filesystems. With Kubernetes, you can enable project
810813
quotas for monitoring storage use. Make sure that the filesystem
811814
backing the `emptyDir` volumes, on the node, provides project quota support.
812815
For example, XFS and ext4fs offer project quotas.
813-
814-
{{< note >}}
815-
Project quotas let you monitor storage use; they do not enforce limits.
816-
{{< /note >}}
817816
-->
818-
819-
{{% tab name="文件系统项目配额" %}}
820-
821-
{{< feature-state for_k8s_version="v1.15" state="alpha" >}}
822-
823817
项目配额(Project Quota)是一个操作系统层的功能特性,用来管理文件系统中的存储用量。
824818
在 Kubernetes 中,你可以启用项目配额以监视存储用量。
825819
你需要确保节点上为 `emptyDir` 提供存储的文件系统支持项目配额。
826820
例如,XFS 和 ext4fs 文件系统都支持项目配额。
827821

828822
{{< note >}}
823+
<!--
824+
Project quotas let you monitor storage use; they do not enforce limits.
825+
-->
829826
项目配额可以帮你监视存储用量,但无法对存储约束执行限制。
830827
{{< /note >}}
831828

@@ -846,7 +843,7 @@ whereas directory scans overlook the storage used by deleted files.
846843
-->
847844
Kubernetes 所使用的项目 ID 始于 `1048576`。
848845
所使用的 IDs 会注册在 `/etc/projects` 和 `/etc/projid` 文件中。
849-
如果该范围中的项目 ID 已经在系统中被用于其他目的,则已占用的项目 IDs
846+
如果该范围中的项目 ID 已经在系统中被用于其他目的,则已占用的项目 ID
850847
也必须注册到 `/etc/projects` 和 `/etc/projid` 中,这样 Kubernetes
851848
才不会使用它们。
852849

@@ -882,8 +879,9 @@ If you want to use project quotas, you should:
882879

883880
如果你希望使用项目配额,你需要:
884881

885-
* 在 [kubelet 配置](/zh-cn/docs/reference/config-api/kubelet-config.v1beta1/)中使用 `featureGates` 字段 或者使用 `--feature-gates` 命令行参数
886-
启用 `LocalStorageCapacityIsolationFSQuotaMonitoring=true` [特性门控](/zh-cn/docs/reference/command-line-tools-reference/feature-gates/) 。
882+
* 在 [kubelet 配置](/zh-cn/docs/reference/config-api/kubelet-config.v1beta1/)中使用
883+
`featureGates` 字段或者使用 `--feature-gates` 命令行参数启用
884+
`LocalStorageCapacityIsolationFSQuotaMonitoring=true` [特性门控](/zh-cn/docs/reference/command-line-tools-reference/feature-gates/)。
887885

888886
* 确保根文件系统(或者可选的运行时文件系统)启用了项目配额。所有 XFS
889887
文件系统都支持项目配额。
@@ -911,7 +909,6 @@ There are two steps required to use Extended Resources. First, the cluster
911909
operator must advertise an Extended Resource. Second, users must request the
912910
Extended Resource in Pods.
913911
-->
914-
915912
## 扩展资源(Extended Resources) {#extended-resources}
916913

917914
扩展资源是 `kubernetes.io` 域名之外的标准资源名称。
@@ -941,8 +938,8 @@ for how to advertise device plugin managed resources on each node.
941938

942939
##### 设备插件管理的资源 {#device-plugin-managed-resources}
943940

944-
有关如何颁布在各节点上由设备插件所管理的资源,请参阅
945-
[设备插件](/zh-cn/docs/concepts/extend-kubernetes/compute-storage-net/device-plugins/)。
941+
有关如何颁布在各节点上由设备插件所管理的资源,
942+
请参阅[设备插件](/zh-cn/docs/concepts/extend-kubernetes/compute-storage-net/device-plugins/)。
946943

947944
<!--
948945
##### Other resources
@@ -992,15 +989,13 @@ curl --header "Content-Type: application/json-patch+json" \
992989
http://k8s-master:8080/api/v1/nodes/k8s-node-1/status
993990
```
994991

995-
<!--
996992
{{< note >}}
993+
<!--
997994
In the preceding request, `~1` is the encoding for the character `/`
998995
in the patch path. The operation path value in JSON-Patch is interpreted as a
999996
JSON-Pointer. For more details, see
1000997
[IETF RFC 6901, section 3](https://tools.ietf.org/html/rfc6901#section-3).
1001-
{{< /note >}}
1002998
-->
1003-
{{< note >}}
1004999
在前面的请求中,`~1` 是在 patch 路径中对字符 `/` 的编码。
10051000
JSON-Patch 中的操作路径的值被视为 JSON-Pointer 类型。
10061001
有关更多详细信息,请参见
@@ -1069,40 +1064,42 @@ extender.
10691064
Users can consume extended resources in Pod specs like CPU and memory.
10701065
The scheduler takes care of the resource accounting so that no more than the
10711066
available amount is simultaneously allocated to Pods.
1072-
1073-
The API server restricts quantities of extended resources to whole numbers.
1074-
Examples of _valid_ quantities are `3`, `3000m` and `3Ki`. Examples of
1075-
_invalid_ quantities are `0.5` and `1500m`.
10761067
-->
10771068
### 使用扩展资源 {#consuming-extended-resources}
10781069

10791070
就像 CPU 和内存一样,用户可以在 Pod 的规约中使用扩展资源。
10801071
调度器负责资源的核算,确保同时分配给 Pod 的资源总量不会超过可用数量。
10811072

10821073
<!--
1074+
The API server restricts quantities of extended resources to whole numbers.
1075+
Examples of _valid_ quantities are `3`, `3000m` and `3Ki`. Examples of
1076+
_invalid_ quantities are `0.5` and `1500m`.
1077+
-->
1078+
API 服务器将扩展资源的数量限制为整数。
1079+
**有效** 数量的示例是 `3`、`3000m` 和 `3Ki`。
1080+
**无效** 数量的示例是 `0.5` 和 `1500m`。
1081+
10831082
{{< note >}}
1083+
<!--
10841084
Extended resources replace Opaque Integer Resources.
10851085
Users can use any domain name prefix other than `kubernetes.io` which is reserved.
1086-
{{< /note >}}
10871086
-->
1088-
{{< note >}}
10891087
扩展资源取代了非透明整数资源(Opaque Integer Resources,OIR)。
10901088
用户可以使用 `kubernetes.io` (保留)以外的任何域名前缀。
10911089
{{< /note >}}
10921090

10931091
<!--
10941092
To consume an extended resource in a Pod, include the resource name as a key
10951093
in the `spec.containers[].resources.limits` map in the container spec.
1096-
1097-
{{< note >}}
1098-
Extended resources cannot be overcommitted, so request and limit
1099-
must be equal if both are present in a container spec.
1100-
{{< /note >}}
11011094
-->
11021095
要在 Pod 中使用扩展资源,请在容器规范的 `spec.containers[].resources.limits`
11031096
映射中包含资源名称作为键。
11041097

11051098
{{< note >}}
1099+
<!--
1100+
Extended resources cannot be overcommitted, so request and limit
1101+
must be equal if both are present in a container spec.
1102+
-->
11061103
扩展资源不能过量使用,因此如果容器规范中同时存在请求和约束,则它们的取值必须相同。
11071104
{{< /note >}}
11081105

@@ -1273,8 +1270,8 @@ For more information on node allocatable resources in Kubernetes, see
12731270
[Reserve Compute Resources for System Daemons](/docs/tasks/administer-cluster/reserve-compute-resources/).
12741271
-->
12751272
字段 `.status.allocatable` 描述节点上可以用于 Pod 的资源总量(例如:15 个虚拟
1276-
CPU、7538 MiB 内存)。关于 Kubernetes 中节点可分配资源的信息,可参阅
1277-
[为系统守护进程预留计算资源](/zh-cn/docs/tasks/administer-cluster/reserve-compute-resources/)
1273+
CPU、7538 MiB 内存)。关于 Kubernetes 中节点可分配资源的信息,
1274+
可参阅[为系统守护进程预留计算资源](/zh-cn/docs/tasks/administer-cluster/reserve-compute-resources/)
12781275

12791276
<!--
12801277
You can configure [resource quotas](/docs/concepts/policy/resource-quotas/)

0 commit comments

Comments
 (0)