[zh] Sync part of #15436 update get started page into Chinese (#15492)

* Sync part of #15436 update get started page into Chinese

* fix lint
This commit is contained in:
Wilson Wu 2024-07-31 18:07:12 +08:00 committed by GitHub
parent 993e4a8f11
commit c439d270dc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 81 additions and 204 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 366 KiB

View File

@ -3,33 +3,30 @@ title: 入门
description: 快速、轻松地尝试 Istio 特性。 description: 快速、轻松地尝试 Istio 特性。
weight: 5 weight: 5
aliases: aliases:
- /zh/docs/setup/kubernetes/getting-started/ - /zh/docs/setup/additional-setup/getting-started/
- /zh/docs/setup/kubernetes/ - /zh/latest/docs/setup/additional-setup/getting-started/
- /zh/docs/setup/kubernetes/install/kubernetes/ keywords: [getting-started, install, bookinfo, quick-start, kubernetes, gateway-api]
keywords: [getting-started, install, bookinfo, quick-start, kubernetes]
test: yes test: yes
owner: istio/wg-environments-maintainers owner: istio/wg-environments-maintainers
--- ---
{{< tip >}} {{< tip >}}
{{< boilerplate gateway-api-future >}} 想要探索 Istio 的 {{< gloss "ambient" >}}Ambient 模式{{< /gloss >}}
如果您想从 Gateway API 开始使用 Istio 访问 [Ambient 模式入门](/zh/docs/ambient/getting-started) 指南!
请参阅[后续入门说明](/zh/docs/setup/additional-setup/getting-started/)而不是以下内容。
{{< /tip >}} {{< /tip >}}
本指南帮您快速评估 Istio。 本指南帮您快速评估 Istio。
如果您已经熟悉 Istio或对安装其他配置类型或高级[部署模型](/zh/docs/ops/deployment/deployment-models/)感兴趣, 如果您已经熟悉 Istio或对安装其他配置类型或高级[部署模型](/zh/docs/ops/deployment/deployment-models/)感兴趣,
请参阅[我们应该采用哪种 Istio 安装方法?](/zh/about/faq/#install-method-selection) 的 FAQ 页面。 请参阅[我们应该采用哪种 Istio 安装方法?](/zh/about/faq/#install-method-selection) 的 FAQ 页面。
完成下面步骤需要您有一个 {{< gloss >}}cluster{{< /gloss >}} 您需要一个 Kubernetes 集群才能继续。如果您没有集群,则可以使用
且运行着兼容版本的 Kubernetes ({{< supported_kubernetes_versions >}})。 [kind](/zh/docs/setup/platform-setup/kind)
您可以使用任何支持的平台,例如: 或任何其他[受支持的 Kubernetes 平台](/zh/docs/setup/platform-setup)。
[Minikube](https://kubernetes.io/zh-cn/docs/tasks/tools/#minikube)
或[特定平台安装说明](/zh/docs/setup/platform-setup/)章节中指定的其他平台。
请按照以下步骤开始使用 Istio 请按照以下步骤开始使用 Istio
1. [下载并安装 Istio](#download) 1. [下载并安装 Istio](#download)
1. [安装 Kubernetes Gateway API CRD](#gateway-api)
1. [部署示例应用](#bookinfo) 1. [部署示例应用](#bookinfo)
1. [对外开放应用](#ip) 1. [对外开放应用](#ip)
1. [查看仪表板](#dashboard) 1. [查看仪表板](#dashboard)
@ -37,23 +34,12 @@ owner: istio/wg-environments-maintainers
## 下载 Istio {#download} ## 下载 Istio {#download}
1. 转到 [Istio 发布]({{< istio_release_url >}})页面,下载适用于您操作系统的安装文件, 1. 转到 [Istio 发布]({{< istio_release_url >}})页面,下载适用于您操作系统的安装文件,
用自动化工具下载并解压最新版本的安装文件Linux 或 macOS [自动下载并获取最新版本](/zh/docs/setup/additional-setup/download-istio-release)Linux 或 macOS
{{< text bash >}} {{< text bash >}}
$ curl -L https://istio.io/downloadIstio | sh - $ curl -L https://istio.io/downloadIstio | sh -
{{< /text >}} {{< /text >}}
{{< tip >}}
上面的命令下载最新版本(用数值表示)的 Istio。
您可以给命令行传递变量,用来下载指定的、不同处理器体系的版本。
例如,要为 x86_64 架构下载 Istio {{< istio_full_version >}},请运行:
{{< text bash >}}
$ curl -L https://istio.io/downloadIstio | ISTIO_VERSION={{< istio_full_version >}} TARGET_ARCH=x86_64 sh -
{{< /text >}}
{{< /tip >}}
1. 转到 Istio 包目录。例如,如果包是 `istio-{{< istio_full_version >}}` 1. 转到 Istio 包目录。例如,如果包是 `istio-{{< istio_full_version >}}`
{{< text syntax=bash snip_id=none >}} {{< text syntax=bash snip_id=none >}}
@ -73,22 +59,23 @@ owner: istio/wg-environments-maintainers
## 安装 Istio {#install} ## 安装 Istio {#install}
1. 对于本次安装,我们采用 `demo` 在本指南中,我们使用 `demo` [配置文件](/zh/docs/setup/additional-setup/config-profiles/)。
[配置组合](/zh/docs/setup/additional-setup/config-profiles/)。 选择它是为了拥有一组适合测试的默认设置,但还有其他配置文件可用于生产、
选择它是因为它包含了一组专为测试准备的默认配置,另外还有用于生产或性能测试的配置组合 性能测试或 [OpenShift](/zh/docs/setup/platform-setup/openshift/)
{{< warning >}} 与 [Istio Gateway](/zh/docs/concepts/traffic-management/#gateways) 不同,
如果您的平台有 Openshift 等供应商提供的配置组合,请在下面命令中替换掉 `demo` 配置项。 创建 [Kubernetes Gateway](https://gateway-api.sigs.k8s.io/api-types/gateway/) 时,
更多细节请参阅[平台说明](/zh/docs/setup/platform-setup/)。 默认情况下还会[部署网关代理服务器](/zh/docs/tasks/traffic-management/ingress/gateway-api/#automated-deployment)。
{{< /warning >}} 由于不会使用它们,因此我们禁用通常作为 `demo` 配置文件的一部分安装的默认 Istio Gateway 服务的部署。
1. 使用 `demo` 配置文件安装 Istio无需任何 Gateway
{{< text bash >}} {{< text bash >}}
$ istioctl install --set profile=demo -y $ istioctl install -f @samples/bookinfo/demo-profile-no-gateways.yaml@ -y
✔ Istio core installed ✔ Istio core installed
✔ Istiod installed ✔ Istiod installed
✔ Egress gateways installed
✔ Ingress gateways installed
✔ Installation complete ✔ Installation complete
Made this installation the default for injection and validation.
{{< /text >}} {{< /text >}}
1. 给命名空间添加标签,指示 Istio 在部署应用的时候,自动注入 Envoy Sidecar 代理: 1. 给命名空间添加标签,指示 Istio 在部署应用的时候,自动注入 Envoy Sidecar 代理:
@ -98,12 +85,26 @@ owner: istio/wg-environments-maintainers
namespace/default labeled namespace/default labeled
{{< /text >}} {{< /text >}}
## 安装 Kubernetes Gateway API CRD {#gateway-api}
Kubernetes Gateway API CRD 在大多数 Kubernetes 集群上不会默认安装,
因此请确保在使用 Gateway API 之前已安装它们。
1. 如果 Gateway API CRD 尚不存在,请安装它们:
{{< text bash >}}
$ kubectl get crd gateways.gateway.networking.k8s.io &> /dev/null || \
{ kubectl kustomize "github.com/kubernetes-sigs/gateway-api/config/crd?ref={{< k8s_gateway_api_version >}}" | kubectl apply -f -; }
{{< /text >}}
## 部署示例应用 {#bookinfo} ## 部署示例应用 {#bookinfo}
您已将 Istio 配置为将 Sidecar 容器注入到您在 `default` 命名空间中部署的任何应用程序中。
1. 部署 [`Bookinfo` 示例应用](/zh/docs/examples/bookinfo/) 1. 部署 [`Bookinfo` 示例应用](/zh/docs/examples/bookinfo/)
{{< text bash >}} {{< text bash >}}
$ kubectl apply -f @samples/bookinfo/platform/kube/bookinfo.yaml@ $ kubectl apply -f {{< github_file >}}/samples/bookinfo/platform/kube/bookinfo.yaml
service/details created service/details created
serviceaccount/bookinfo-details created serviceaccount/bookinfo-details created
deployment.apps/details-v1 created deployment.apps/details-v1 created
@ -120,7 +121,7 @@ owner: istio/wg-environments-maintainers
deployment.apps/productpage-v1 created deployment.apps/productpage-v1 created
{{< /text >}} {{< /text >}}
1. 应用很快会启动起来。当每个 Pod 准备就绪时Istio Sidecar 将伴随应用一起部署。 应用很快会启动起来。当每个 Pod 准备就绪时Istio Sidecar 将伴随应用一起部署。
{{< text bash >}} {{< text bash >}}
$ kubectl get services $ kubectl get services
@ -145,13 +146,9 @@ owner: istio/wg-environments-maintainers
reviews-v3-7dbcdcbc56-m8dph 2/2 Running 0 2m41s reviews-v3-7dbcdcbc56-m8dph 2/2 Running 0 2m41s
{{< /text >}} {{< /text >}}
{{< tip >}} 请注意Pod 显示 `READY 2/2`,确认它们具有应用程序容器和 Istio Sidecar 容器。
在执行下一步之前,反复运行上面的命令直到所有的 Pod 均报告:
READY `2/2` 和 STATUS `Running`
基于您平台的不同,这个操作过程可能会花费几分钟的时间。
{{< /tip >}}
1. 确认上面的操作都正确之后,运行下面命令,通过检查返回的页面标题来验证应用是否已在集群中运行,并已提供网页服务 1. 通过检查响应中的页面标题来验证应用程序是否在集群内运行:
{{< text bash >}} {{< text bash >}}
$ kubectl exec "$(kubectl get pod -l app=ratings -o jsonpath='{.items[0].metadata.name}')" -c ratings -- curl -sS productpage:9080/productpage | grep -o "<title>.*</title>" $ kubectl exec "$(kubectl get pod -l app=ratings -o jsonpath='{.items[0].metadata.name}')" -c ratings -- curl -sS productpage:9080/productpage | grep -o "<title>.*</title>"
@ -160,183 +157,53 @@ owner: istio/wg-environments-maintainers
## 对外开放应用 {#ip} ## 对外开放应用 {#ip}
此时BookInfo 应用已经部署,但还不能被外界访问。 Bookinfo 应用程序已部署,但无法从外部访问。为了使其可访问,
要开放访问,您需要创建 您需要创建一个 Ingress Gateway它将路径映射到网格边缘的路由。
[Istio 入站网关Ingress Gateway](/zh/docs/concepts/traffic-management/#gateways)
它会在网格边缘把一个路径映射到路由。
1. 把应用关联到 Istio 网关 1. 为 Bookinfo 应用创建 [Kubernetes Gateway](https://gateway-api.sigs.k8s.io/api-types/gateway/)
{{< text bash >}} {{< text syntax=bash snip_id=deploy_bookinfo_gateway >}}
$ kubectl apply -f @samples/bookinfo/networking/bookinfo-gateway.yaml@ $ kubectl apply -f @samples/bookinfo/gateway-api/bookinfo-gateway.yaml@
gateway.networking.istio.io/bookinfo-gateway created gateway.gateway.networking.k8s.io/bookinfo-gateway created
virtualservice.networking.istio.io/bookinfo created httproute.gateway.networking.k8s.io/bookinfo created
{{< /text >}} {{< /text >}}
1. 确保配置文件没有问题: 默认情况下Istio 会为网关创建一个 `LoadBalancer` 服务。由于我们将通过隧道访问此网关,
因此不需要负载均衡器。如果您想了解如何为外部 IP 地址配置负载均衡器,
请阅读 [Ingress Gateway](/zh/docs/tasks/traffic-management/ingress/ingress-control/) 文档。
{{< text bash >}} 1. 通过注解网关将服务类型更改为 `ClusterIP`
$ istioctl analyze
✔ No validation issues found when analyzing namespace: default. {{< text syntax=bash snip_id=annotate_bookinfo_gateway >}}
$ kubectl annotate gateway bookinfo-gateway networking.istio.io/service-type=ClusterIP --namespace=default
{{< /text >}} {{< /text >}}
### 确定入站 IP 和端口 {#determining-the-ingress-ip-and-ports} 1. 要检查网关的状态,请运行:
按照说明,为访问网关设置两个变量:`INGRESS_HOST` 和 `INGRESS_PORT`
使用标签页,切换到您选用平台的说明:
{{< tabset category-name="gateway-ip" >}}
{{< tab name="Minikube" category-value="external-lb" >}}
在新的终端窗口中运行此命令以启动一个 Minikube 隧道,将流量发送到 Istio Ingress Gateway。
这将为 `service/istio-ingressgateway` 提供一个外部负载均衡器 `EXTERNAL-IP`
{{< text bash >}}
$ minikube tunnel
{{< /text >}}
设置入站主机和端口:
{{< text bash >}}
$ export INGRESS_HOST=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
$ export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].port}')
$ export SECURE_INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="https")].port}')
{{< /text >}}
确保 IP 地址和端口被成功地赋值给了每一个环境变量:
{{< text bash >}}
$ echo "$INGRESS_HOST"
127.0.0.1
{{< /text >}}
{{< text bash >}}
$ echo "$INGRESS_PORT"
80
{{< /text >}}
{{< text bash >}}
$ echo "$SECURE_INGRESS_PORT"
443
{{< /text >}}
{{< /tab >}}
{{< tab name="其他平台" category-value="node-port" >}}
执行下面的命令以判断您的 Kubernetes 集群环境是否支持外部负载均衡:
{{< text bash >}}
$ kubectl get svc istio-ingressgateway -n istio-system
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
istio-ingressgateway LoadBalancer 172.21.109.129 130.211.10.121 80:31380/TCP,443:31390/TCP,31400:31400/TCP 17h
{{< /text >}}
设置 `EXTERNAL-IP` 的值之后,
您的环境就有了一个外部的负载均衡器,可以将其用作入站网关。
但如果 `EXTERNAL-IP` 的值为 `<none>` (或者一直是 `<pending>` 状态)
则您的环境则没有提供可作为入站流量网关的外部负载均衡器。
在这个情况下您还可以用服务Service的[节点端口](https://kubernetes.io/zh-cn/docs/concepts/services-networking/service/#type-nodeport)访问网关。
依据您的环境,选择相应的说明:
如果您确定您的环境中确实存在外部的负载均衡,请参照下面的说明。
设置入站 IP 地址和端口:
{{< text bash >}}
$ export INGRESS_HOST=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
$ export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].port}')
$ export SECURE_INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="https")].port}')
{{< /text >}}
{{< warning >}}
在某些环境中,负载均衡器可能使用主机名访问,而不是 IP 地址。
在这种情况下,入站流量网关的 `EXTERNAL-IP` 值不是 IP 地址,而是一个主机名,
那上面设置 `INGRESS_HOST` 环境变量的操作会失败。
使用下面命令纠正 `INGRESS_HOST` 的值。
{{< text bash >}}
$ export INGRESS_HOST=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')
{{< /text >}}
{{< /warning >}}
按照下面说明:如果您的环境中没有外部负载均衡器,那就选择一个节点端口来代替。
设置入站的端口:
{{< text bash >}}
$ export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].nodePort}')
$ export SECURE_INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="https")].nodePort}')
{{< /text >}}
_GKE:_
{{< text bash >}}
$ export INGRESS_HOST=worker-node-address
{{< /text >}}
您需要创建防火墙规则,以允许 TCP 流量发送到 `ingressgateway` 服务地端口。
运行下面的命令,以允许 HTTP 端口或 HTTPS 端口的流量,或两者的流量都允许。
{{< text bash >}}
$ gcloud compute firewall-rules create allow-gateway-http --allow "tcp:$INGRESS_PORT"
$ gcloud compute firewall-rules create allow-gateway-https --allow "tcp:$SECURE_INGRESS_PORT"
{{< /text >}}
_IBM Cloud Kubernetes Service:_
{{< text bash >}}
$ ibmcloud ks workers --cluster cluster-name-or-id
$ export INGRESS_HOST=public-IP-of-one-of-the-worker-nodes
{{< /text >}}
_Docker For Desktop:_
{{< text bash >}}
$ export INGRESS_HOST=127.0.0.1
{{< /text >}}
其他环境:
{{< text bash >}}
$ export INGRESS_HOST=$(kubectl get po -l istio=ingressgateway -n istio-system -o jsonpath='{.items[0].status.hostIP}')
{{< /text >}}
{{< /tab >}}
{{< /tabset >}}
1. 设置环境变量 `GATEWAY_URL`
{{< text bash >}} {{< text bash >}}
$ export GATEWAY_URL=$INGRESS_HOST:$INGRESS_PORT $ kubectl get gateway
NAME CLASS ADDRESS PROGRAMMED AGE
bookinfo-gateway istio bookinfo-gateway-istio.default.svc.cluster.local True 42s
{{< /text >}} {{< /text >}}
1. 确保 IP 地址和端口均成功地赋值给了环境变量: ## 访问应用程序 {#access-the-application}
{{< text bash >}} 您将通过刚刚配置的网关连接到 Bookinfo `productpage` 服务。
$ echo "$GATEWAY_URL" 要访问网关,您需要使用 `kubectl port-forward` 命令:
127.0.0.1:80
{{< /text >}}
### 验证外部访问 {#confirm} {{< text syntax=bash snip_id=none >}}
$ kubectl port-forward svc/bookinfo-gateway-istio 8080:80
{{< /text >}}
用浏览器查看 Bookinfo 应用的产品页面,验证 Bookinfo 已经实现了外部访问。 打开浏览器并导航到 `http://localhost:8080/productpage` 以查看 Bookinfo 应用程序。
1. 运行下面命令,获取 Bookinfo 应用的外部访问地址。 {{< image width="80%" link="./bookinfo-browser.png" caption="Bookinfo 应用程序" >}}
{{< text bash >}} 如果您刷新页面,您应该会看到书评和评分发生变化,因为请求分布在 `reviews` 服务的不同版本上。
$ echo "http://$GATEWAY_URL/productpage"
{{< /text >}}
1. 把上面命令的输出地址复制粘贴到浏览器并访问,确认 Bookinfo 应用的产品页面是否可以打开。
## 查看仪表板 {#dashboard} ## 查看仪表板 {#dashboard}
Istio 和[几个](/zh/docs/ops/integrations)遥测应用做了集成。 Istio 和[几个遥测应用](/zh/docs/ops/integrations)做了集成。
遥测能帮您了解服务网格的结构、展示网络的拓扑结构、分析网格的健康状态。 遥测能帮您了解服务网格的结构、展示网络的拓扑结构、分析网格的健康状态。
使用下面说明部署 [Kiali](/zh/docs/ops/integrations/kiali/) 仪表板、 使用下面说明部署 [Kiali](/zh/docs/ops/integrations/kiali/) 仪表板、
@ -353,10 +220,6 @@ Istio 和[几个](/zh/docs/ops/integrations)遥测应用做了集成。
deployment "kiali" successfully rolled out deployment "kiali" successfully rolled out
{{< /text >}} {{< /text >}}
{{< tip >}}
如果在安装插件时出错,再运行一次命令。有一些和时间相关的问题,再次运行就能解决。
{{< /tip >}}
1. 访问 Kiali 仪表板。 1. 访问 Kiali 仪表板。
{{< text bash >}} {{< text bash >}}
@ -425,3 +288,17 @@ $ kubectl delete namespace istio-system
{{< text bash >}} {{< text bash >}}
$ kubectl label namespace default istio-injection- $ kubectl label namespace default istio-injection-
{{< /text >}} {{< /text >}}
如果您安装了 Kubernetes Gateway API CRD 并且现在想要删除它们,请运行以下命令之一:
- 如果您运行的任何任务需要**实验版本**的 CRD
{{< text bash >}}
$ kubectl kustomize "github.com/kubernetes-sigs/gateway-api/config/crd/experimental?ref={{< k8s_gateway_api_version >}}" | kubectl delete -f -
{{< /text >}}
- 否则:
{{< text bash >}}
$ kubectl kustomize "github.com/kubernetes-sigs/gateway-api/config/crd?ref={{< k8s_gateway_api_version >}}" | kubectl delete -f -
{{< /text >}}