From 5fc21f661db5d9731c8b2aa1b8a3b84cdba964eb Mon Sep 17 00:00:00 2001 From: Guangwen Feng Date: Mon, 3 Apr 2023 14:16:28 +0800 Subject: [PATCH] [zh-cn] Sync tutorials/hello-minikube.md Signed-off-by: Guangwen Feng --- .../zh-cn/docs/tutorials/hello-minikube.md | 164 +++++++++--------- 1 file changed, 79 insertions(+), 85 deletions(-) diff --git a/content/zh-cn/docs/tutorials/hello-minikube.md b/content/zh-cn/docs/tutorials/hello-minikube.md index fa5c9d8cd9..8f0d46ca3a 100644 --- a/content/zh-cn/docs/tutorials/hello-minikube.md +++ b/content/zh-cn/docs/tutorials/hello-minikube.md @@ -30,21 +30,11 @@ card: -本教程向你展示如何使用 Minikube 和 Katacoda -在 Kubernetes 上运行一个应用示例。Katacoda 提供免费的浏览器内 Kubernetes 环境。 - -{{< note >}} - -如果你已在本地安装 Minikube,也可以按照本教程操作。 -安装指南参阅 [minikube start](https://minikube.sigs.k8s.io/docs/start/)。 -{{< /note >}} +本教程向你展示如何使用 Minikube 在 Kubernetes 上运行一个应用示例。 +教程提供了容器镜像,使用 NGINX 来对所有请求做出回应。 ## {{% heading "objectives" %}} @@ -60,52 +50,54 @@ See [minikube start](https://minikube.sigs.k8s.io/docs/start/) for installation ## {{% heading "prerequisites" %}} -本教程提供了容器镜像,使用 NGINX 来对所有请求做出回应。 +本教程假设你已经安装了 `minikube`。 +有关安装说明,请参阅 [minikube start](https://minikube.sigs.k8s.io/docs/start/)。 + +你还需要安装 `kubectl`。 +有关安装说明,请参阅[安装工具](/zh-cn/docs/tasks/tools/#kubectl)。 ## 创建 Minikube 集群 {#create-a-minikube-cluster} -1. 点击 **Launch Terminal**。 - - {{< kat-button >}} - - {{< note >}} - - 如果你在本地安装了 Minikube,运行 `minikube start`。 - 在运行 `minikube dashboard` 之前,你应该打开一个新终端, - 在此启动 `minikube dashboard` ,然后切换回主终端。 - {{< /note >}} +```shell +minikube start +``` -2. 在浏览器中打开 Kubernetes 仪表板(Dashboard): +## Open the Dashboard - ```shell - minikube dashboard - ``` +Open the Kubernetes dashboard. You can do this two different ways: +--> +## 打开仪表板 {#open-the-dashboard} + +打开 Kubernetes 仪表板。你可以通过两种不同的方式执行此操作: + +{{< tabs name="dashboard" >}} +{{% tab name="启动浏览器" %}} + +打开一个**新的**终端,然后运行: +```shell +# 启动一个新的终端,并保持此命令运行。 +minikube dashboard +``` -3. 仅限 Katacoda 环境:在终端窗口的顶部,单击加号,然后单击 **Select port to view on Host 1**。 +现在,切换回运行 `minikube start` 的终端。 - -4. 仅限 Katacoda 环境:输入 `30000`,然后单击 **Display Port**。 - -{{< note >}} +{{< note >}} `dashboard` 命令启用仪表板插件,并在默认的 Web 浏览器中打开代理。 你可以在仪表板上创建 Kubernetes 资源,例如 Deployment 和 Service。 @@ -133,20 +126,32 @@ You can run the `dashboard` command again to create another proxy to access the 你可以再次运行 `dashboard` 命令创建另一个代理来访问仪表板。 {{< /note >}} - -## 使用 URL 打开仪表板 {#open-dashboard-with-url} +{{% /tab %}} +{{% tab name="URL 复制粘贴" %}} -如果你不想打开 Web 浏览器,请使用 `--url` 标志运行显示板命令以得到 URL: +If you don't want minikube to open a web browser for you, run the dashboard command with the +`--url` flag. `minikube` outputs a URL that you can open in the browser you prefer. +Open a **new** terminal, and run: +--> +如果你不想 Minikube 为你打开 Web 浏览器,可以使用 `--url` 标志运行仪表板命令。 +`minikube` 会输出一个 URL,你可以在你喜欢的浏览器中打开该 URL。 + +打开一个**新的**终端,然后运行: ```shell +# 启动一个新的终端,并保持此命令运行。 minikube dashboard --url ``` + +现在,切换回运行 `minikube start` 的终端。 + +{{% /tab %}} +{{< /tabs >}} + -1. 仅 Katacoda 环境:在终端窗格的顶部,点击加号,然后点击 **Open New Terminal**。 - -2. 使用 `kubectl create` 命令创建管理 Pod 的 Deployment。该 Pod 根据提供的 Docker +1. 使用 `kubectl create` 命令创建管理 Pod 的 Deployment。该 Pod 根据提供的 Docker 镜像运行容器。 ```shell + # 运行包含 Web 服务器的测试容器镜像 kubectl create deployment hello-node --image=registry.k8s.io/e2e-test-images/agnhost:2.39 -- /agnhost netexec --http-port=8080 ``` -3. 查看 Deployment: +2. 查看 Deployment: ```shell kubectl get deployments @@ -204,7 +205,7 @@ Pod runs a Container based on the provided Docker image. -4. 查看 Pod: +3. 查看 Pod: ```shell kubectl get pods @@ -224,7 +225,7 @@ Pod runs a Container based on the provided Docker image. -5. 查看集群事件: +4. 查看集群事件: ```shell kubectl get events @@ -233,7 +234,7 @@ Pod runs a Container based on the provided Docker image. -6. 查看 `kubectl` 配置: +5. 查看 `kubectl` 配置: ```shell kubectl config view @@ -241,8 +242,7 @@ Pod runs a Container based on the provided Docker image. {{< note >}} 有关 `kubectl` 命令的更多信息,请参阅 [kubectl 概述](/zh-cn/docs/reference/kubectl/)。 {{< /note >}} @@ -274,13 +274,13 @@ Kubernetes [*Service*](/docs/concepts/services-networking/service/). The `--type=LoadBalancer` flag indicates that you want to expose your Service outside of the cluster. - The application code inside the image `registry.k8s.io/echoserver` only listens on TCP port 8080. If you used + The application code inside the test image only listens on TCP port 8080. If you used `kubectl expose` to expose a different port, clients could not connect to that other port. --> 这里的 `--type=LoadBalancer` 参数表明你希望将你的 Service 暴露到集群外部。 - 镜像 `registry.k8s.io/echoserver` 中的应用程序代码仅监听 TCP 8080 端口。 + 测试镜像中的应用程序代码仅监听 TCP 8080 端口。 如果你用 `kubectl expose` 暴露了其它的端口,客户端将不能访问其它端口。 -4. 仅限 Katacoda 环境:单击加号,然后单击 **Select port to view on Host 1**。 - - -5. 仅限 Katacoda 环境:请注意在 service 输出中与 `8080` 对应的长度为 5 位的端口号。 - 此端口号是随机生成的,可能与你的不同。 - 在端口号文本框中输入你自己的端口号,然后单击 **Display Port**。 - 对应于上面的例子,需要输入 `30369`。 - + 这将打开一个浏览器窗口,为你的应用程序提供服务并显示应用的响应。 -3. 查看创建的 Pod 和 Service: +3. 查看通过安装该插件所创建的 Pod 和 Service: ```shell kubectl get pod,svc -n kube-system @@ -472,9 +460,9 @@ kubectl delete deployment hello-node ``` -可选地,停止 Minikube 虚拟机(VM): +停止 Minikube 集群: ```shell minikube stop @@ -486,9 +474,15 @@ Optionally, delete the Minikube VM: 可选地,删除 Minikube 虚拟机(VM): ```shell +# 可选的 minikube delete ``` + +如果你还想使用 Minikube 进一步学习 Kubernetes,那就不需要删除 Minikube。 + ## {{% heading "whatsnext" %}}