Skip to content

Commit c8bee3d

Browse files
authored
Merge pull request #35571 from yanrongshi/zh-cn]Sync-coarse-parallel-processing-work-queue.md
[zh-cn]Update coarse-parallel-processing-work-queue.md
2 parents 0499442 + 66f9650 commit c8bee3d

File tree

1 file changed

+27
-18
lines changed

1 file changed

+27
-18
lines changed

content/zh-cn/docs/tasks/job/coarse-parallel-processing-work-queue.md

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ Here is an overview of the steps in this example:
5050

5151
<!--
5252
Be familiar with the basic,
53-
non-parallel, use of [Job](/docs/concepts/jobs/run-to-completion-finite-workloads/).
53+
non-parallel, use of [Job](/docs/concepts/workloads/controllers/job/).
5454
-->
5555

5656
要熟悉 Job 基本用法(非并行的),请参考
5757
[Job](/zh-cn/docs/concepts/workloads/controllers/job/)
5858

59-
{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
59+
{{< include "task-tutorial-prereqs.md" >}}
6060

6161
<!-- steps -->
6262

@@ -70,7 +70,7 @@ cluster and reuse it for many jobs, as well as for long-running services.
7070
7171
Start RabbitMQ as follows:
7272
-->
73-
## 启动消息队列服务
73+
## 启动消息队列服务 {#starting-a-message-queue-service}
7474

7575
本例使用了 RabbitMQ,但你可以更改该示例,使用其他 AMQP 类型的消息服务。
7676

@@ -108,7 +108,7 @@ and experiment with queues.
108108
109109
First create a temporary interactive Pod.
110110
-->
111-
## 测试消息队列服务
111+
## 测试消息队列服务 {#testing-the-message-queue-service}
112112

113113
现在,我们可以试着访问消息队列。我们将会创建一个临时的可交互的 Pod,在它上面安装一些工具,然后用队列做实验。
114114

@@ -154,7 +154,7 @@ Next, we will check that we can discover the rabbitmq service:
154154
# Note the rabbitmq-service has a DNS name, provided by Kubernetes:
155155
-->
156156
```
157-
# 请注意 rabbitmq-service 有Kubernetes 提供的 DNS 名称
157+
# 请注意 rabbitmq-service 拥有一个由 Kubernetes 提供的 DNS 名称
158158
159159
root@temp-loe07:/# nslookup rabbitmq-service
160160
Server: 10.0.0.10
@@ -196,8 +196,6 @@ Next we will verify we can create a queue, and publish and consume messages.
196196
# then use this command instead:
197197
# root@temp-loe07:/# BROKER_URL=amqp://guest:guest@$RABBITMQ_SERVICE_SERVICE_HOST:5672
198198
# Now create a queue:
199-
# and publish a message to it:
200-
# and get it back.
201199
-->
202200

203201
```shell
@@ -246,7 +244,7 @@ In a practice, the content of the messages might be:
246244
- configuration parameters to a simulation
247245
- frame numbers of a scene to be rendered
248246
-->
249-
## 为队列增加任务
247+
## 为队列增加任务 {#filling-the-queue-with-tasks}
250248

251249
现在让我们给队列增加一些任务。在我们的示例中,任务是多个待打印的字符串。
252250

@@ -268,7 +266,9 @@ For our example, we will create the queue and fill it using the amqp command lin
268266
In practice, you might write a program to fill the queue using an amqp client library.
269267
-->
270268

271-
本例中,如果有大量的数据需要被 Job 的所有 Pod 读取,典型的做法是把它们放在一个共享文件系统中,如NFS,并以只读的方式挂载到所有 Pod,或者 Pod 中的程序从类似 HDFS 的集群文件系统中读取。
269+
本例中,如果有大量的数据需要被 Job 的所有 Pod 读取,典型的做法是把它们放在一个共享文件系统中,
270+
如 NFS(Network File System 网络文件系统),并以只读的方式挂载到所有 Pod,或者 Pod 中的程序从类似 HDFS
271+
(Hadoop Distributed File System 分布式文件系统)的集群文件系统中读取。
272272

273273
例如,我们创建队列并使用 amqp 命令行工具向队列中填充消息。实践中,你可以写个程序来利用 amqp 客户端库来填充这些队列。
274274

@@ -294,14 +294,24 @@ example program:
294294
-->
295295
这样,我们给队列中填充了8个消息。
296296

297-
## 创建镜像
297+
## 创建镜像 {#create-an-image}
298298

299299
现在我们可以创建一个做为 Job 来运行的镜像。
300300

301301
我们将用 `amqp-consume` 来从队列中读取消息并实际运行我们的程序。这里给出一个非常简单的示例程序:
302302

303303
{{< codenew language="python" file="application/job/rabbitmq/worker.py" >}}
304304

305+
<!--
306+
Give the script execution permission:
307+
-->
308+
赋予脚本执行权限:
309+
310+
```shell
311+
chmod +x worker.py
312+
```
313+
314+
305315
<!--
306316
Now, build an image. If you are working in the source
307317
tree, then change directory to `examples/job/work-queue-1`.
@@ -355,7 +365,7 @@ gcloud docker -- push gcr.io/<project>/job-wq-1
355365
Here is a job definition. You'll need to make a copy of the Job and edit the
356366
image to match the name you used, and call it `./job.yaml`.
357367
-->
358-
## 定义 Job
368+
## 定义 Job {#defining-a-job}
359369

360370
这里给出一个 Job 定义 yaml文件。你需要拷贝一份并编辑镜像以匹配你使用的名称,保存为 `./job.yaml`
361371

@@ -372,18 +382,17 @@ So, now run the Job:
372382
-->
373383
本例中,每个 Pod 使用队列中的一个消息然后退出。这样,Job 的完成计数就代表了完成的工作项的数量。本例中我们设置 `.spec.completions: 8`,因为我们放了8项内容在队列中。
374384

375-
## 运行 Job
385+
## 运行 Job {#running-the-job}
376386

377387
现在我们运行 Job:
378388

379389
```shell
380-
kubectl create -f ./job.yaml
390+
kubectl apply -f ./job.yaml
381391
```
382392

383393
<!--
384394
Now wait a bit, then check on the job.
385395
-->
386-
387396
稍等片刻,然后检查 Job。
388397

389398
```shell
@@ -441,9 +450,9 @@ do not need to modify your "worker" program to be aware that there is a work que
441450
442451
It does require that you run a message queue service.
443452
If running a queue service is inconvenient, you may
444-
want to consider one of the other [job patterns](/docs/concepts/jobs/run-to-completion-finite-workloads/#job-patterns).
453+
want to consider one of the other [job patterns](/docs/concepts/workloads/controllers/job/#job-patterns).
445454
-->
446-
## 替代方案
455+
## 替代方案 {#alternatives}
447456

448457
本文所讲述的处理方法的好处是你不需要修改你的 "worker" 程序使其知道工作队列的存在。
449458

@@ -455,7 +464,7 @@ This approach creates a pod for every work item. If your work items only take a
455464
though, creating a Pod for every work item may add a lot of overhead. Consider another
456465
[example](/docs/tasks/job/fine-parallel-processing-work-queue/), that executes multiple work items per Pod.
457466
458-
In this example, we used use the `amqp-consume` utility to read the message
467+
In this example, we use the `amqp-consume` utility to read the message
459468
from the queue and run our actual program. This has the advantage that you
460469
do not need to modify your program to be aware of the queue.
461470
A [different example](/docs/tasks/job/fine-parallel-processing-work-queue/), shows how to
@@ -489,7 +498,7 @@ exits with success, or if the node crashes before the kubelet is able to post th
489498
back to the api-server, then the Job will not appear to be complete, even though all items
490499
in the queue have been processed.
491500
-->
492-
## 友情提醒
501+
## 友情提醒 {#caveats}
493502

494503
如果设置的完成数量小于队列中的消息数量,会导致一部分消息项不会被执行。
495504

0 commit comments

Comments
 (0)