@@ -31,13 +31,13 @@ You must be able to log in to the SSH service on the remote server.
31
31
<!--
32
32
## Task context
33
33
-->
34
- ## 任务上下文
34
+ ## 任务上下文 {#task-context}
35
35
36
+ {{< note >}}
36
37
<!--
37
38
This example tunnels traffic using SSH, with the SSH client and server acting as a SOCKS proxy.
38
39
You can instead use any other kind of [SOCKS5](https://en.wikipedia.org/wiki/SOCKS#SOCKS5) proxies.
39
40
-->
40
- {{< note >}}
41
41
此示例使用 SSH 隧道传输流量,SSH 客户端和服务器充当 SOCKS 代理。
42
42
你可以使用其他任意类型的 [ SOCKS5] ( https://zh.wikipedia.org/wiki/SOCKS#SOCKS5 ) 代理代替。
43
43
{{</ note >}}
@@ -53,11 +53,12 @@ Figure 1 represents what you're going to achieve in this task.
53
53
-->
54
54
图 1 表示你将在此任务中实现的目标。
55
55
56
- * 你有一台在后面的步骤中被称为本地计算机的客户端计算机,你将在这台计算机上创建与 Kubernetes API 对话的请求。
56
+ * 你有一台在后面的步骤中被称为本地计算机的客户端计算机,你将在这台计算机上创建与
57
+ Kubernetes API 对话的请求。
57
58
* Kubernetes 服务器/API 托管在远程服务器上。
58
59
* 你将使用 SSH 客户端和服务器软件在本地和远程服务器之间创建安全的 SOCKS5 隧道。
59
- 客户端和 Kubernetes API 之间的 HTTPS 流量将流经 SOCKS5 隧道,该隧道本身通过 SSH 进行隧道传输。
60
-
60
+ 客户端和 Kubernetes API 之间的 HTTPS 流量将流经 SOCKS5 隧道,该隧道本身通过
61
+ SSH 进行隧道传输。
61
62
62
63
<!--
63
64
graph LR;
@@ -108,13 +109,12 @@ Figure 1. SOCKS5 tutorial components
108
109
109
110
<!--
110
111
## Using ssh to create a SOCKS5 proxy
111
- -->
112
- ## 使用 ssh 创建 SOCKS5 代理
113
112
114
- <!--
115
113
This command starts a SOCKS5 proxy between your client machine and the remote server.
116
114
The SOCKS5 proxy lets you connect to your cluster's API server.
117
115
-->
116
+ ## 使用 SSH 创建 SOCKS5 代理
117
+
118
118
此命令在你的客户端计算机和远程服务器之间启动一个 SOCKS5 代理。
119
119
SOCKS5 代理允许你连接到集群的 API 服务器。
120
120
136
136
137
137
<!--
138
138
## Client configuration
139
- -->
140
- ## 客户端配置
141
139
142
- <!--
143
140
To explore the Kubernetes API you'll first need to instruct your clients to send their queries through
144
141
the SOCKS5 proxy we created earlier.
145
142
146
143
For command-line tools, set the `https_proxy` environment variable and pass it to commands that you run.
147
144
-->
148
- 要探索 Kubernetes API,你首先需要指示你的客户端通过我们之前创建的 SOCKS5 代理发送他们的查询。
145
+ ## 客户端配置
146
+
147
+ 要探索 Kubernetes API,你首先需要指示你的客户端通过我们之前创建的 SOCKS5
148
+ 代理发送他们的查询。
149
149
对于命令行工具,设置 ` https_proxy ` 环境变量并将其传递给你运行的命令。
150
150
151
151
``` shell
@@ -155,22 +155,21 @@ export https_proxy=socks5h://localhost:1080
155
155
<!--
156
156
When you set the `https_proxy` variable, tools such as `curl` route HTTPS traffic through the proxy
157
157
you configured. For this to work, the tool must support SOCKS5 proxying.
158
+ -->
159
+ 当你设置 ` https_proxy ` 变量时,` curl ` 等工具会通过你配置的代理路由 HTTPS 流量。
160
+ 为此,该工具必须支持 SOCKS5 代理。
158
161
159
162
{{< note >}}
163
+ <!--
160
164
In the URL https://localhost/api, `localhost` does not refer to your local client computer.
161
- Instead, it refers to the endpoint on the remote server knows as `localhost`.
165
+ Instead, it refers to the endpoint on the remote server known as `localhost`.
162
166
The `curl` tool sends the hostname from the HTTPS URL over SOCKS, and the remote server
163
167
resolves that locally (to an address that belongs to its loopback interface).
164
- {{</ note >}}
165
168
-->
166
- 当你设置 ` https_proxy ` 变量时,` curl ` 等工具会通过你配置的代理路由 HTTPS 流量。
167
- 为此,该工具必须支持 SOCKS5 代理。
168
-
169
- {{< note >}}
170
169
在 URL https://localhost/api 中,` localhost ` 不是指你的本地客户端计算机。
171
170
它指的是远程服务器上称为 “localhost” 的端点。
172
171
` curl ` 工具通过 SOCKS 从 HTTPS URL 发送主机名,远程服务器在本地解析(到属于其环回接口的地址)。
173
- {{</ note >}}
172
+ {{< / note >}}
174
173
175
174
``` shell
176
175
curl -k -v https://localhost/api
@@ -187,9 +186,11 @@ for the relevant `cluster` entry within your `~/.kube/config` file. For example
187
186
apiVersion : v1
188
187
clusters :
189
188
- cluster :
190
- certificate-authority-data : LRMEMMW2 # 为了便于阅读缩短
191
- server : https://localhost # 上图中的“Kubernetes API”
192
- proxy-url : socks5://localhost:1080 # 上图中的“SSH SOCKS5代理”(内置DNS解析)
189
+ certificate-authority-data : LRMEMMW2 # 简化以便阅读
190
+ # “Kubernetes API”服务器,换言之,kubernetes-remote-server.example 的 IP 地址
191
+ server : https://<API_SERVER_IP_ADRESS>:6443
192
+ # 上图中的“SSH SOCKS5代理”(内置 DNS 解析)
193
+ proxy-url : socks5://localhost:1080
193
194
name : default
194
195
contexts :
195
196
- context :
@@ -202,8 +203,8 @@ preferences: {}
202
203
users :
203
204
- name : default
204
205
user :
205
- client-certificate-data : LS0tLS1CR== # 为了便于阅读缩短
206
- client-key-data : LS0tLS1CRUdJT= # 为了便于阅读缩短
206
+ client-certificate-data : LS0tLS1CR== # 节略,为了便于阅读
207
+ client-key-data : LS0tLS1CRUdJT= # 节略,为了便于阅读
207
208
` ` `
208
209
209
210
<!--
@@ -223,24 +224,23 @@ kube-system coredns-85cb69466-klwq8 1/1 Running 0
223
224
224
225
<!--
225
226
# # Clean up
226
- -->
227
- # # 清理
228
227
229
- <!--
230
228
Stop the ssh port-forwarding process by pressing `CTRL+C` on the terminal where it is running.
231
229
232
230
Type `unset https_proxy` in a terminal to stop forwarding http traffic through the proxy.
233
231
-->
234
- 通过在运行它的终端上按“CTRL+C”来停止 ssh 端口转发进程。
232
+ # # 清理
233
+
234
+ 通过在运行它的终端上按 “CTRL+C” 来停止 SSH 端口转发进程。
235
235
236
236
在终端中键入 `unset https_proxy` 以停止通过代理转发 http 流量。
237
237
238
238
<!--
239
239
# # Further reading
240
- -->
241
- # # 进一步阅读
242
240
243
- <!--
244
241
* [OpenSSH remote login client](https://man.openbsd.org/ssh)
245
242
-->
246
- * [OpenSSH远程登录客户端](https://man.openbsd.org/ssh)
243
+ # # 进一步阅读
244
+
245
+ * [OpenSSH远程登录客户端](https://man.openbsd.org/ssh)
246
+
0 commit comments