[zh] sync translation of ingress minikube page (#31027)
* [zh] verification methods of different minikube versions of ingress * [zh] sync translation of ingress minikube content page * [zh] update translate comment struct
This commit is contained in:
@@ -2,11 +2,13 @@
|
|||||||
title: 在 Minikube 环境中使用 NGINX Ingress 控制器配置 Ingress
|
title: 在 Minikube 环境中使用 NGINX Ingress 控制器配置 Ingress
|
||||||
content_type: task
|
content_type: task
|
||||||
weight: 100
|
weight: 100
|
||||||
|
min-kubernetes-server-version: 1.19
|
||||||
---
|
---
|
||||||
<!--
|
<!--
|
||||||
title: Set up Ingress on Minikube with the NGINX Ingress Controller
|
title: Set up Ingress on Minikube with the NGINX Ingress Controller
|
||||||
content_type: task
|
content_type: task
|
||||||
weight: 100
|
weight: 100
|
||||||
|
min-kubernetes-server-version: 1.19
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<!-- overview -->
|
<!-- overview -->
|
||||||
@@ -25,31 +27,26 @@ This page shows you how to set up a simple Ingress which routes requests to Serv
|
|||||||
本节为你展示如何配置一个简单的 Ingress,根据 HTTP URI 将服务请求路由到
|
本节为你展示如何配置一个简单的 Ingress,根据 HTTP URI 将服务请求路由到
|
||||||
服务 `web` 或 `web2`。
|
服务 `web` 或 `web2`。
|
||||||
|
|
||||||
|
|
||||||
## {{% heading "prerequisites" %}}
|
## {{% heading "prerequisites" %}}
|
||||||
|
|
||||||
|
|
||||||
{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
|
{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
|
||||||
|
如果你使用的是较早的 Kubernetes 版本,请切换到该版本的文档。
|
||||||
|
|
||||||
<!-- steps -->
|
<!-- steps -->
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
## Create a Minikube cluster
|
### Create a Minikube cluster
|
||||||
|
|
||||||
1. Click **Launch Terminal**
|
|
||||||
-->
|
-->
|
||||||
## 创建一个 Minikube 集群
|
### 创建一个 Minikube 集群
|
||||||
|
|
||||||
1. 点击 **Launch Terminal**
|
使用 Katacoda
|
||||||
|
: {{< kat-button >}}
|
||||||
|
|
||||||
{{< kat-button >}}
|
本地
|
||||||
|
: 如果已经在本地[安装Minikube](/zh/docs/tasks/tools/#minikube),
|
||||||
<!--
|
请运行 `minikube start` 创建一个集群。
|
||||||
1. (Optional) If you installed Minikube locally, run the following command:
|
|
||||||
-->
|
|
||||||
2. (可选操作)如果你在本地安装了 Minikube,运行下面的命令:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
minikube start
|
|
||||||
```
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
## Enable the Ingress controller
|
## Enable the Ingress controller
|
||||||
@@ -70,26 +67,51 @@ This page shows you how to set up a simple Ingress which routes requests to Serv
|
|||||||
-->
|
-->
|
||||||
2. 检查验证 NGINX Ingress 控制器处于运行状态:
|
2. 检查验证 NGINX Ingress 控制器处于运行状态:
|
||||||
|
|
||||||
```shell
|
|
||||||
kubectl get pods -n kube-system
|
|
||||||
```
|
|
||||||
|
|
||||||
<!-- This can take up to a minute. -->
|
{{< tabs name="tab_with_md" >}}
|
||||||
{{< note >}}
|
{{% tab name="minikube v1.19 或更高版本" %}}
|
||||||
这一操作可能需要近一分钟时间。
|
```shell
|
||||||
{{< /note >}}
|
kubectl get pods -n ingress-nginx
|
||||||
|
```
|
||||||
|
<!-- It can take up to a minute before you see these pods running OK. -->
|
||||||
|
{{< note >}}最多可能需要等待一分钟才能看到这些 Pod 运行正常。{{< /note >}}
|
||||||
|
|
||||||
输出:
|
<!-- The output is similar to: -->
|
||||||
|
输出类似于:
|
||||||
|
|
||||||
```
|
```
|
||||||
NAME READY STATUS RESTARTS AGE
|
NAME READY STATUS RESTARTS AGE
|
||||||
default-http-backend-59868b7dd6-xb8tq 1/1 Running 0 1m
|
ingress-nginx-admission-create-g9g49 0/1 Completed 0 11m
|
||||||
kube-addon-manager-minikube 1/1 Running 0 3m
|
ingress-nginx-admission-patch-rqp78 0/1 Completed 1 11m
|
||||||
kube-dns-6dcb57bcc8-n4xd4 3/3 Running 0 2m
|
ingress-nginx-controller-59b45fb494-26npt 1/1 Running 0 11m
|
||||||
kubernetes-dashboard-5498ccf677-b8p5h 1/1 Running 0 2m
|
```
|
||||||
nginx-ingress-controller-5984b97644-rnkrg 1/1 Running 0 1m
|
{{% /tab %}}
|
||||||
storage-provisioner 1/1 Running 0 2m
|
{{% tab name="minikube v1.18.1 或更早版本" %}}
|
||||||
```
|
```shell
|
||||||
|
kubectl get pods -n kube-system
|
||||||
|
```
|
||||||
|
<!-- It can take up to a minute before you see these pods running OK. -->
|
||||||
|
{{< note >}}最多可能需要等待一分钟才能看到这些 Pod 运行正常。{{< /note >}}
|
||||||
|
|
||||||
|
<!-- The output is similar to: -->
|
||||||
|
输出类似于:
|
||||||
|
|
||||||
|
```
|
||||||
|
NAME READY STATUS RESTARTS AGE
|
||||||
|
default-http-backend-59868b7dd6-xb8tq 1/1 Running 0 1m
|
||||||
|
kube-addon-manager-minikube 1/1 Running 0 3m
|
||||||
|
kube-dns-6dcb57bcc8-n4xd4 3/3 Running 0 2m
|
||||||
|
kubernetes-dashboard-5498ccf677-b8p5h 1/1 Running 0 2m
|
||||||
|
nginx-ingress-controller-5984b97644-rnkrg 1/1 Running 0 1m
|
||||||
|
storage-provisioner 1/1 Running 0 2m
|
||||||
|
```
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Make sure that you see a Pod with a name that starts with `nginx-ingress-controller-`.
|
||||||
|
-->
|
||||||
|
请确保可以在输出中看到一个名称以 `nginx-ingress-controller-` 为前缀的 Pod。
|
||||||
|
{{% /tab %}}
|
||||||
|
{{< /tabs >}}
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
## Deploy a hello, world app
|
## Deploy a hello, world app
|
||||||
@@ -104,7 +126,7 @@ This page shows you how to set up a simple Ingress which routes requests to Serv
|
|||||||
kubectl create deployment web --image=gcr.io/google-samples/hello-app:1.0
|
kubectl create deployment web --image=gcr.io/google-samples/hello-app:1.0
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--Output:-->
|
<!--The output should be:-->
|
||||||
输出:
|
输出:
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -120,7 +142,7 @@ This page shows you how to set up a simple Ingress which routes requests to Serv
|
|||||||
kubectl expose deployment web --type=NodePort --port=8080
|
kubectl expose deployment web --type=NodePort --port=8080
|
||||||
```
|
```
|
||||||
|
|
||||||
<!-- Output: -->
|
<!--The output should be:-->
|
||||||
输出:
|
输出:
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -136,8 +158,8 @@ This page shows you how to set up a simple Ingress which routes requests to Serv
|
|||||||
kubectl get service web
|
kubectl get service web
|
||||||
```
|
```
|
||||||
|
|
||||||
<!-- Output: -->
|
<!-- The output is similar to: -->
|
||||||
输出:
|
输出类似于:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
|
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
|
||||||
@@ -153,8 +175,8 @@ This page shows you how to set up a simple Ingress which routes requests to Serv
|
|||||||
minikube service web --url
|
minikube service web --url
|
||||||
```
|
```
|
||||||
|
|
||||||
<!-- Output: -->
|
<!-- The output is similar to: -->
|
||||||
输出:
|
输出类似于:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
http://172.17.0.15:31637
|
http://172.17.0.15:31637
|
||||||
@@ -169,8 +191,8 @@ This page shows you how to set up a simple Ingress which routes requests to Serv
|
|||||||
输入节点和端口号(这里是`31637`),之后点击 **Display Port**。
|
输入节点和端口号(这里是`31637`),之后点击 **Display Port**。
|
||||||
{{< /note >}}
|
{{< /note >}}
|
||||||
|
|
||||||
<!-- Output: -->
|
<!-- The output is similar to: -->
|
||||||
输出:
|
输出类似于:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
Hello, world!
|
Hello, world!
|
||||||
@@ -186,15 +208,15 @@ This page shows you how to set up a simple Ingress which routes requests to Serv
|
|||||||
下一步是让自己能够通过 Ingress 资源来访问应用。
|
下一步是让自己能够通过 Ingress 资源来访问应用。
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
## Create an Ingress resource
|
## Create an Ingress
|
||||||
|
|
||||||
The following file is an Ingress resource that sends traffic to your Service via hello-world.info.
|
The following manifest defines an Ingress that sends traffic to your Service via hello-world.info.
|
||||||
|
|
||||||
1. Create `example-ingress.yaml` from the following file:
|
1. Create `example-ingress.yaml` from the following file:
|
||||||
-->
|
-->
|
||||||
## 创建一个 Ingress 资源
|
## 创建一个 Ingress
|
||||||
|
|
||||||
下面是一个 Ingress 资源的配置文件,负责通过 `hello-world.info` 将服务请求
|
下面是一个定义 Ingress 的配置文件,负责通过 `hello-world.info` 将请求
|
||||||
转发到你的服务。
|
转发到你的服务。
|
||||||
|
|
||||||
1. 根据下面的 YAML 创建文件 `example-ingress.yaml`:
|
1. 根据下面的 YAML 创建文件 `example-ingress.yaml`:
|
||||||
@@ -202,15 +224,15 @@ The following file is an Ingress resource that sends traffic to your Service via
|
|||||||
{{< codenew file="service/networking/example-ingress.yaml" >}}
|
{{< codenew file="service/networking/example-ingress.yaml" >}}
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
1. Create the Ingress resource by running the following command:
|
1. Create the Ingress object by running the following command:
|
||||||
-->
|
-->
|
||||||
2. 通过运行下面的命令创建 Ingress 资源:
|
2. 通过运行下面的命令创建 Ingress 对象:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl apply -f https://k8s.io/examples/service/networking/example-ingress.yaml
|
kubectl apply -f https://k8s.io/examples/service/networking/example-ingress.yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
<!-- Output: -->
|
<!-- The output should be: -->
|
||||||
输出:
|
输出:
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -231,15 +253,19 @@ The following file is an Ingress resource that sends traffic to your Service via
|
|||||||
此操作可能需要几分钟时间。
|
此操作可能需要几分钟时间。
|
||||||
{{< /note >}}
|
{{< /note >}}
|
||||||
|
|
||||||
|
<!-- You should see an IPv4 address in the ADDRESS column; for example: -->
|
||||||
|
接下来你将会在ADDRESS列中看到IPv4地址,例如:
|
||||||
|
|
||||||
```
|
```
|
||||||
NAME CLASS HOSTS ADDRESS PORTS AGE
|
NAME CLASS HOSTS ADDRESS PORTS AGE
|
||||||
example-ingress <none> hello-world.info 172.17.0.15 80 38s
|
example-ingress <none> hello-world.info 172.17.0.15 80 38s
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
1. Add the following line to the bottom of the `/etc/hosts` file.
|
1. Add the following line to the bottom of the `/etc/hosts` file on
|
||||||
|
your computer (you will need administrator access):
|
||||||
-->
|
-->
|
||||||
4. 在 `/etc/hosts` 文件的末尾添加以下内容:
|
4. 在 `/etc/hosts` 文件的末尾添加以下内容(需要管理员访问权限):
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
If you are running Minikube locally, use `minikube ip` to get the external IP. The IP address displayed within the ingress list will be the internal IP.
|
If you are running Minikube locally, use `minikube ip` to get the external IP. The IP address displayed within the ingress list will be the internal IP.
|
||||||
@@ -252,8 +278,11 @@ The following file is an Ingress resource that sends traffic to your Service via
|
|||||||
172.17.0.15 hello-world.info
|
172.17.0.15 hello-world.info
|
||||||
```
|
```
|
||||||
|
|
||||||
<!-- This sends requests from hello-world.info to Minikube. -->
|
<!--
|
||||||
此设置使得来自 `hello-world.info` 的请求被发送到 Minikube。
|
After you make this change, your web browser sends requests for
|
||||||
|
hello-world.info URLs to Minikube.
|
||||||
|
-->
|
||||||
|
添加完成后,在浏览器中访问URL `hello-world.info`,请求将被发送到 Minikube。
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
1. Verify that the Ingress controller is directing traffic:
|
1. Verify that the Ingress controller is directing traffic:
|
||||||
@@ -264,8 +293,8 @@ The following file is an Ingress resource that sends traffic to your Service via
|
|||||||
curl hello-world.info
|
curl hello-world.info
|
||||||
```
|
```
|
||||||
|
|
||||||
<!-- Output: -->
|
<!-- You should see: -->
|
||||||
输出:
|
你应该看到类似输出:
|
||||||
|
|
||||||
```
|
```
|
||||||
Hello, world!
|
Hello, world!
|
||||||
@@ -281,18 +310,19 @@ The following file is an Ingress resource that sends traffic to your Service via
|
|||||||
{{< /note >}}
|
{{< /note >}}
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
## Create Second Deployment
|
## Create a second Deployment
|
||||||
|
|
||||||
1. Create a v2 Deployment using the following command:
|
1. Create another Deployment using the following command:
|
||||||
-->
|
-->
|
||||||
## 创建第二个 Deployment
|
## 创建第二个 Deployment
|
||||||
|
|
||||||
1. 使用下面的命令创建 v2 的 Deployment:
|
1. 使用下面的命令创建第二个 Deployment:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl create deployment web2 --image=gcr.io/google-samples/hello-app:2.0
|
kubectl create deployment web2 --image=gcr.io/google-samples/hello-app:2.0
|
||||||
```
|
```
|
||||||
<!-- Output: -->
|
|
||||||
|
<!-- The output should be: -->
|
||||||
输出:
|
输出:
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -300,15 +330,15 @@ The following file is an Ingress resource that sends traffic to your Service via
|
|||||||
```
|
```
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
1. Expose the Deployment:
|
1. Expose the second Deployment:
|
||||||
-->
|
-->
|
||||||
2. 将 Deployment 暴露出来:
|
2. 将第二个 Deployment 暴露出来:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl expose deployment web2 --port=8080 --type=NodePort
|
kubectl expose deployment web2 --port=8080 --type=NodePort
|
||||||
```
|
```
|
||||||
|
|
||||||
<!-- Output: -->
|
<!-- The output should be: -->
|
||||||
输出:
|
输出:
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -316,13 +346,14 @@ The following file is an Ingress resource that sends traffic to your Service via
|
|||||||
```
|
```
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
## Edit Ingress
|
## Edit the existing Ingress {#edit-ingress}
|
||||||
|
|
||||||
1. Edit the existing `example-ingress.yaml` and add the following lines:
|
1. Edit the existing `example-ingress.yaml` manifest, and add the
|
||||||
|
following lines at the end:
|
||||||
-->
|
-->
|
||||||
## 编辑 Ingress
|
## 编辑现有的 Ingress {#edit-ingress}
|
||||||
|
|
||||||
1. 编辑现有的 `example-ingress.yaml`,添加以下行:
|
1. 编辑现有的 `example-ingress.yaml`,在文件最后添加以下行:
|
||||||
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
@@ -338,13 +369,13 @@ The following file is an Ingress resource that sends traffic to your Service via
|
|||||||
<!--
|
<!--
|
||||||
1. Apply the changes:
|
1. Apply the changes:
|
||||||
-->
|
-->
|
||||||
2. 应用所作变更:
|
2. 应用变更:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl apply -f example-ingress.yaml
|
kubectl apply -f example-ingress.yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
<!-- Output: -->
|
<!-- You should see: -->
|
||||||
输出:
|
输出:
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -364,8 +395,8 @@ The following file is an Ingress resource that sends traffic to your Service via
|
|||||||
curl hello-world.info
|
curl hello-world.info
|
||||||
```
|
```
|
||||||
|
|
||||||
<!-- Output: -->
|
<!-- The output is similar to: -->
|
||||||
输出:
|
输出类似于:
|
||||||
|
|
||||||
```
|
```
|
||||||
Hello, world!
|
Hello, world!
|
||||||
@@ -382,8 +413,8 @@ The following file is an Ingress resource that sends traffic to your Service via
|
|||||||
curl hello-world.info/v2
|
curl hello-world.info/v2
|
||||||
```
|
```
|
||||||
|
|
||||||
<!-- Output: -->
|
<!-- The output is similar to: -->
|
||||||
输出:
|
输出类似于:
|
||||||
|
|
||||||
```
|
```
|
||||||
Hello, world!
|
Hello, world!
|
||||||
@@ -392,7 +423,7 @@ The following file is an Ingress resource that sends traffic to your Service via
|
|||||||
```
|
```
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
If you are running Minikube locally, you can visit hello-world.info and hello-world.info/v2 from your browser
|
If you are running Minikube locally, you can visit hello-world.info and hello-world.info/v2 from your browser.
|
||||||
-->
|
-->
|
||||||
{{< note >}}
|
{{< note >}}
|
||||||
如果你在本地运行 Minikube 环境,你可以使用浏览器来访问
|
如果你在本地运行 Minikube 环境,你可以使用浏览器来访问
|
||||||
@@ -409,5 +440,4 @@ The following file is an Ingress resource that sends traffic to your Service via
|
|||||||
|
|
||||||
* 进一步了解 [Ingress](/zh/docs/concepts/services-networking/ingress/)。
|
* 进一步了解 [Ingress](/zh/docs/concepts/services-networking/ingress/)。
|
||||||
* 进一步了解 [Ingress 控制器](/zh/docs/concepts/services-networking/ingress-controllers/)
|
* 进一步了解 [Ingress 控制器](/zh/docs/concepts/services-networking/ingress-controllers/)
|
||||||
* 进一步了解[服务](/zh/docs/concepts/services-networking/service/)
|
* 进一步了解 [服务](/zh/docs/concepts/services-networking/service/)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user