2
2
title : 使用端口转发来访问集群中的应用
3
3
content_type : task
4
4
weight : 40
5
+ min-kubernetes-server-version : v1.10
5
6
---
6
7
7
8
<!--
8
9
title: Use Port Forwarding to Access Applications in a Cluster
9
10
content_type: task
10
11
weight: 40
12
+ min-kubernetes-server-version: v1.10
11
13
-->
12
14
13
15
<!-- overview -->
@@ -16,8 +18,8 @@ This page shows how to use `kubectl port-forward` to connect to a MongoDB
16
18
server running in a Kubernetes cluster. This type of connection can be useful
17
19
for database debugging.
18
20
-->
19
- 本文展示如何使用 ` kubectl port-forward ` 连接到在 Kubernetes 集群中
20
- 运行的 MongoDB 服务。 这种类型的连接对数据库调试很有用。
21
+ 本文展示如何使用 ` kubectl port-forward ` 连接到在 Kubernetes 集群中运行的 MongoDB 服务。
22
+ 这种类型的连接对数据库调试很有用。
21
23
22
24
## {{% heading "prerequisites" %}}
23
25
@@ -34,9 +36,9 @@ for database debugging.
34
36
35
37
1. Create a Deployment that runs MongoDB:
36
38
-->
37
- ## 创建 MongoDB deployment 和服务
39
+ ## 创建 MongoDB Deployment 和服务
38
40
39
- 1 . 创建一个运行 MongoDB 的 deployment :
41
+ 1 . 创建一个运行 MongoDB 的 Deployment :
40
42
41
43
``` shell
42
44
kubectl apply -f https://k8s.io/examples/application/mongodb/mongo-deployment.yaml
@@ -54,7 +56,7 @@ for database debugging.
54
56
<!--
55
57
View the pod status to check that it is ready:
56
58
-->
57
- 查看 pod 状态,检查其是否准备就绪:
59
+ 查看 Pod 状态,检查其是否准备就绪:
58
60
59
61
``` shell
60
62
kubectl get pods
@@ -63,7 +65,7 @@ for database debugging.
63
65
<!--
64
66
The output displays the pod created:
65
67
-->
66
- 输出显示创建的 pod :
68
+ 输出显示创建的 Pod :
67
69
68
70
```
69
71
NAME READY STATUS RESTARTS AGE
@@ -149,7 +151,7 @@ for database debugging.
149
151
<!--
150
152
3. Verify that the MongoDB server is running in the Pod, and listening on port 27017:
151
153
-->
152
- 3 . 验证 MongoDB 服务是否运行在 Pod 中并且在 27017 端口上监听 :
154
+ 3 . 验证 MongoDB 服务是否运行在 Pod 中并且在监听 27017 端口 :
153
155
154
156
<!--
155
157
```shell
@@ -184,7 +186,7 @@ for database debugging.
184
186
## 转发一个本地端口到 Pod 端口
185
187
186
188
1 . ` kubectl port-forward ` 允许使用资源名称
187
- (例如 pod 名称)来选择匹配的 pod 来进行端口转发。
189
+ (例如 Pod 名称)来选择匹配的 Pod 来进行端口转发。
188
190
189
191
<!--
190
192
```shell
0 commit comments