Skip to content

Commit 83d7c2e

Browse files
committed
[zh] Sync scheduling-hugepages.md
1 parent d7e023e commit 83d7c2e

File tree

2 files changed

+71
-42
lines changed

2 files changed

+71
-42
lines changed

content/zh-cn/docs/tasks/manage-hugepages/scheduling-hugepages.md

+52-16
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
title: 管理巨页(HugePages
2+
title: 管理巨页(HugePage
33
content_type: task
4-
description: 将大页配置和管理为集群中的可调度资源。
4+
description: 将巨页作为集群中的可调度资源来配置和管理
55
---
66
<!--
77
reviewers:
@@ -12,6 +12,7 @@ description: Configure and manage huge pages as a schedulable resource in a clus
1212
--->
1313

1414
<!-- overview -->
15+
1516
{{< feature-state state="stable" >}}
1617

1718
<!--
@@ -20,24 +21,62 @@ by applications in a Pod. This page describes how users can consume huge pages.
2021
--->
2122
Kubernetes 支持在 Pod 应用中使用预先分配的巨页。本文描述了用户如何使用巨页,以及当前的限制。
2223

24+
## {{% heading "prerequisites" %}}
2325

26+
<!--
27+
Kubernetes nodes must
28+
[pre-allocate huge pages](https://www.kernel.org/doc/html/latest/admin-guide/mm/hugetlbpage.html)
29+
in order for the node to report its huge page capacity.
2430
25-
## {{% heading "prerequisites" %}}
31+
A node can pre-allocate huge pages for multiple sizes, for instance,
32+
the following line in `/etc/default/grub` allocates `2*1GiB` of 1 GiB
33+
and `512*2 MiB` of 2 MiB pages:
34+
--->
35+
为了使节点能够上报巨页容量,Kubernetes
36+
节点必须[预先分配巨页](https://www.kernel.org/doc/html/latest/admin-guide/mm/hugetlbpage.html)
2637

38+
节点能够预先分配多种规格的巨页。例如,在 `/etc/default/grub`
39+
中的以下这一行分配了 `2*1GiB` 的 1 GiB 页面和 `512*2 MiB` 的 2 MiB 页面。
2740

28-
<!--
29-
1. Kubernetes nodes must pre-allocate huge pages in order for the node to report
30-
its huge page capacity. A node can pre-allocate huge pages for multiple
31-
sizes.
41+
```
42+
GRUB_CMDLINE_LINUX="hugepagesz=1G hugepages=2 hugepagesz=2M hugepages=512"
43+
```
3244

45+
<!--
3346
The nodes will automatically discover and report all huge page resources as
3447
schedulable resources.
35-
--->
36-
1. 为了使节点能够上报巨页容量,Kubernetes 节点必须预先分配巨页。每个节点能够预先分配多种规格的巨页。
3748
38-
节点会自动发现全部巨页资源,并作为可供调度的资源进行上报。
49+
When you describe the Node, you should see something similar to the following
50+
in the following in the `Capacity` and `Allocatable` sections:
51+
-->
52+
节点将自动发现并报告所有巨页资源作为可调度资源。
3953

54+
当你描述 Node 时,你应该在 `Capacity``Allocatable` 节中看到类似以下内容:
4055

56+
```
57+
Capacity:
58+
cpu: ...
59+
ephemeral-storage: ...
60+
hugepages-1Gi: 2Gi
61+
hugepages-2Mi: 1Gi
62+
memory: ...
63+
pods: ...
64+
Allocatable:
65+
cpu: ...
66+
ephemeral-storage: ...
67+
hugepages-1Gi: 2Gi
68+
hugepages-2Mi: 1Gi
69+
memory: ...
70+
pods: ...
71+
```
72+
73+
{{< note >}}
74+
<!--
75+
For dynamically allocated pages (after boot), the Kubelet needs to be restarted
76+
for the new allocations to be refrelected.
77+
-->
78+
对于动态分配的页面(引导后),kubelet 需要被重新启动才能更新为新的分配。
79+
{{< /note >}}
4180

4281
<!-- steps -->
4382

@@ -55,7 +94,6 @@ memory or CPU resources must be requested as well.
5594
A pod may consume multiple huge page sizes in a single pod spec. In this case it
5695
must use `medium: HugePages-<hugepagesize>` notation for all volume mounts.
5796
--->
58-
5997
用户可以通过在容器级别的资源需求中使用资源名称 `hugepages-<size>`
6098
来使用巨页,其中的 size 是特定节点上支持的以整数值表示的最小二进制单位。
6199
例如,如果一个节点支持 2048KiB 和 1048576KiB 页面大小,它将公开可调度的资源
@@ -97,6 +135,7 @@ spec:
97135
emptyDir:
98136
medium: HugePages-1Gi
99137
```
138+
100139
<!--
101140
A pod may use `medium: HugePages` only if it requests huge pages of one size.
102141
-->
@@ -144,12 +183,9 @@ spec:
144183
--->
145184

146185
- 巨页的资源请求值必须等于其限制值。该条件在指定了资源限制,而没有指定请求的情况下默认成立。
147-
- 巨页是被隔离在 pod 作用域的,因此每个容器在 spec 中都对 cgroup 沙盒有自己的限制。
186+
- 巨页是被隔离在 Pod 作用域的,因此每个容器在 spec 中都对 cgroup 沙盒有自己的限制。
148187
- 巨页可用于 EmptyDir 卷,不过 EmptyDir 卷所使用的巨页数量不能够超出 Pod 请求的巨页数量。
149188
- 通过带有 `SHM_HUGETLB` 的 `shmget()` 使用巨页的应用,必须运行在一个与
150-
`proc/sys/vm/hugetlb_shm_group` 匹配的补充组下。
189+
`proc/sys/vm/hugetlb_shm_group` 匹配的补充组下。
151190
- 通过 ResourceQuota 资源,可以使用 `hugepages-<size>` 标记控制每个命名空间下的巨页使用量,
152191
类似于使用 `cpu` 或 `memory` 来控制其他计算资源。
153-
154-
155-

content/zh-cn/docs/tasks/manage-kubernetes-objects/imperative-config.md

+19-26
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ This document explains how to define and manage objects using configuration file
2323
<!--
2424
Install [`kubectl`](/docs/tasks/tools/).
2525
-->
26-
安装 [`kubectl`](/zh-cn/docs/tasks/tools/)
26+
安装 [`kubectl`](/zh-cn/docs/tasks/tools/)
2727

2828
{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
2929

@@ -34,7 +34,7 @@ Install [`kubectl`](/docs/tasks/tools/).
3434
3535
The `kubectl` tool supports three kinds of object management:
3636
-->
37-
## 权衡
37+
## 权衡 {#trade-offs}
3838

3939
`kubectl` 工具支持三种对象管理:
4040

@@ -51,7 +51,7 @@ The `kubectl` tool supports three kinds of object management:
5151
See [Kubernetes Object Management](/docs/concepts/overview/working-with-objects/object-management/)
5252
for a discussion of the advantages and disadvantage of each kind of object management.
5353
-->
54-
参看 [Kubernetes 对象管理](/zh-cn/docs/concepts/overview/working-with-objects/object-management/)
54+
参见 [Kubernetes 对象管理](/zh-cn/docs/concepts/overview/working-with-objects/object-management/)
5555
中关于每种对象管理的优缺点的讨论。
5656

5757
<!--
@@ -61,16 +61,20 @@ You can use `kubectl create -f` to create an object from a configuration file.
6161
Refer to the [kubernetes API reference](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/)
6262
for details.
6363
-->
64-
## 如何创建对象
64+
## 如何创建对象 {#how-to-create-objects}
6565

6666
你可以使用 `kubectl create -f` 从配置文件创建一个对象。
67-
请参考 [kubernetes API 参考](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/) 有关详细信息
67+
更多细节参阅 [kubernetes API 参考](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/)。
6868

6969
* `kubectl create -f <filename|url>`
7070

7171
<!--
7272
## How to update objects
73+
-->
74+
## 如何更新对象 {#how-to-update-objects}
7375

76+
{{< warning >}}
77+
<!--
7478
Updating objects with the `replace` command drops all
7579
parts of the spec not specified in the configuration file. This
7680
should not be used with objects whose specs are partially managed
@@ -79,9 +83,6 @@ the `externalIPs` field is managed independently from the configuration
7983
file. Independently managed fields must be copied to the configuration
8084
file to prevent `replace` from dropping them.
8185
-->
82-
## 如何更新对象
83-
84-
{{< warning >}}
8586
使用 `replace` 命令更新对象会删除所有未在配置文件中指定的规范的某些部分。
8687
不应将其规范由集群部分管理的对象使用,比如类型为 `LoadBalancer` 的服务,
8788
其中 `externalIPs` 字段独立于配置文件进行管理。
@@ -92,7 +93,7 @@ file to prevent `replace` from dropping them.
9293
You can use `kubectl replace -f` to update a live object according to a
9394
configuration file.
9495
-->
95-
你可以使用 `kubectl replace -f` 根据配置文件更新活动对象。
96+
你可以使用 `kubectl replace -f` 根据配置文件更新活动对象。
9697

9798
* `kubectl replace -f <filename|url>`
9899

@@ -102,24 +103,19 @@ configuration file.
102103
You can use `kubectl delete -f` to delete an object that is described in a
103104
configuration file.
104105
-->
105-
## 如何删除对象
106+
## 如何删除对象 {#how-to-delete-objects}
106107

107108
你可以使用 `kubectl delete -f` 删除配置文件中描述的对象。
108109

109110
* `kubectl delete -f <filename|url>`
110111

112+
{{< note >}}
111113
<!--
112114
If configuration file has specified the `generateName` field in the `metadata`
113115
section instead of the `name` field, you cannot delete the object using
114116
`kubectl delete -f <filename|url>`.
115117
You will have to use other flags for deleting the object. For example:
116-
117-
```shell
118-
kubectl delete <type> <name>
119-
kubectl delete <type> -l <label>
120-
```
121118
-->
122-
{{< note >}}
123119
如果配置文件在 `metadata` 节中设置了 `generateName` 字段而非 `name` 字段,
124120
你无法使用 `kubectl delete -f <filename|url>` 来删除该对象。
125121
你必须使用其他标志才能删除对象。例如:
@@ -136,7 +132,7 @@ kubectl delete <type> -l <label>
136132
You can use `kubectl get -f` to view information about an object that is
137133
described in a configuration file.
138134
-->
139-
## 如何查看对象
135+
## 如何查看对象 {#how-to-view-an-object}
140136

141137
你可以使用 `kubectl get -f` 查看有关配置文件中描述的对象的信息。
142138

@@ -146,8 +142,7 @@ described in a configuration file.
146142
The `-o yaml` flag specifies that the full object configuration is printed.
147143
Use `kubectl get -h` to see a list of options.
148144
-->
149-
`-o yaml` 标志指定打印完整的对象配置。
150-
使用 `kubectl get -h` 查看选项列表。
145+
`-o yaml` 标志指定打印完整的对象配置。使用 `kubectl get -h` 查看选项列表。
151146

152147
<!--
153148
## Limitations
@@ -160,7 +155,7 @@ is executed. This can happen if a controller, such as
160155
a HorizontalPodAutoscaler, makes updates directly to a live object. Here's
161156
an example:
162157
-->
163-
## 局限性
158+
## 局限性 {#limitations}
164159

165160
当完全定义每个对象的配置并将其记录在其配置文件中时,`create``replace``delete` 命令会很好的工作。
166161
但是,当更新一个活动对象,并且更新没有合并到其配置文件中时,下一次执行 `replace` 时,更新将丢失。
@@ -191,7 +186,7 @@ Suppose you have the URL of an object configuration file. You can use
191186
object is created. This is particularly useful for tutorials and tasks
192187
that point to a configuration file that could be modified by the reader.
193188
-->
194-
## 从 URL 创建和编辑对象而不保存配置
189+
## 从 URL 创建和编辑对象而不保存配置 {#creating-and-editing-an-object-from-a-url-without-saving-the-configuration}
195190

196191
假设你具有对象配置文件的 URL。
197192
你可以在创建对象之前使用 `kubectl create --edit` 对配置进行更改。
@@ -207,7 +202,7 @@ kubectl create -f <url> --edit
207202
Migrating from imperative commands to imperative object configuration involves
208203
several manual steps.
209204
-->
210-
## 从命令式命令迁移到命令式对象配置
205+
## 从命令式命令迁移到命令式对象配置 {#migrating-from-imperative-commands-to-imperative-object-configuration}
211206

212207
从命令式命令迁移到命令式对象配置涉及几个手动步骤。
213208

@@ -237,12 +232,12 @@ several manual steps.
237232
<!--
238233
## Defining controller selectors and PodTemplate labels
239234
-->
240-
## 定义控制器选择器和 PodTemplate 标签
235+
## 定义控制器选择器和 PodTemplate 标签 {#defining-controller-selectors-and-podtemplate-labels}
241236

237+
{{< warning >}}
242238
<!--
243239
Updating selectors on controllers is strongly discouraged.
244240
-->
245-
{{< warning >}}
246241
不建议在控制器上更新选择器。
247242
{{< /warning >}}
248243

@@ -279,5 +274,3 @@ template:
279274
* [使用配置文件对 Kubernetes 对象进行声明式管理](/zh-cn/docs/tasks/manage-kubernetes-objects/declarative-config/)
280275
* [Kubectl 命令参考](/docs/reference/generated/kubectl/kubectl-commands/)
281276
* [Kubernetes API 参考](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/)
282-
283-

0 commit comments

Comments
 (0)