Skip to content

Commit 97408b7

Browse files
authored
Merge pull request #34230 from tengqm/zh-portforward
[zh] Resync port-forward page
2 parents adbc59a + 1dc7437 commit 97408b7

File tree

1 file changed

+39
-34
lines changed

1 file changed

+39
-34
lines changed

content/zh-cn/docs/tasks/access-application-cluster/port-forward-access-application-cluster.md

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ for database debugging.
2222
## {{% heading "prerequisites" %}}
2323

2424
* {{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
25-
2625
<!--
2726
* Install [MongoDB Shell](https://www.mongodb.com/try/download/shell).
2827
-->
@@ -46,7 +45,7 @@ for database debugging.
4645
<!--
4746
The output of a successful command verifies that the deployment was created:
4847
-->
49-
查看输出是否成功,以验证是否成功创建 deployment
48+
成功执行的命令的输出可以证明创建了 Deployment
5049

5150
```
5251
deployment.apps/mongo created
@@ -94,8 +93,7 @@ for database debugging.
9493
The Deployment automatically manages a ReplicaSet.
9594
View the ReplicaSet status using:
9695
-->
97-
Deployment 自动管理 ReplicaSet。
98-
查看 ReplicaSet 状态:
96+
该 Deployment 自动管理一个 ReplicaSet。查看该 ReplicaSet 的状态:
9997

10098
```shell
10199
kubectl get replicaset
@@ -104,7 +102,7 @@ for database debugging.
104102
<!--
105103
The output displays that the ReplicaSet was created:
106104
-->
107-
输出显示创建的 ReplicaSet:
105+
输出显示 ReplicaSet 已被创建
108106

109107
```
110108
NAME DESIRED CURRENT READY AGE
@@ -123,7 +121,7 @@ for database debugging.
123121
<!--
124122
The output of a successful command verifies that the Service was created:
125123
-->
126-
查看输出是否成功,以验证是否成功创建 Service:
124+
成功执行的命令的输出可以证明 Service 已经被创建
127125

128126
```
129127
service/mongo created
@@ -132,7 +130,7 @@ for database debugging.
132130
<!--
133131
Check the Service created:
134132
-->
135-
检查 Service 是否创建
133+
检查所创建的 Service:
136134

137135
```shell
138136
kubectl get service mongo
@@ -141,7 +139,7 @@ for database debugging.
141139
<!--
142140
The output displays the service created:
143141
-->
144-
输出显示创建的 Service:
142+
输出显示已被创建的 Service:
145143

146144
```
147145
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
@@ -151,41 +149,53 @@ for database debugging.
151149
<!--
152150
3. Verify that the MongoDB server is running in the Pod, and listening on port 27017:
153151
-->
154-
3. 验证 MongoDB 服务是否运行在 Pod 中并且监听 27017 端口
152+
3. 验证 MongoDB 服务是否运行在 Pod 中并且在 27017 端口上监听
155153

154+
<!--
156155
```shell
157156
# Change mongo-75f59d57f4-4nd6q to the name of the Pod
158157
kubectl get pod mongo-75f59d57f4-4nd6q --template='{{(index (index .spec.containers 0).ports 0).containerPort}}{{"\n"}}'
159158
```
159+
-->
160+
```shell
161+
# 将 mongo-75f59d57f4-4nd6q 改为 Pod 的名称
162+
kubectl get pod mongo-75f59d57f4-4nd6q --template='{{(index (index .spec.containers 0).ports 0).containerPort}}{{"\n"}}'
163+
```
160164

161165
<!--
162166
The output displays the port for MongoDB in that Pod:
163167
-->
164-
输出应该显示 Pod 中 MongoDB 的端口:
168+
输出应该显示对应 Pod 中 MongoDB 的端口:
165169

166170
```
167171
27017
168172
```
169173

170174
<!--
171-
(this is the TCP port allocated to MongoDB on the internet).
175+
27017 is the TCP port allocated to MongoDB on the internet.
172176
-->
173-
(这是 Internet 分配给 MongoDB TCP 端口
177+
27017 是分配给 MongoDB 的互联网 TCP 端口。
174178

175179
<!--
176180
## Forward a local port to a port on the Pod
177181
178-
1. `kubectl port-forward` allows using resource name, such as a pod name, to select a matching pod to port forward to.
182+
1. `kubectl port-forward` allows using resource name, such as a pod name, to select a matching pod to port forward to.
179183
-->
180184
## 转发一个本地端口到 Pod 端口
181185

182186
1. `kubectl port-forward` 允许使用资源名称
183187
(例如 pod 名称)来选择匹配的 pod 来进行端口转发。
184188

189+
<!--
185190
```shell
186191
# Change mongo-75f59d57f4-4nd6q to the name of the Pod
187192
kubectl port-forward mongo-75f59d57f4-4nd6q 28015:27017
188193
```
194+
-->
195+
```shell
196+
# 将 mongo-75f59d57f4-4nd6q 改为 Pod 的名称
197+
kubectl port-forward mongo-75f59d57f4-4nd6q 28015:27017
198+
```
189199

190200
<!--
191201
which is the same as
@@ -220,30 +230,25 @@ for database debugging.
220230
<!--
221231
Any of the above commands works. The output is similar to this:
222232
-->
223-
以上所有命令都应该有效。输出应该类似于
233+
以上所有命令都有效。输出类似于
224234

225235
```
226236
Forwarding from 127.0.0.1:28015 -> 27017
227237
Forwarding from [::1]:28015 -> 27017
228238
```
229-
<!--
230-
{{< note >}}
231-
232-
`kubectl port-forward` does not return. To continue with the exercises, you will need to open another terminal.
233-
234-
{{< /note >}}
235-
-->
236-
{{< note >}}
237239
238-
`kubectl port-forward` 不会返回。你需要打开另一个终端来继续这个练习。
239-
240-
{{< /note >}}
240+
{{< note >}}
241+
<!--
242+
`kubectl port-forward` does not return. To continue with the exercises, you will need to open another terminal.
243+
-->
244+
`kubectl port-forward` 不会返回。你需要打开另一个终端来继续这个练习。
245+
{{< /note >}}
241246
242247
243248
<!--
244-
2. Start the MongoDB command line interface:
249+
2. Start the MongoDB command line interface:
245250
-->
246-
2. 启动 MongoDB 命令行接口:
251+
2. 启动 MongoDB 命令行接口:
247252
248253
```shell
249254
mongosh --port 28015
@@ -278,7 +283,7 @@ the local port and thus relieve you from having to manage local port conflicts,
278283
the slightly simpler syntax:
279284
-->
280285
如果你不需要指定特定的本地端口,你可以让 `kubectl` 来选择和分配本地端口,
281-
以便你不需要管理本地端口冲突。该命令使用稍微不同的语法:
286+
这样你就不需要管理本地端口冲突。该命令使用稍微不同的语法:
282287

283288
```shell
284289
kubectl port-forward deployment/mongo :27017
@@ -288,8 +293,8 @@ kubectl port-forward deployment/mongo :27017
288293
The `kubectl` tool finds a local port number that is not in use (avoiding low ports numbers,
289294
because these might be used by other applications). The output is similar to:
290295
-->
291-
`kubectl` 工具会找到一个未被使用的本地端口号(避免使用低段位的端口号,因为他们可能会被其他应用程序使用)。
292-
输出应该类似于
296+
`kubectl` 工具会找到一个未被使用的本地端口号(避免使用低段位的端口号,
297+
因为他们可能会被其他应用程序使用)。输出类似于
293298

294299
```
295300
Forwarding from 127.0.0.1:63753 -> 27017
@@ -307,19 +312,19 @@ local workstation to debug the database that is running in the Pod.
307312
-->
308313
## 讨论 {#discussion}
309314

310-
与本地 28015 端口建立的连接将转发到运行 MongoDB 服务器的 Pod 的 27017 端口。
315+
与本地 28015 端口建立的连接将被转发到运行 MongoDB 服务器的 Pod 的 27017 端口。
311316
通过此连接,你可以使用本地工作站来调试在 Pod 中运行的数据库。
312317

318+
{{< note >}}
313319
<!--
314320
`kubectl port-forward` is implemented for TCP ports only.
315321
The support for UDP protocol is tracked in
316322
[issue 47862](https://github.com/kubernetes/kubernetes/issues/47862).
317323
-->
318-
{{< warning >}}
319-
`kubectl port-forward` 仅适用于 TCP 端口。
324+
`kubectl port-forward` 仅实现了 TCP 端口 支持。
320325
[issue 47862](https://github.com/kubernetes/kubernetes/issues/47862)
321326
中跟踪了对 UDP 协议的支持。
322-
{{< /warning >}}
327+
{{< /note >}}
323328

324329
## {{% heading "whatsnext" %}}
325330

0 commit comments

Comments
 (0)