Skip to content

Commit 8bcb39b

Browse files
authored
Merge pull request #40446 from windsonsea/minikuy
[zh] sync /access-application-cluster/ingress-minikube.md
2 parents 270ae5f + 7106bda commit 8bcb39b

File tree

1 file changed

+61
-105
lines changed

1 file changed

+61
-105
lines changed

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

Lines changed: 61 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ min-kubernetes-server-version: 1.19
77
<!--
88
title: Set up Ingress on Minikube with the NGINX Ingress Controller
99
content_type: task
10-
weight: 100
10+
weight: 110
1111
min-kubernetes-server-version: 1.19
1212
-->
1313

@@ -31,32 +31,28 @@ Ingress 中所设置的规则。
3131

3232
## {{% heading "prerequisites" %}}
3333

34+
<!--
35+
This tutorial assumes that you are using `minikube` to run a local Kubernetes cluster.
36+
Visit [Install tools](/docs/tasks/tools/#minikube) to learn how to install `minikube`.
37+
-->
38+
本教程假设你正在使用 `minikube` 运行一个本地 Kubernetes 集群。
39+
参阅[安装工具](/zh-cn/docs/tasks/tools/#minikube)了解如何安装 `minikube`
40+
3441
{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
42+
3543
<!--
3644
If you are using an older Kubernetes version, switch to the documentation for that version.
3745
-->
3846
如果你使用的是较早的 Kubernetes 版本,请切换到该版本的文档。
3947

40-
<!-- steps -->
41-
4248
<!--
43-
### Create a Minikube cluster
49+
### Create a minikube cluster
4450
45-
Using Katacoda
46-
: {{< kat-button >}}
47-
48-
Locally
49-
: If you already [installed Minikube](/docs/tasks/tools/#minikube)
50-
locally, run `minikube start` to create a cluster.
51+
If you haven't already set up a cluster locally, run `minikube start` to create a cluster.
5152
-->
5253
### 创建一个 Minikube 集群 {#create-minikube-cluster}
5354

54-
使用 Katacoda
55-
: {{< kat-button >}}
56-
57-
本地
58-
: 如果已经在本地[安装 Minikube](/zh-cn/docs/tasks/tools/#minikube)
59-
请运行 `minikube start` 创建一个集群。
55+
如果你还未在本地搭建集群,运行 `minikube start` 创建集群。
6056

6157
<!-- steps -->
6258

@@ -65,7 +61,7 @@ Locally
6561
6662
1. To enable the NGINX Ingress controller, run the following command:
6763
-->
68-
## 启用 Ingress 控制器
64+
## 启用 Ingress 控制器 {#enable-ingress-controller}
6965

7066
1. 为了启用 NGINIX Ingress 控制器,可以运行下面的命令:
7167

@@ -78,9 +74,6 @@ Locally
7874
-->
7975
2. 检查验证 NGINX Ingress 控制器处于运行状态:
8076

81-
{{< tabs name="tab_with_md" >}}
82-
{{% tab name="minikube v1.19 或更高版本" %}}
83-
8477
```shell
8578
kubectl get pods -n ingress-nginx
8679
```
@@ -104,43 +97,6 @@ Locally
10497
ingress-nginx-controller-59b45fb494-26npt 1/1 Running 0 11m
10598
```
10699

107-
{{% /tab %}}
108-
{{% tab name="minikube v1.18.1 或更早版本" %}}
109-
110-
```shell
111-
kubectl get pods -n kube-system
112-
```
113-
114-
{{< note >}}
115-
<!--
116-
It can take up to a minute before you see these pods running OK.
117-
-->
118-
最多可能需要等待一分钟才能看到这些 Pod 运行正常。
119-
{{< /note >}}
120-
121-
<!--
122-
The output is similar to:
123-
-->
124-
输出类似于:
125-
126-
```none
127-
NAME READY STATUS RESTARTS AGE
128-
default-http-backend-59868b7dd6-xb8tq 1/1 Running 0 1m
129-
kube-addon-manager-minikube 1/1 Running 0 3m
130-
kube-dns-6dcb57bcc8-n4xd4 3/3 Running 0 2m
131-
kubernetes-dashboard-5498ccf677-b8p5h 1/1 Running 0 2m
132-
nginx-ingress-controller-5984b97644-rnkrg 1/1 Running 0 1m
133-
storage-provisioner 1/1 Running 0 2m
134-
```
135-
136-
<!--
137-
Make sure that you see a Pod with a name that starts with `nginx-ingress-controller-`.
138-
-->
139-
请确保可以在输出中看到一个名称以 `nginx-ingress-controller-` 为前缀的 Pod。
140-
141-
{{% /tab %}}
142-
{{< /tabs >}}
143-
144100
<!--
145101
## Deploy a hello, world app
146102
@@ -218,17 +174,6 @@ Locally
218174
http://172.17.0.15:31637
219175
```
220176

221-
{{< note >}}
222-
<!--
223-
Katacoda environment only: at the top of the terminal panel, click the plus sign,
224-
and then click **Select port to view on Host 1**. Enter the NodePort value,
225-
in this case `31637`, and then click **Display Port**.
226-
-->
227-
如果使用的是 Katacoda 环境,在终端面板顶端,请点击加号标志。
228-
然后点击 **Select port to view on Host 1**
229-
输入节点和端口号(这里是`31637`),之后点击 **Display Port**
230-
{{< /note >}}
231-
232177
<!--
233178
The output is similar to:
234179
-->
@@ -255,7 +200,7 @@ The following manifest defines an Ingress that sends traffic to your Service via
255200
256201
1. Create `example-ingress.yaml` from the following file:
257202
-->
258-
## 创建一个 Ingress
203+
## 创建一个 Ingress {#create-ingress}
259204

260205
下面是一个定义 Ingress 的配置文件,负责通过 `hello-world.info`
261206
将请求转发到你的服务。
@@ -308,38 +253,13 @@ The following manifest defines an Ingress that sends traffic to your Service via
308253
example-ingress <none> hello-world.info 172.17.0.15 80 38s
309254
```
310255

311-
<!--
312-
1. Add the following line to the bottom of the `/etc/hosts` file on
313-
your computer (you will need administrator access):
314-
-->
315-
4.`/etc/hosts` 文件的末尾添加以下内容(需要管理员访问权限):
316-
317-
```none
318-
172.17.0.15 hello-world.info
319-
```
320-
321-
{{< note >}}
322-
<!--
323-
If you are running Minikube locally, use `minikube ip` to get the external IP.
324-
The IP address displayed within the ingress list will be the internal IP.
325-
-->
326-
如果你在本地运行 Minikube 环境,需要使用 `minikube ip` 获得外部 IP 地址。
327-
Ingress 列表中显示的 IP 地址会是内部 IP 地址。
328-
{{< /note >}}
329-
330-
<!--
331-
After you make this change, your web browser sends requests for
332-
`hello-world.info` URLs to Minikube.
333-
-->
334-
添加完成后,在浏览器中访问 URL `hello-world.info`,请求将被发送到 Minikube。
335-
336256
<!--
337257
1. Verify that the Ingress controller is directing traffic:
338258
-->
339-
5. 验证 Ingress 控制器能够转发请求流量:
259+
4. 验证 Ingress 控制器能够转发请求流量:
340260

341261
```shell
342-
curl hello-world.info
262+
curl --resolve "hello-world.info:80:$( minikube ip )" -i http://hello-world.info
343263
```
344264

345265
<!--
@@ -353,12 +273,48 @@ The following manifest defines an Ingress that sends traffic to your Service via
353273
Hostname: web-55b8c6998d-8k564
354274
```
355275

356-
{{< note >}}
357276
<!--
358-
If you are running Minikube locally, you can visit `hello-world.info` from your browser.
277+
You can also visit `hello-world.info` from your browser.
278+
279+
* **Optionally**
280+
281+
Look up the external IP address as reported by minikube:
359282
-->
360-
如果你在使用本地 Minikube 环境,你可以从浏览器中访问 hello-world.info。
361-
{{< /note >}}
283+
284+
你也可以从浏览器访问 `hello-world.info`
285+
286+
* **可选**
287+
288+
查看 Minikube 报告的外部 IP 地址:
289+
290+
```shell
291+
minikube ip
292+
```
293+
294+
<!--
295+
Add line similar to the following one to the bottom of the `/etc/hosts` file on
296+
your computer (you will need administrator access):
297+
-->
298+
299+
将类似以下这一行添加到你计算机上的 `/etc/hosts` 文件的末尾(需要管理员访问权限):
300+
301+
```none
302+
172.17.0.15 hello-world.info
303+
```
304+
305+
{{< note >}}
306+
<!--
307+
Change the IP address to match the output from `minikube ip`.
308+
-->
309+
更改 IP 地址以匹配 `minikube ip` 的输出。
310+
{{< /note >}}
311+
312+
<!--
313+
After you make this change, your web browser sends requests for
314+
`hello-world.info` URLs to Minikube.
315+
-->
316+
317+
更改完成后,在浏览器中访问 URL `hello-world.info`,请求将被发送到 Minikube。
362318

363319
<!--
364320
## Create a second Deployment
@@ -448,7 +404,7 @@ The following manifest defines an Ingress that sends traffic to your Service via
448404
1. 访问 Hello World 应用的第一个版本:
449405

450406
```shell
451-
curl hello-world.info
407+
curl --resolve "hello-world.info:80:$( minikube ip )" -i http://hello-world.info
452408
```
453409

454410
<!--
@@ -468,7 +424,7 @@ The following manifest defines an Ingress that sends traffic to your Service via
468424
2. 访问 Hello World 应用的第二个版本:
469425

470426
```shell
471-
curl hello-world.info/v2
427+
curl --resolve "hello-world.info:80:$( minikube ip )" -i http://hello-world.info/v2
472428
```
473429

474430
<!--
@@ -484,10 +440,10 @@ The following manifest defines an Ingress that sends traffic to your Service via
484440

485441
{{< note >}}
486442
<!--
487-
If you are running Minikube locally, you can visit `hello-world.info` and
443+
If you did the optional step to update `/etc/hosts`, you can also visit `hello-world.info` and
488444
`hello-world.info/v2` from your browser.
489445
-->
490-
如果你在本地运行 Minikube 环境,你可以使用浏览器来访问
446+
如果你执行了更新 `/etc/hosts` 的可选步骤,你也可以从你的浏览器中访问
491447
`hello-world.info``hello-world.info/v2`
492448
{{< /note >}}
493449

@@ -500,4 +456,4 @@ The following manifest defines an Ingress that sends traffic to your Service via
500456
-->
501457
* 进一步了解 [Ingress](/zh-cn/docs/concepts/services-networking/ingress/)
502458
* 进一步了解 [Ingress 控制器](/zh-cn/docs/concepts/services-networking/ingress-controllers/)
503-
* 进一步了解 [服务](/zh-cn/docs/concepts/services-networking/service/)
459+
* 进一步了解[服务](/zh-cn/docs/concepts/services-networking/service/)

0 commit comments

Comments
 (0)