Skip to content

Commit 11124d0

Browse files
authored
Merge pull request #34838 from windsonsea/fppwq
[zh-cn] Improve fine-parallel-processing-work-queue.md
2 parents 687b645 + 7d9c9c7 commit 11124d0

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

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

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ min-kubernetes-server-version: v1.8
1717
In this example, we will run a Kubernetes Job with multiple parallel
1818
worker processes in a given pod.
1919
-->
20-
在这个例子中,我们会运行一个Kubernetes Job,其中的 Pod 会运行多个并行工作进程。
20+
在这个例子中,我们会运行一个 Kubernetes Job,其中的 Pod 会运行多个并行工作进程。
2121

2222
<!--
2323
In this example, as each pod is created, it picks up one unit of work
2424
from a task queue, processes it, and repeats until the end of the queue is reached.
2525
2626
Here is an overview of the steps in this example:
2727
-->
28-
在这个例子中,当每个pod被创建时,它会从一个任务队列中获取一个工作单元,处理它,然后重复,直到到达队列的尾部。
28+
在这个例子中,当每个 Pod 被创建时,它会从一个任务队列中获取一个工作单元,处理它,然后重复,直到到达队列的尾部。
2929

3030
下面是这个示例的步骤概述:
3131

@@ -54,7 +54,7 @@ Here is an overview of the steps in this example:
5454
1. **Start a Job that works on tasks from the queue**. The Job starts several pods. Each pod takes
5555
one task from the message queue, processes it, and repeats until the end of the queue is reached.
5656
-->
57-
3. **启动一个 Job 对队列中的任务进行处理**。这个 Job 启动了若干个 Pod
57+
3. **启动一个 Job 对队列中的任务进行处理**。这个 Job 启动了若干个 Pod。
5858
每个 Pod 从消息队列中取出一个工作任务,处理它,然后重复,直到到达队列的尾部。
5959

6060
## {{% heading "prerequisites" %}}
@@ -104,13 +104,15 @@ Start a temporary interactive pod for running the Redis CLI.
104104
-->
105105
## 使用任务填充队列
106106

107-
现在,让我们往队列里添加一些“任务”。在这个例子中,我们的任务是一些将被打印出来的字符串。
107+
现在,让我们往队列里添加一些 “任务”。在这个例子中,我们的任务是一些将被打印出来的字符串。
108108

109-
启动一个临时的可交互的 pod 用于运行 Redis 命令行界面。
109+
启动一个临时的可交互的 Pod 用于运行 Redis 命令行界面。
110110

111111
```shell
112112
kubectl run -i --tty temp --image redis --command "/bin/sh"
113113
```
114+
115+
输出类似于:
114116
```
115117
Waiting for pod default/redis2-c7h78 to be running, status is Pending, pod ready: false
116118
Hit enter for command prompt
@@ -119,7 +121,7 @@ Hit enter for command prompt
119121
<!--
120122
Now hit enter, start the redis CLI, and create a list with some work items in it.
121123
-->
122-
现在按回车键,启动 redis 命令行界面,然后创建一个存在若干个工作项的列表。
124+
现在按回车键,启动 Redis 命令行界面,然后创建一个存在若干个工作项的列表。
123125

124126
```shell
125127
# redis-cli -h redis
@@ -178,17 +180,17 @@ called rediswq.py ([Download](/examples/application/job/redis/rediswq.py)).
178180
-->
179181
## 创建镜像
180182

181-
现在我们已经准备好创建一个我们要运行的镜像
183+
现在我们已经准备好创建一个我们要运行的镜像
182184

183-
我们会使用一个带有 redis 客户端的 python 工作程序从消息队列中读出消息。
185+
我们会使用一个带有 Redis 客户端的 Python 工作程序从消息队列中读出消息。
184186

185-
这里提供了一个简单的 Redis 工作队列客户端库, rediswq.py ([下载](/examples/application/job/redis/rediswq.py))。
187+
这里提供了一个简单的 Redis 工作队列客户端库,名为 rediswq.py ([下载](/examples/application/job/redis/rediswq.py))。
186188

187189
<!--
188190
The "worker" program in each Pod of the Job uses the work queue
189191
client library to get work. Here it is:
190192
-->
191-
Job 中每个 Pod 内的 “工作程序” 使用工作队列客户端库获取工作。如下
193+
Job 中每个 Pod 内的 “工作程序” 使用工作队列客户端库获取工作。具体如下
192194

193195
{{< codenew language="python" file="application/job/redis/worker.py" >}}
194196

@@ -235,7 +237,7 @@ your app image with your project ID, and push to GCR. Replace
235237
`<project>` with your project ID.
236238
-->
237239
如果你使用的是 [Google Container Registry](https://cloud.google.com/tools/container-registry/)
238-
请先用你的 project ID 给你的镜像打上标签,然后 push 到 GCR 。请将 `<project>` 替换为你自己的 project ID
240+
请先用你的 project ID 给你的镜像打上标签,然后 push 到 GCR 。请将 `<project>` 替换为你自己的 project ID
239241

240242
```shell
241243
docker tag job-wq-2 gcr.io/<project>/job-wq-2
@@ -249,15 +251,15 @@ Here is the job definition:
249251
-->
250252
## 定义一个 Job
251253

252-
这是 job 定义:
254+
这是 Job 定义:
253255

254256
{{< codenew file="application/job/redis/job.yaml" >}}
255257

256258
<!--
257259
Be sure to edit the job template to
258260
change `gcr.io/myproject` to your own path.
259261
-->
260-
请确保将 job 模板中的 `gcr.io/myproject` 更改为你自己的路径。
262+
请确保将 Job 模板中的 `gcr.io/myproject` 更改为你自己的路径。
261263

262264
<!--
263265
In this example, each pod works on several items from the queue and then exits when there are no more items.
@@ -268,12 +270,12 @@ exits with success, the controller knows the work is done, and the Pods will exi
268270
So, we set the completion count of the Job to 1. The job controller will wait for the other pods to complete
269271
too.
270272
-->
271-
在这个例子中,每个 pod 处理了队列中的多个项目,直到队列中没有项目时便退出。
273+
在这个例子中,每个 Pod 处理了队列中的多个项目,直到队列中没有项目时便退出。
272274
因为是由工作程序自行检测工作队列是否为空,并且 Job 控制器不知道工作队列的存在,
273275
这依赖于工作程序在完成工作时发出信号。
274276
工作程序以成功退出的形式发出信号表示工作队列已经为空。
275277
所以,只要有任意一个工作程序成功退出,控制器就知道工作已经完成了,所有的 Pod 将很快会退出。
276-
因此,我们将 Job 的完成计数(Completion Count)设置为 1
278+
因此,我们将 Job 的完成计数(Completion Count)设置为 1。
277279
尽管如此,Job 控制器还是会等待其它 Pod 完成。
278280

279281
<!--
@@ -283,7 +285,7 @@ So, now run the Job:
283285
-->
284286
## 运行 Job
285287

286-
现在运行这个 Job
288+
现在运行这个 Job:
287289

288290
```shell
289291
kubectl apply -f ./job.yaml
@@ -325,12 +327,13 @@ Events:
325327
33s 33s 1 {job-controller } Normal SuccessfulCreate Created pod: job-wq-2-lglf8
326328
```
327329

328-
查看日志
330+
运行以下命令查看日志
329331

330332
```shell
331333
kubectl logs pods/job-wq-2-7r7b2
332334
```
333335

336+
日志类似于:
334337
```
335338
Worker with sessionID: bbd72d0a-9e5c-4dd6-abf6-416cc267991f
336339
Initial queue state: empty=False
@@ -342,7 +345,7 @@ Working on lemon
342345
<!--
343346
As you can see, one of our pods worked on several work units.
344347
-->
345-
你可以看到,其中的一个 pod 处理了若干个工作单元。
348+
你可以看到,其中的一个 Pod 处理了若干个工作单元。
346349

347350
<!-- discussion -->
348351

0 commit comments

Comments
 (0)