Skip to content

Commit b608cc1

Browse files
authored
Merge pull request #34016 from Sea-n/zh-code-output-tasks
[zh] Sync tasks
2 parents 6bfc4cf + dd34016 commit b608cc1

File tree

6 files changed

+92
-72
lines changed

6 files changed

+92
-72
lines changed

content/zh/docs/tasks/access-application-cluster/configure-access-multiple-clusters.md

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@ configuration files. After your clusters, users, and contexts are defined in
2222
one or more configuration files, you can quickly switch between clusters by using the
2323
`kubectl config use-context` command.
2424
-->
25-
本文展示如何使用配置文件来配置对多个集群的访问。 在将集群、用户和上下文定义在一个或多个配置文件中之后,用户可以使用 `kubectl config use-context` 命令快速地在集群之间进行切换。
25+
本文展示如何使用配置文件来配置对多个集群的访问。
26+
在将集群、用户和上下文定义在一个或多个配置文件中之后,用户可以使用
27+
`kubectl config use-context` 命令快速地在集群之间进行切换。
2628

29+
{{< note >}}
2730
<!--
2831
A file that is used to configure access to a cluster is sometimes called
2932
a *kubeconfig file*. This is a generic way of referring to configuration files.
3033
It does not mean that there is a file named `kubeconfig`.
3134
-->
32-
{{< note >}}
3335
用于配置集群访问的文件有时被称为 *kubeconfig 文件*
3436
这是一种引用配置文件的通用方式,并不意味着存在一个名为 `kubeconfig` 的文件。
3537
{{< /note >}}
@@ -63,6 +65,7 @@ kubectl 的版本应该与集群的 API 服务器
6365
[使用同一次版本号](/zh/releases/version-skew-policy/#kubectl)
6466

6567
<!-- steps -->
68+
6669
<!--
6770
## Define clusters, users, and contexts
6871
@@ -76,16 +79,16 @@ to the scratch cluster requires authentication by username and password.
7679
Create a directory named `config-exercise`. In your
7780
`config-exercise` directory, create a file named `config-demo` with this content:
7881
-->
79-
## 定义集群、用户和上下文
82+
## 定义集群、用户和上下文 {#define-clusters-users-and-contexts}
8083

8184
假设用户有两个集群,一个用于正式开发工作,一个用于其它临时用途(scratch)。
8285
`development` 集群中,前端开发者在名为 `frontend` 的名字空间下工作,
83-
存储开发者在名为 `storage` 的名字空间下工作。 `scratch` 集群中,
84-
开发人员可能在默认名字空间下工作,也可能视情况创建附加的名字空间。
86+
存储开发者在名为 `storage` 的名字空间下工作。在 `scratch` 集群中,
87+
开发人员可能在默认名字空间下工作,也可能视情况创建附加的名字空间。
8588
访问开发集群需要通过证书进行认证。
8689
访问其它临时用途的集群需要通过用户名和密码进行认证。
8790

88-
创建名为 `config-exercise` 的目录。
91+
创建名为 `config-exercise` 的目录。在
8992
`config-exercise` 目录中,创建名为 `config-demo` 的文件,其内容为:
9093

9194
```yaml
@@ -139,16 +142,16 @@ kubectl config --kubeconfig=config-demo set-credentials developer --client-certi
139142
kubectl config --kubeconfig=config-demo set-credentials experimenter --username=exp --password=some-password
140143
```
141144

145+
{{< note >}}
142146
<!--
143147
- To delete a user you can run `kubectl --kubeconfig=config-demo config unset users.<name>`
144148
- To remove a cluster, you can run `kubectl --kubeconfig=config-demo config unset clusters.<name>`
145149
- To remove a context, you can run `kubectl --kubeconfig=config-demo config unset contexts.<name>`
146150
-->
147-
148-
注意:
149151
- 要删除用户,可以运行 `kubectl --kubeconfig=config-demo config unset users.<name>`
150152
- 要删除集群,可以运行 `kubectl --kubeconfig=config-demo config unset clusters.<name>`
151153
- 要删除上下文,可以运行 `kubectl --kubeconfig=config-demo config unset contexts.<name>`
154+
{{< /note >}}
152155

153156
<!--
154157
Add context details to your configuration file:
@@ -165,7 +168,7 @@ kubectl config --kubeconfig=config-demo set-context exp-scratch --cluster=scratc
165168
Open your `config-demo` file to see the added details. As an alternative to opening the
166169
`config-demo` file, you can use the `config view` command.
167170
-->
168-
打开 `config-demo` 文件查看添加的详细信息。 也可以使用 `config view`
171+
打开 `config-demo` 文件查看添加的详细信息。也可以使用 `config view`
169172
命令进行查看:
170173

171174
```shell
@@ -355,7 +358,7 @@ kubectl config --kubeconfig=config-demo view --minify
355358
In your `config-exercise` directory, create a file named `config-demo-2` with this content:
356359
-->
357360

358-
## 创建第二个配置文件
361+
## 创建第二个配置文件 {#create-a-second-configuration-file}
359362

360363
在 `config-exercise` 目录中,创建名为 `config-demo-2` 的文件,其中包含以下内容:
361364

@@ -384,7 +387,7 @@ See whether you have an environment variable named `KUBECONFIG`. If so, save the
384387
current value of your `KUBECONFIG` environment variable, so you can restore it later.
385388
For example:
386389
-->
387-
## 设置 KUBECONFIG 环境变量
390+
## 设置 KUBECONFIG 环境变量 {#set-the-kubeconfig-environment-variable}
388391

389392
查看是否有名为 `KUBECONFIG` 的环境变量。
390393
如有,保存 `KUBECONFIG` 环境变量当前的值,以便稍后恢复。
@@ -414,12 +417,12 @@ Temporarily append two paths to your `KUBECONFIG` environment variable. For exam
414417
在 Windows 中以分号分隔。
415418
如果有 `KUBECONFIG` 环境变量,请熟悉列表中的配置文件。
416419

417-
临时添加两条路径到 `KUBECONFIG` 环境变量中。 例如:
420+
临时添加两条路径到 `KUBECONFIG` 环境变量中。例如:
418421

419422
### Linux
420423

421424
```shell
422-
export KUBECONFIG=$KUBECONFIG:config-demo:config-demo-2
425+
export KUBECONFIG=$KUBECONFIG:config-demo:config-demo-2
423426
```
424427

425428
### Windows PowerShell
@@ -489,7 +492,7 @@ Go to `$HOME/.kube`, and see what files are there. Typically, there is a file na
489492
`config`. There might also be other configuration files in this directory. Briefly
490493
familiarize yourself with the contents of these files.
491494
-->
492-
## 探索 $HOME/.kube 目录
495+
## 探索 $HOME/.kube 目录 {#explore-the-home-kube-directory}
493496

494497
如果用户已经拥有一个集群,可以使用 `kubectl` 与集群进行交互,
495498
那么很可能在 `$HOME/.kube` 目录下有一个名为 `config` 的文件。
@@ -504,7 +507,7 @@ If you have a `$HOME/.kube/config` file, and it's not already listed in your
504507
`KUBECONFIG` environment variable, append it to your `KUBECONFIG` environment variable now.
505508
For example:
506509
-->
507-
## 将 $HOME/.kube/config 追加到 KUBECONFIG 环境变量中
510+
## 将 $HOME/.kube/config 追加到 KUBECONFIG 环境变量中 {#append-home-kube-config-to-your-kubeconfig-environment-variable}
508511

509512
如果有 `$HOME/.kube/config` 文件,并且还未列在 `KUBECONFIG` 环境变量中,
510513
那么现在将它追加到 `KUBECONFIG` 环境变量中。
@@ -535,11 +538,11 @@ kubectl config view
535538
<!--
536539
## Clean up
537540

538-
Return your `KUBECONFIG` environment variable to its original value. For example:
541+
Return your `KUBECONFIG` environment variable to its original value. For example:<br>
539542
-->
540-
## 清理
543+
## 清理 {#clean-up}
541544

542-
将 `KUBECONFIG` 环境变量还原为原始值。 例如:
545+
将 `KUBECONFIG` 环境变量还原为原始值。例如:
543546

544547
### Linux
545548

content/zh/docs/tasks/administer-cluster/quota-api-object.md

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ object.
3434
Create a namespace so that the resources you create in this exercise are
3535
isolated from the rest of your cluster.
3636
-->
37-
## 创建命名空间
37+
## 创建命名空间 {#create-a-namespace}
3838

3939
创建一个命名空间以便本例中创建的资源和集群中的其余部分相隔离。
4040

@@ -47,7 +47,7 @@ kubectl create namespace quota-object-example
4747
4848
Here is the configuration file for a ResourceQuota object:
4949
-->
50-
## 创建 ResourceQuota
50+
## 创建 ResourceQuota {#create-a-resourcequota}
5151

5252
下面是一个 ResourceQuota 对象的配置文件:
5353

@@ -96,7 +96,7 @@ status:
9696
9797
Here is the configuration file for a PersistentVolumeClaim object:
9898
-->
99-
## 创建 PersistentVolumeClaim
99+
## 创建 PersistentVolumeClaim {#create-a-persistentvolumeclaim}
100100
101101
下面是一个 PersistentVolumeClaim 对象的配置文件:
102102
@@ -135,7 +135,7 @@ pvc-quota-demo Pending
135135
136136
Here is the configuration file for a second PersistentVolumeClaim:
137137
-->
138-
## 尝试创建第二个 PersistentVolumeClaim
138+
## 尝试创建第二个 PersistentVolumeClaim {#attempt-to-create-a-second-persistentvolumeclaim}
139139

140140
下面是第二个 PersistentVolumeClaim 的配置文件:
141141

@@ -147,8 +147,9 @@ Attempt to create the second PersistentVolumeClaim:
147147
尝试创建第二个 PersistentVolumeClaim:
148148

149149
```shell
150-
kubectl create -f https://k8s.io/examples/admin/resource/quota-objects-pvc-2.yaml --namespace=quota-object-example
150+
kubectl apply -f https://k8s.io/examples/admin/resource/quota-objects-pvc-2.yaml --namespace=quota-object-example
151151
```
152+
152153
<!--
153154
The output shows that the second PersistentVolumeClaim was not created,
154155
because it would have exceeded the quota for the namespace.
@@ -167,11 +168,14 @@ used: persistentvolumeclaims=1, limited: persistentvolumeclaims=1
167168
These are the strings used to identify API resources that can be constrained
168169
by quotas:
169170
-->
170-
## 说明
171+
## 说明 {#notes}
171172

172173
下面这些字符串可被用来标识那些能被配额限制的 API 资源:
173174

174175
<table>
176+
<!--
177+
<tr><th>String</th><th>API Object</th></tr>
178+
-->
175179
<tr><th>字符串</th><th>API 对象</th></tr>
176180
<tr><td>"pods"</td><td>Pod</td></tr>
177181
<tr><td>"services"</td><td>Service</td></tr>
@@ -180,7 +184,13 @@ by quotas:
180184
<tr><td>"secrets"</td><td>Secret</td></tr>
181185
<tr><td>"configmaps"</td><td>ConfigMap</td></tr>
182186
<tr><td>"persistentvolumeclaims"</td><td>PersistentVolumeClaim</td></tr>
187+
<!--
188+
<tr><td>"services.nodeports"</td><td>Service of type NodePort</td></tr>
189+
-->
183190
<tr><td>"services.nodeports"</td><td>NodePort 类型的 Service</td></tr>
191+
<!--
192+
<tr><td>"services.loadbalancers"</td><td>Service of type LoadBalancer</td></tr>
193+
-->
184194
<tr><td>"services.loadbalancers"</td><td>LoadBalancer 类型的 Service</td></tr>
185195
</table>
186196

@@ -189,7 +199,7 @@ by quotas:
189199
190200
Delete your namespace:
191201
-->
192-
## 清理
202+
## 清理 {#clean-up}
193203

194204
删除你的命名空间:
195205

@@ -202,20 +212,20 @@ kubectl delete namespace quota-object-example
202212
<!--
203213
### For cluster administrators
204214
205-
* [Configure Default Memory Requests and Limits for a Namespace](/docs/tasks/administer-cluster/memory-default-namespace/)
215+
* [Configure Default Memory Requests and Limits for a Namespace](/docs/tasks/administer-cluster/manage-resources/memory-default-namespace/)
206216
207-
* [Configure Default CPU Requests and Limits for a Namespace](/docs/tasks/administer-cluster/cpu-default-namespace/)
217+
* [Configure Default CPU Requests and Limits for a Namespace](/docs/tasks/administer-cluster/manage-resources/cpu-default-namespace/)
208218
209-
* [Configure Minimum and Maximum Memory Constraints for a Namespace](/docs/tasks/administer-cluster/memory-constraint-namespace/)
219+
* [Configure Minimum and Maximum Memory Constraints for a Namespace](/docs/tasks/administer-cluster/manage-resources/memory-constraint-namespace/)
210220
211-
* [Configure Minimum and Maximum CPU Constraints for a Namespace](/docs/tasks/administer-cluster/cpu-constraint-namespace/)
221+
* [Configure Minimum and Maximum CPU Constraints for a Namespace](/docs/tasks/administer-cluster/manage-resources/cpu-constraint-namespace/)
212222
213-
* [Configure Memory and CPU Quotas for a Namespace](/docs/tasks/administer-cluster/quota-memory-cpu-namespace/)
223+
* [Configure Memory and CPU Quotas for a Namespace](/docs/tasks/administer-cluster/manage-resources/quota-memory-cpu-namespace/)
214224
215-
* [Configure a Pod Quota for a Namespace](/docs/tasks/administer-cluster/quota-pod-namespace/)
225+
* [Configure a Pod Quota for a Namespace](/docs/tasks/administer-cluster/manage-resources/quota-pod-namespace/)
216226
-->
217227

218-
### 集群管理员参考
228+
### 集群管理员参考 {#for-cluster-administrators}
219229

220230
* [为命名空间配置默认的内存请求和限制](/zh/docs/tasks/administer-cluster/manage-resources/memory-default-namespace/)
221231
* [为命名空间配置默认的 CPU 请求和限制](/zh/docs/tasks/administer-cluster/manage-resources/cpu-default-namespace/)
@@ -234,7 +244,7 @@ kubectl delete namespace quota-object-example
234244
* [Configure Quality of Service for Pods](/docs/tasks/configure-pod-container/quality-service-pod/)
235245
-->
236246

237-
### 应用开发者参考
247+
### 应用开发者参考 {#for-app-developers}
238248

239249
* [为容器和 Pod 分配内存资源](/zh/docs/tasks/configure-pod-container/assign-memory-resource/)
240250
* [为容器和 Pod 分配 CPU 资源](/zh/docs/tasks/configure-pod-container/assign-cpu-resource/)

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ v1beta1.metrics.k8s.io
7878
Create a namespace so that the resources you create in this exercise are
7979
isolated from the rest of your cluster.
8080
-->
81-
## 创建命名空间
81+
## 创建命名空间 {#create-a-namespace}
8282

8383
创建一个命名空间,以便将本练习中创建的资源与集群的其余部分隔离。
8484

@@ -96,7 +96,7 @@ In this exercise, you create a Pod that has one Container. The Container has a m
9696
request of 100 MiB and a memory limit of 200 MiB. Here's the configuration file
9797
for the Pod:
9898
-->
99-
## 指定内存请求和限制
99+
## 指定内存请求和限制 {#specify-a-memory-request-and-a-memory-limit}
100100

101101
要为容器指定内存请求,请在容器资源清单中包含 `resources:requests` 字段。
102102
同理,要指定内存限制,请包含 `resources:limits`
@@ -196,7 +196,7 @@ its limit, the Container becomes a candidate for termination. If the Container c
196196
consume memory beyond its limit, the Container is terminated. If a terminated Container can be
197197
restarted, the kubelet restarts it, as with any other type of runtime failure.
198198
-->
199-
## 超过容器限制的内存
199+
## 超过容器限制的内存 {#exceed-a-container-s-memory-limit}
200200

201201
当节点拥有足够的可用内存时,容器可以使用其请求的内存。
202202
但是,容器不允许使用超过其限制的内存。
@@ -260,7 +260,7 @@ The output shows that the Container was killed because it is out of memory (OOM)
260260
-->
261261
输出结果显示:由于内存溢出(OOM),容器已被杀掉:
262262

263-
```shell
263+
```yaml
264264
lastState:
265265
terminated:
266266
containerID: 65183c1877aaec2e8427bc95609cc52677a454b56fcb24340dbd22917c23b10f
@@ -352,7 +352,7 @@ of a Pod as having a memory request and limit. The memory request for the Pod is
352352
sum of the memory requests for all the Containers in the Pod. Likewise, the memory
353353
limit for the Pod is the sum of the limits of all the Containers in the Pod.
354354
-->
355-
## 超过整个节点容量的内存
355+
## 超过整个节点容量的内存 {#specify-a-memory-request-that-is-too-big-for-your-nodes}
356356

357357
内存请求和限制是与容器关联的,但将 Pod 视为具有内存请求和限制,也是很有用的。
358358
Pod 的内存请求是 Pod 中所有容器的内存请求之和。
@@ -419,7 +419,7 @@ The output shows that the Container cannot be scheduled because of insufficient
419419
-->
420420
输出结果显示:由于节点内存不足,该容器无法被调度:
421421

422-
```shell
422+
```
423423
Events:
424424
... Reason Message
425425
------ -------
@@ -433,14 +433,14 @@ The memory resource is measured in bytes. You can express memory as a plain inte
433433
fixed-point integer with one of these suffixes: E, P, T, G, M, K, Ei, Pi, Ti, Gi, Mi, Ki.
434434
For example, the following represent approximately the same value:
435435
-->
436-
## 内存单位
436+
## 内存单位 {#memory-units}
437437

438438
内存资源的基本单位是字节(byte)。你可以使用这些后缀之一,将内存表示为
439439
纯整数或定点整数:E、P、T、G、M、K、Ei、Pi、Ti、Gi、Mi、Ki。
440440
例如,下面是一些近似相同的值:
441441

442-
```shell
443-
128974848, 129e6, 129M , 123Mi
442+
```
443+
128974848, 129e6, 129M, 123Mi
444444
```
445445

446446
<!--
@@ -457,7 +457,7 @@ kubectl delete pod memory-demo-3 --namespace=mem-example
457457
458458
If you do not specify a memory limit for a Container, one of the following situations applies:
459459
-->
460-
## 如果你没有指定内存限制
460+
## 如果你没有指定内存限制 {#if-you-do-not-specify-a-memory-limit}
461461

462462
如果你没有为一个容器指定内存限制,则自动遵循以下情况之一:
463463

@@ -486,7 +486,7 @@ cluster, you can make efficient use of the memory resources available on your cl
486486
Nodes. By keeping a Pod's memory request low, you give the Pod a good chance of being
487487
scheduled. By having a memory limit that is greater than the memory request, you accomplish two things:
488488
-->
489-
## 内存请求和限制的目的
489+
## 内存请求和限制的目的 {#motivation-for-memory-requests-and-limits}
490490

491491
通过为集群中运行的容器配置内存请求和限制,你可以有效利用集群节点上可用的内存资源。
492492
通过将 Pod 的内存请求保持在较低水平,你可以更好地安排 Pod 调度。
@@ -504,7 +504,7 @@ scheduled. By having a memory limit that is greater than the memory request, you
504504
505505
Delete your namespace. This deletes all the Pods that you created for this task:
506506
-->
507-
## 清理
507+
## 清理 {#clean-up}
508508

509509
删除命名空间。下面的命令会删除你根据这个任务创建的所有 Pod:
510510

@@ -521,7 +521,7 @@ kubectl delete namespace mem-example
521521
522522
* [Configure Quality of Service for Pods](/docs/tasks/configure-pod-container/quality-service-pod/)
523523
-->
524-
### 应用开发者扩展阅读
524+
### 应用开发者扩展阅读 {#for-app-developers}
525525

526526
* [为容器和 Pod 分配 CPU 资源](/zh/docs/tasks/configure-pod-container/assign-cpu-resource/)
527527

@@ -545,7 +545,7 @@ kubectl delete namespace mem-example
545545
546546
* [Configure Quotas for API Objects](/docs/tasks/administer-cluster/quota-api-object/)
547547
-->
548-
### 集群管理员扩展阅读
548+
### 集群管理员扩展阅读 {#for-cluster-administrators}
549549

550550
* [为命名空间配置默认的内存请求和限制](/zh/docs/tasks/administer-cluster/manage-resources/memory-default-namespace/)
551551
* [为命名空间配置默认的 CPU 请求和限制](/zh/docs/tasks/administer-cluster/manage-resources/cpu-default-namespace/)

0 commit comments

Comments
 (0)