@@ -7,7 +7,7 @@ min-kubernetes-server-version: 1.19
7
7
<!--
8
8
title: Set up Ingress on Minikube with the NGINX Ingress Controller
9
9
content_type: task
10
- weight: 100
10
+ weight: 110
11
11
min-kubernetes-server-version: 1.19
12
12
-->
13
13
@@ -31,32 +31,28 @@ Ingress 中所设置的规则。
31
31
32
32
## {{% heading "prerequisites" %}}
33
33
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
+
34
41
{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
42
+
35
43
<!--
36
44
If you are using an older Kubernetes version, switch to the documentation for that version.
37
45
-->
38
46
如果你使用的是较早的 Kubernetes 版本,请切换到该版本的文档。
39
47
40
- <!-- steps -->
41
-
42
48
<!--
43
- ### Create a Minikube cluster
49
+ ### Create a minikube cluster
44
50
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.
51
52
-->
52
53
### 创建一个 Minikube 集群 {#create-minikube-cluster}
53
54
54
- 使用 Katacoda
55
- : {{< kat-button >}}
56
-
57
- 本地
58
- : 如果已经在本地[ 安装 Minikube] ( /zh-cn/docs/tasks/tools/#minikube ) ,
59
- 请运行 ` minikube start ` 创建一个集群。
55
+ 如果你还未在本地搭建集群,运行 ` minikube start ` 创建集群。
60
56
61
57
<!-- steps -->
62
58
@@ -65,7 +61,7 @@ Locally
65
61
66
62
1. To enable the NGINX Ingress controller, run the following command:
67
63
-->
68
- ## 启用 Ingress 控制器
64
+ ## 启用 Ingress 控制器 {#enable-ingress-controller}
69
65
70
66
1 . 为了启用 NGINIX Ingress 控制器,可以运行下面的命令:
71
67
@@ -78,9 +74,6 @@ Locally
78
74
-->
79
75
2 . 检查验证 NGINX Ingress 控制器处于运行状态:
80
76
81
- {{< tabs name="tab_with_md" >}}
82
- {{% tab name="minikube v1.19 或更高版本" %}}
83
-
84
77
``` shell
85
78
kubectl get pods -n ingress-nginx
86
79
```
@@ -104,43 +97,6 @@ Locally
104
97
ingress-nginx-controller-59b45fb494-26npt 1/1 Running 0 11m
105
98
```
106
99
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
-
144
100
<!--
145
101
## Deploy a hello, world app
146
102
@@ -218,17 +174,6 @@ Locally
218
174
http://172.17.0.15:31637
219
175
```
220
176
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
-
232
177
<!--
233
178
The output is similar to:
234
179
-->
@@ -255,7 +200,7 @@ The following manifest defines an Ingress that sends traffic to your Service via
255
200
256
201
1. Create `example-ingress.yaml` from the following file:
257
202
-->
258
- ## 创建一个 Ingress
203
+ ## 创建一个 Ingress {#create-ingress}
259
204
260
205
下面是一个定义 Ingress 的配置文件,负责通过 ` hello-world.info `
261
206
将请求转发到你的服务。
@@ -308,38 +253,13 @@ The following manifest defines an Ingress that sends traffic to your Service via
308
253
example-ingress <none> hello-world.info 172.17.0.15 80 38s
309
254
```
310
255
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
-
336
256
<!--
337
257
1. Verify that the Ingress controller is directing traffic:
338
258
-->
339
- 5 . 验证 Ingress 控制器能够转发请求流量:
259
+ 4 . 验证 Ingress 控制器能够转发请求流量:
340
260
341
261
``` shell
342
- curl hello-world.info
262
+ curl --resolve " hello-world.info:80: $( minikube ip ) " -i http:// hello-world.info
343
263
```
344
264
345
265
<!--
@@ -353,12 +273,48 @@ The following manifest defines an Ingress that sends traffic to your Service via
353
273
Hostname: web-55b8c6998d-8k564
354
274
```
355
275
356
- {{< note >}}
357
276
<!--
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:
359
282
-->
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。
362
318
363
319
< ! --
364
320
# # Create a second Deployment
@@ -448,7 +404,7 @@ The following manifest defines an Ingress that sends traffic to your Service via
448
404
1. 访问 Hello World 应用的第一个版本:
449
405
450
406
` ` ` shell
451
- curl hello-world.info
407
+ curl --resolve " hello-world.info:80: $( minikube ip ) " -i http:// hello-world.info
452
408
` ` `
453
409
454
410
< ! --
@@ -468,7 +424,7 @@ The following manifest defines an Ingress that sends traffic to your Service via
468
424
2. 访问 Hello World 应用的第二个版本:
469
425
470
426
` ` ` shell
471
- curl hello-world.info/v2
427
+ curl --resolve " hello-world.info:80: $( minikube ip ) " -i http:// hello-world.info/v2
472
428
` ` `
473
429
474
430
< ! --
@@ -484,10 +440,10 @@ The following manifest defines an Ingress that sends traffic to your Service via
484
440
485
441
{{< note > }}
486
442
< ! --
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
488
444
` hello-world.info/v2` from your browser.
489
445
-->
490
- 如果你在本地运行 Minikube 环境,你可以使用浏览器来访问
446
+ 如果你执行了更新 ` /etc/hosts ` 的可选步骤,你也可以从你的浏览器中访问
491
447
` hello-world.info` 和 ` hello-world.info/v2` 。
492
448
{{< /note > }}
493
449
@@ -500,4 +456,4 @@ The following manifest defines an Ingress that sends traffic to your Service via
500
456
-->
501
457
* 进一步了解 [Ingress](/zh-cn/docs/concepts/services-networking/ingress/)
502
458
* 进一步了解 [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