Skip to content

Commit 4aea751

Browse files
authored
Merge pull request #46250 from my-git9/pt-8714
[zh-cn] sync ingress-minikube.md
2 parents 040f544 + 4ff5b27 commit 4aea751

File tree

1 file changed

+233
-15
lines changed

1 file changed

+233
-15
lines changed

content/zh-cn/docs/tasks/access-application-cluster/ingress-minikube.md

Lines changed: 233 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,18 @@ Visit [Install tools](/docs/tasks/tools/#minikube) to learn how to install `mini
3838
本教程假设你正在使用 `minikube` 运行一个本地 Kubernetes 集群。
3939
参阅[安装工具](/zh-cn/docs/tasks/tools/#minikube)了解如何安装 `minikube`
4040

41+
{{< note >}}
42+
<!--
43+
This tutorial uses a container that requires the AMD64 architecture.
44+
If you are using minikube on a computer with a different CPU architecture,
45+
you could try using minikube with a driver that can emulate AMD64.
46+
For example, the Docker Desktop driver can do this.
47+
-->
48+
本教程使用需要 AMD64 架构的容器。
49+
如果你在其他 CPU 架构的计算机上使用 minikube,可以尝试使用带有可以模拟 AMD64 的驱动程序的 minikube。
50+
例如,Docker Desktop 驱动程序可以执行此操作。
51+
{{< /note >}}
52+
4153
{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
4254

4355
<!--
@@ -119,6 +131,24 @@ If you haven't already set up a cluster locally, run `minikube start` to create
119131
deployment.apps/web created
120132
```
121133

134+
<!--
135+
Verify that the Deployment is in a Ready state:
136+
-->
137+
验证 Deployment 是否处于 Ready 状态:
138+
139+
```shell
140+
kubectl get deployment web
141+
```
142+
<!--
143+
The output should be similar to:
144+
-->
145+
输出应类似于:
146+
147+
```none
148+
NAME READY UP-TO-DATE AVAILABLE AGE
149+
web 1/1 1 1 53s
150+
```
151+
122152
<!--
123153
1. Expose the Deployment:
124154
-->
@@ -157,9 +187,14 @@ If you haven't already set up a cluster locally, run `minikube start` to create
157187
```
158188

159189
<!--
160-
1. Visit the Service via NodePort:
190+
1. Visit the Service via NodePort, using the [`minikube service`](https://minikube.sigs.k8s.io/docs/handbook/accessing/#using-minikube-service-with-tunnel) command. Follow the instructions for your platform:
161191
-->
162-
4. 使用节点端口信息访问服务:
192+
4. 使用节点端口信息访问服务,使用
193+
[`minikube service`](https://minikube.sigs.k8s.io/docs/handbook/accessing/#using-minikube-service-with-tunnel) 命令。
194+
请按照适合你平台的说明进行操作:
195+
196+
{{< tabs name="minikube_service" >}}
197+
{{% tab name="Linux" %}}
163198

164199
```shell
165200
minikube service web --url
@@ -174,10 +209,49 @@ If you haven't already set up a cluster locally, run `minikube start` to create
174209
http://172.17.0.15:31637
175210
```
176211

212+
<!--
213+
Invoke the URL obtained in the output of the previous step:
214+
-->
215+
调用上一步输出中获取的 URL:
216+
177217
```shell
178218
curl http://172.17.0.15:31637
179219
```
180220

221+
{{% /tab %}}
222+
{{% tab name="MacOS" %}}
223+
224+
<!--
225+
# The command must be run in a separate terminal.
226+
-->
227+
```shell
228+
# 该命令必须在单独的终端中运行。
229+
minikube service web --url
230+
```
231+
232+
<!--
233+
The output is similar to:
234+
-->
235+
输出类似于:
236+
237+
```none
238+
http://127.0.0.1:62445
239+
! Because you are using a Docker driver on darwin, the terminal needs to be open to run it.
240+
```
241+
242+
<!--
243+
From a different terminal, invoke the URL obtained in the output of the previous step:
244+
-->
245+
从不同的终端调用在上一步的输出中获取的 URL:
246+
247+
```shell
248+
curl http://127.0.0.1:62445
249+
```
250+
251+
{{% /tab %}}
252+
{{< /tabs >}}
253+
<br>
254+
181255
<!--
182256
The output is similar to:
183257
-->
@@ -200,13 +274,13 @@ If you haven't already set up a cluster locally, run `minikube start` to create
200274
## Create an Ingress
201275
202276
The following manifest defines an Ingress that sends traffic to your Service via
203-
`hello-world.info`.
277+
`hello-world.example`.
204278
205279
1. Create `example-ingress.yaml` from the following file:
206280
-->
207281
## 创建一个 Ingress {#create-ingress}
208282

209-
下面是一个定义 Ingress 的配置文件,负责通过 `hello-world.info`
283+
下面是一个定义 Ingress 的配置文件,负责通过 `hello-world.example`
210284
将请求转发到你的服务。
211285

212286
1. 根据下面的 YAML 创建文件 `example-ingress.yaml`
@@ -253,19 +327,67 @@ The following manifest defines an Ingress that sends traffic to your Service via
253327
接下来你将会在 `ADDRESS` 列中看到 IPv4 地址,例如:
254328

255329
```none
256-
NAME CLASS HOSTS ADDRESS PORTS AGE
257-
example-ingress <none> hello-world.info 172.17.0.15 80 38s
330+
NAME CLASS HOSTS ADDRESS PORTS AGE
331+
example-ingress nginx hello-world.example 172.17.0.15 80 38s
258332
```
259333

260334
<!--
261-
1. Verify that the Ingress controller is directing traffic:
335+
1. Verify that the Ingress controller is directing traffic, by following the instructions for your platform:
262336
-->
263-
4. 验证 Ingress 控制器能够转发请求流量:
337+
4. 验证 Ingress 控制器能够转发请求流量,按照适用于所属平台的说明进行操作:
338+
339+
{{< note >}}
340+
<!--
341+
The network is limited if using the Docker driver on MacOS (Darwin) and the Node IP is not reachable directly. To get ingress to work you’ll need to open a new terminal and run `minikube tunnel`.
342+
`sudo` permission is required for it, so provide the password when prompted.
343+
-->
344+
如果在 MacOS(Darwin)上使用 Docker 驱动程序,网络会受到限制,并且无法直接访问节点 IP。
345+
要让 Ingress 正常工作,你需要打开一个新终端并运行 `minikube tunnel`
346+
此操作需要 `sudo` 权限,因此请在出现提示时提供密码。
347+
{{< /note >}}
348+
349+
{{< tabs name="ingress" >}}
350+
{{% tab name="Linux" %}}
264351

265352
```shell
266-
curl --resolve "hello-world.info:80:$( minikube ip )" -i http://hello-world.info
353+
curl --resolve "hello-world.example:80:$( minikube ip )" -i http://hello-world.example
354+
```
355+
356+
{{% /tab %}}
357+
{{% tab name="MacOS" %}}
358+
359+
```shell
360+
minikube tunnel
361+
```
362+
363+
<!--
364+
The output is similar to:
365+
-->
366+
输出类似于:
367+
368+
```none
369+
Tunnel successfully started
370+
371+
NOTE: Please do not close this terminal as this process must stay alive for the tunnel to be accessible ...
372+
373+
The service/ingress example-ingress requires privileged ports to be exposed: [80 443]
374+
sudo permission will be asked for it.
375+
Starting tunnel for service example-ingress.
267376
```
268377

378+
<!--
379+
From within a new terminal, invoke the following command:
380+
-->
381+
从新终端中调用以下命令:
382+
383+
```shell
384+
curl --resolve "hello-world.example:80:127.0.0.1" -i http://hello-world.example
385+
```
386+
387+
{{% /tab %}}
388+
{{< /tabs >}}
389+
<br>
390+
269391
<!--
270392
You should see:
271393
-->
@@ -307,10 +429,12 @@ The following manifest defines an Ingress that sends traffic to your Service via
307429
```
308430

309431
{{< note >}}
432+
310433
<!--
311434
Change the IP address to match the output from `minikube ip`.
312435
-->
313-
更改 IP 地址以匹配 `minikube ip` 的输出。
436+
437+
更改 IP 地址以匹配 `minikube ip` 的输出。
314438
{{< /note >}}
315439

316440
<!--
@@ -342,6 +466,25 @@ The following manifest defines an Ingress that sends traffic to your Service via
342466
deployment.apps/web2 created
343467
```
344468

469+
<!--
470+
Verify that the Deployment is in a Ready state:
471+
-->
472+
验证 Deployment 是否处于 Ready 状态:
473+
474+
```shell
475+
kubectl get deployment web2
476+
```
477+
478+
<!--
479+
The output should be similar to:
480+
-->
481+
输出应类似于:
482+
483+
```none
484+
NAME READY UP-TO-DATE AVAILABLE AGE
485+
web2 1/1 1 1 16s
486+
```
487+
345488
<!--
346489
1. Expose the second Deployment:
347490
-->
@@ -407,10 +550,48 @@ The following manifest defines an Ingress that sends traffic to your Service via
407550

408551
1. 访问 Hello World 应用的第一个版本:
409552

553+
{{< tabs name="ingress2-v1" >}}
554+
{{% tab name="Linux" %}}
555+
556+
```shell
557+
curl --resolve "hello-world.example:80:$( minikube ip )" -i http://hello-world.example
558+
```
559+
560+
{{% /tab %}}
561+
{{% tab name="MacOS" %}}
562+
563+
```shell
564+
minikube tunnel
565+
```
566+
567+
<!--
568+
The output is similar to:
569+
-->
570+
输出类似于:
571+
572+
```none
573+
Tunnel successfully started
574+
575+
NOTE: Please do not close this terminal as this process must stay alive for the tunnel to be accessible ...
576+
577+
The service/ingress example-ingress requires privileged ports to be exposed: [80 443]
578+
sudo permission will be asked for it.
579+
Starting tunnel for service example-ingress.
580+
```
581+
582+
<!--
583+
From within a new terminal, invoke the following command:
584+
-->
585+
从新终端中调用以下命令:
586+
410587
```shell
411-
curl --resolve "hello-world.info:80:$( minikube ip )" -i http://hello-world.info
588+
curl --resolve "hello-world.example:80:127.0.0.1" -i http://hello-world.example
412589
```
413590

591+
{{% /tab %}}
592+
{{< /tabs >}}
593+
<br>
594+
414595
<!--
415596
The output is similar to:
416597
-->
@@ -427,9 +608,46 @@ The following manifest defines an Ingress that sends traffic to your Service via
427608
-->
428609
2. 访问 Hello World 应用的第二个版本:
429610

611+
{{< tabs name="ingress2-v2" >}}
612+
{{% tab name="Linux" %}}
613+
614+
```shell
615+
curl --resolve "hello-world.example:80:$( minikube ip )" -i http://hello-world.example/v2
616+
```
617+
618+
{{% /tab %}}
619+
{{% tab name="MacOS" %}}
620+
430621
```shell
431-
curl --resolve "hello-world.info:80:$( minikube ip )" -i http://hello-world.info/v2
622+
minikube tunnel
432623
```
624+
625+
<!--
626+
The output is similar to:
627+
-->
628+
输出类似于:
629+
630+
```none
631+
Tunnel successfully started
632+
633+
NOTE: Please do not close this terminal as this process must stay alive for the tunnel to be accessible ...
634+
635+
The service/ingress example-ingress requires privileged ports to be exposed: [80 443]
636+
sudo permission will be asked for it.
637+
Starting tunnel for service example-ingress.
638+
```
639+
640+
<!--
641+
From within a new terminal, invoke the following command:
642+
-->
643+
从新终端中调用以下命令:
644+
645+
```shell
646+
curl --resolve "hello-world.example:80:127.0.0.1" -i http://hello-world.example/v2
647+
```
648+
649+
{{% /tab %}}
650+
{{< /tabs >}}
433651

434652
<!--
435653
The output is similar to:
@@ -444,11 +662,11 @@ The following manifest defines an Ingress that sends traffic to your Service via
444662

445663
{{< note >}}
446664
<!--
447-
If you did the optional step to update `/etc/hosts`, you can also visit `hello-world.info` and
448-
`hello-world.info/v2` from your browser.
665+
If you did the optional step to update `/etc/hosts`, you can also visit `hello-world.example` and
666+
`hello-world.example/v2` from your browser.
449667
-->
450668
如果你执行了更新 `/etc/hosts` 的可选步骤,你也可以从你的浏览器中访问
451-
`hello-world.info``hello-world.info/v2`
669+
`hello-world.example``hello-world.example/v2`
452670
{{< /note >}}
453671

454672
## {{% heading "whatsnext" %}}

0 commit comments

Comments
 (0)