Merge pull request #40446 from windsonsea/minikuy

[zh] sync /access-application-cluster/ingress-minikube.md
This commit is contained in:
Kubernetes Prow Robot 2023-04-03 00:41:51 -07:00 committed by GitHub
commit 8bcb39be16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 61 additions and 105 deletions

View File

@ -7,7 +7,7 @@ min-kubernetes-server-version: 1.19
<!--
title: Set up Ingress on Minikube with the NGINX Ingress Controller
content_type: task
weight: 100
weight: 110
min-kubernetes-server-version: 1.19
-->
@ -31,32 +31,28 @@ Ingress 中所设置的规则。
## {{% heading "prerequisites" %}}
<!--
This tutorial assumes that you are using `minikube` to run a local Kubernetes cluster.
Visit [Install tools](/docs/tasks/tools/#minikube) to learn how to install `minikube`.
-->
本教程假设你正在使用 `minikube` 运行一个本地 Kubernetes 集群。
参阅[安装工具](/zh-cn/docs/tasks/tools/#minikube)了解如何安装 `minikube`
{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
<!--
If you are using an older Kubernetes version, switch to the documentation for that version.
-->
如果你使用的是较早的 Kubernetes 版本,请切换到该版本的文档。
<!-- steps -->
<!--
### Create a Minikube cluster
### Create a minikube cluster
Using Katacoda
: {{< kat-button >}}
Locally
: If you already [installed Minikube](/docs/tasks/tools/#minikube)
locally, run `minikube start` to create a cluster.
If you haven't already set up a cluster locally, run `minikube start` to create a cluster.
-->
### 创建一个 Minikube 集群 {#create-minikube-cluster}
使用 Katacoda
: {{< kat-button >}}
本地
: 如果已经在本地[安装 Minikube](/zh-cn/docs/tasks/tools/#minikube)
请运行 `minikube start` 创建一个集群。
如果你还未在本地搭建集群,运行 `minikube start` 创建集群。
<!-- steps -->
@ -65,7 +61,7 @@ Locally
1. To enable the NGINX Ingress controller, run the following command:
-->
## 启用 Ingress 控制器
## 启用 Ingress 控制器 {#enable-ingress-controller}
1. 为了启用 NGINIX Ingress 控制器,可以运行下面的命令:
@ -78,9 +74,6 @@ Locally
-->
2. 检查验证 NGINX Ingress 控制器处于运行状态:
{{< tabs name="tab_with_md" >}}
{{% tab name="minikube v1.19 或更高版本" %}}
```shell
kubectl get pods -n ingress-nginx
```
@ -104,43 +97,6 @@ Locally
ingress-nginx-controller-59b45fb494-26npt 1/1 Running 0 11m
```
{{% /tab %}}
{{% tab name="minikube v1.18.1 或更早版本" %}}
```shell
kubectl get pods -n kube-system
```
{{< note >}}
<!--
It can take up to a minute before you see these pods running OK.
-->
最多可能需要等待一分钟才能看到这些 Pod 运行正常。
{{< /note >}}
<!--
The output is similar to:
-->
输出类似于:
```none
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
@ -218,17 +174,6 @@ Locally
http://172.17.0.15:31637
```
{{< note >}}
<!--
Katacoda environment only: at the top of the terminal panel, click the plus sign,
and then click **Select port to view on Host 1**. Enter the NodePort value,
in this case `31637`, and then click **Display Port**.
-->
如果使用的是 Katacoda 环境,在终端面板顶端,请点击加号标志。
然后点击 **Select port to view on Host 1**
输入节点和端口号(这里是`31637`),之后点击 **Display Port**
{{< /note >}}
<!--
The output is similar to:
-->
@ -255,7 +200,7 @@ The following manifest defines an Ingress that sends traffic to your Service via
1. Create `example-ingress.yaml` from the following file:
-->
## 创建一个 Ingress
## 创建一个 Ingress {#create-ingress}
下面是一个定义 Ingress 的配置文件,负责通过 `hello-world.info`
将请求转发到你的服务。
@ -308,38 +253,13 @@ The following manifest defines an Ingress that sends traffic to your Service via
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 on
your computer (you will need administrator access):
-->
4. 在 `/etc/hosts` 文件的末尾添加以下内容(需要管理员访问权限):
```none
172.17.0.15 hello-world.info
```
{{< note >}}
<!--
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.
-->
如果你在本地运行 Minikube 环境,需要使用 `minikube ip` 获得外部 IP 地址。
Ingress 列表中显示的 IP 地址会是内部 IP 地址。
{{< /note >}}
<!--
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:
-->
5. 验证 Ingress 控制器能够转发请求流量:
4. 验证 Ingress 控制器能够转发请求流量:
```shell
curl hello-world.info
curl --resolve "hello-world.info:80:$( minikube ip )" -i http://hello-world.info
```
<!--
@ -353,12 +273,48 @@ The following manifest defines an Ingress that sends traffic to your Service via
Hostname: web-55b8c6998d-8k564
```
{{< note >}}
<!--
If you are running Minikube locally, you can visit `hello-world.info` from your browser.
You can also visit `hello-world.info` from your browser.
* **Optionally**
Look up the external IP address as reported by minikube:
-->
如果你在使用本地 Minikube 环境,你可以从浏览器中访问 hello-world.info。
{{< /note >}}
你也可以从浏览器访问 `hello-world.info`
* **可选**
查看 Minikube 报告的外部 IP 地址:
```shell
minikube ip
```
<!--
Add line similar to the following one to the bottom of the `/etc/hosts` file on
your computer (you will need administrator access):
-->
将类似以下这一行添加到你计算机上的 `/etc/hosts` 文件的末尾(需要管理员访问权限):
```none
172.17.0.15 hello-world.info
```
{{< note >}}
<!--
Change the IP address to match the output from `minikube ip`.
-->
更改 IP 地址以匹配 `minikube ip` 的输出。
{{< /note >}}
<!--
After you make this change, your web browser sends requests for
`hello-world.info` URLs to Minikube.
-->
更改完成后,在浏览器中访问 URL `hello-world.info`,请求将被发送到 Minikube。
<!--
## Create a second Deployment
@ -448,7 +404,7 @@ The following manifest defines an Ingress that sends traffic to your Service via
1. 访问 Hello World 应用的第一个版本:
```shell
curl hello-world.info
curl --resolve "hello-world.info:80:$( minikube ip )" -i http://hello-world.info
```
<!--
@ -468,7 +424,7 @@ The following manifest defines an Ingress that sends traffic to your Service via
2. 访问 Hello World 应用的第二个版本:
```shell
curl hello-world.info/v2
curl --resolve "hello-world.info:80:$( minikube ip )" -i http://hello-world.info/v2
```
<!--
@ -484,10 +440,10 @@ The following manifest defines an Ingress that sends traffic to your Service via
{{< note >}}
<!--
If you are running Minikube locally, you can visit `hello-world.info` and
If you did the optional step to update `/etc/hosts`, you can also visit `hello-world.info` and
`hello-world.info/v2` from your browser.
-->
如果你在本地运行 Minikube 环境,你可以使用浏览器来访问
如果你执行了更新 `/etc/hosts` 的可选步骤,你也可以从你的浏览器中访问
`hello-world.info``hello-world.info/v2`
{{< /note >}}
@ -500,4 +456,4 @@ The following manifest defines an Ingress that sends traffic to your Service via
-->
* 进一步了解 [Ingress](/zh-cn/docs/concepts/services-networking/ingress/)
* 进一步了解 [Ingress 控制器](/zh-cn/docs/concepts/services-networking/ingress-controllers/)
* 进一步了解 [服务](/zh-cn/docs/concepts/services-networking/service/)
* 进一步了解[服务](/zh-cn/docs/concepts/services-networking/service/)