From e7b7f92df8aa8207801fb96e452c40033d84982d Mon Sep 17 00:00:00 2001 From: LongLong Date: Wed, 7 Apr 2021 17:18:07 +0800 Subject: [PATCH] zh-translation: docs/setup/install/operator/index.md (#9330) --- .../zh/docs/setup/install/operator/index.md | 127 ++++++++++-------- 1 file changed, 70 insertions(+), 57 deletions(-) diff --git a/content/zh/docs/setup/install/operator/index.md b/content/zh/docs/setup/install/operator/index.md index 28fbf39b49..3784757ac2 100644 --- a/content/zh/docs/setup/install/operator/index.md +++ b/content/zh/docs/setup/install/operator/index.md @@ -1,29 +1,23 @@ --- title: 使用 Istio Operator 安装 -description: 使用 Istio operator 在 Kubernetes 集群中安装 Istio 的说明。 +description: 使用 Istio Operator 在 Kubernetes 集群中安装 Istio 的说明。 weight: 25 keywords: [kubernetes, operator] test: no owner: istio/wg-environments-maintainers --- -除了手动在生产环境中安装、升级、和卸载 Istio,你还可以用 -Istio [operator](https://kubernetes.io/zh/docs/concepts/extend-kubernetes/operator/) -管理安装。 +除了手动在生产环境中安装、升级、和卸载 Istio,您还可以用 Istio [Operator](https://kubernetes.io/zh/docs/concepts/extend-kubernetes/operator/) 管理安装。 这样做还能缓解管理不同 Istio 版本的负担。 -你只需简单的更新 operator {{}}自定义资源(CR){{}}即可, -operator 控制器将为你应用相应的配置更改。 +您只需简单的更新 Operator {{}}自定义资源(CR){{}}即可, Operator 控制器将为您应用更改的相应配置。 -当你用 [istioctl install 命令](/zh/docs/setup/install/istioctl)安装 Istio 时, -底层使用的是和 operator 安装相同的 -[`IstioOperator` API](/zh/docs/reference/config/istio.operator.v1alpha1/)。 -在这两种场景下,都会以架构验证配置,并执行同样的正确性检查。 +当您用[使用 Istioctl 安装](/zh/docs/setup/install/istioctl)安装 Istio 时,底层使用的是和 Operator 安装相同的[`IstioOperator` API](/zh/docs/reference/config/istio.operator.v1alpha1/)。在这两种场景下,都会以架构验证配置,并执行同样的正确性检查。 {{< warning >}} -使用 operator 确实存在安全隐患: +使用 Operator 确实存在安全隐患: 这是因为当使用 `istioctl install` 命令时,操作运行于管理员用户的安全上下文中; -而使用 operator 时,操作运行于集群内 pod 自己的安全上下文中。 -为避免此漏洞,需要确保 operator 自身部署的足够安全。 +而使用 Operator 时,操作运行于集群内 pod 自己的安全上下文中。 +为避免此漏洞,需要确保 Operator 自身部署的足够安全。 {{< /warning >}} ## 先决条件 @@ -34,20 +28,20 @@ operator 控制器将为你应用相应的配置更改。 1. 安装 [{{< istioctl >}} 可执行程序](/zh/docs/ops/diagnostic-tools/istioctl/)。 -1. 部署 Istio operator: +1. 部署 Istio Operator: {{< text bash >}} $ istioctl operator init {{< /text >}} - 此命令运行 operator 在 `istio-operator` 命名空间中创建以下资源: + 此命令运行 Operator 在 `istio-operator` 命名空间中创建以下资源: - - operator 自定义资源定义(CRD) - - operator 控制器的 deployment 对象 - - 一个用来访问 operator 指标的服务 - - Istio operator 运行必须的 RBAC 规则 + - Operator 自定义资源定义(CRD) + - Operator 控制器的 deployment 对象 + - 一个用来访问 Operator 指标的服务 + - Istio Operator 运行必须的 RBAC 规则 - 你可以配置 operator 控制器安装的命名空间、operator 观测的命名空间、Istio 的镜像源和版本、以及更多。 + 您可以配置 Operator 控制器安装的命名空间、Operator 观测的命名空间、Istio 的镜像源和版本、以及更多。 例如,可以使用参数 `--watchedNamespaces` 指定一个或多个命名空间来观测: {{< text bash >}} @@ -57,7 +51,7 @@ operator 控制器将为你应用相应的配置更改。 更多详细信息,请参阅 [`istioctl operator init` 命令参考](/zh/docs/reference/commands/istioctl/#istioctl-operator-init)。 {{< tip >}} - 您也可以使用 Helm 部署 operator: + 您也可以使用 Helm 部署 Operator: {{< text bash >}} $ helm install istio-operator manifests/charts/istio-operator \ @@ -67,12 +61,12 @@ operator 控制器将为你应用相应的配置更改。 --set watchedNamespaces=istio-namespace1,istio-namespace2 {{< /text >}} - 注意:为了运行上面的命令,你需要[下载 Istio 的发行版本](/zh/docs/setup/getting-started/#download)。 + 注意:为了运行上面的命令您需要[下载 Istio 的发行版本](/zh/docs/setup/getting-started/#download)。 {{< /tip >}} ## 安装 -要使用 operator 安装 Istio `demo` [配置项(configuration profile)](/zh/docs/setup/additional-setup/config-profiles/),请运行以下命令: +要使用 Operator 安装 Istio `demo` [配置项(configuration profile)](/zh/docs/setup/additional-setup/config-profiles/),请运行以下命令: {{< text bash >}} $ kubectl create ns istio-system @@ -89,8 +83,25 @@ EOF 控制器将检测 `IstioOperator` 资源,然后安装(`demo`)配置指定的 Istio 组件。 +{{< warning >}} +如果在初始化 Istio Operator 时使用了 `--watchedNamespaces`,请将 `IstioOperator` 资源应用于任一观测的命名空间中,而不是应用于 `istio-system` 中。 +{{< /warning >}} + +默认情况下,Istio 控制平面(istiod)将安装在 `istio-system` 命名空间中。要将其安装到其他命名空间,请使用 `values.global.istioNamespace` 字段,如下: + +{{< text yaml >}} +apiVersion: install.istio.io/v1alpha1 +kind: IstioOperator +... +spec: + profile: demo + values: + global: + istioNamespace: istio-namespace1 +{{< /text >}} + {{< tip >}} -Istio operator 控制器在创建 `IstioOperator` 资源的90秒内启动 Istio 的安装。 +Istio Operator 控制器在创建 `IstioOperator` 资源的 90 秒内启动 Istio 的安装。 Istio 安装过程将在 120 秒内完成。 {{< /tip >}} @@ -114,7 +125,7 @@ istiod-598984548d-wjq9j 1/1 Running 0 99s ## 更新 -现在,控制器已经运行起来,你可以通过编辑或替换 `IstioOperator` 来改变 Istio 配置。 +现在,控制器已经运行起来,您可以通过编辑或替换 `IstioOperator` 来改变 Istio 配置。 控制器将检测到改变,继而用相应配置更新 Istio 的安装内容。 例如,使用以下命令将安装切换到 `default` 配置: @@ -131,7 +142,7 @@ spec: EOF {{< /text >}} -还可以启用或禁用组件、改变资源设置。 +您还可以启用或禁用组件、修改资源设置。 例如,启用 `istio-egressgateway` 组件并增加 pilot 的内存要求: {{< text bash >}} @@ -155,25 +166,24 @@ spec: EOF {{< /text >}} -通过检查 operator 控制器日志, -你可以检测到控制器为了响应 `IstioOperator` CR 的更新,而在集群中所做的改变: +通过检查 Operator 控制器日志,您可以检测到控制器为了响应 `IstioOperator` CR 的更新,而在集群中所做的改变: {{< text bash >}} $ kubectl logs -f -n istio-operator $(kubectl get pods -n istio-operator -lname=istio-operator -o jsonpath='{.items[0].metadata.name}') {{< /text >}} -参阅 [`IstioOperator` API](/zh/docs/reference/config/istio.operator.v1alpha1/#IstioOperatorSpec)完整的配置设置。 +参阅 [`IstioOperator` API](/zh/docs/reference/config/istio.operator.v1alpha1/#IstioOperatorSpec) 获取完整的配置设置。 ## 就地升级 下载并提取希望升级到的 Istio 版本对应的 `istioctl`。 -在目标 Istio 版本的目录中,重新安装 operator: +在目标 Istio 版本的目录中,重新安装 Operator: {{< text bash >}} $ /bin/istioctl operator init {{< /text >}} -你会看到 `istio-operator` 的 Pod 已重新启动,其版本已更改到目标版本: +您会看到 `istio-operator` 的 Pod 已重新启动,其版本已更改到目标版本: {{< text bash >}} $ kubectl get pods --namespace istio-operator \ @@ -192,8 +202,7 @@ $ kubectl get pods --namespace istio-system \ 金丝雀升级的过程类似于 [`istioctl` 版本的金丝雀升级](/zh/docs/setup/upgrade/#canary-upgrades)。 -例如,要升级上一节中安装的 Istio 修订版本, -首先验证群集中名为 `example-istiocontrolplane` 的 `IstioOperator` CR 是否存在: +例如,要升级上一节中安装的 Istio 修订版本,首先验证群集中名为 `example-istiocontrolplane` 的 `IstioOperator` CR 是否存在: {{< text bash >}} $ kubectl get iop --all-namespaces @@ -202,7 +211,7 @@ istio-system example-istiocontrolplane HEALTHY 11m {{< /text >}} 下载并提取希望升级到的 Istio 版本对应的 `istioctl`。 -然后,运行以下命令,基于群集内的 `IstioOperator` CR 的方式,安装 Istio 目标版本的控制平面 +然后,运行以下命令,基于集群内的 `IstioOperator` CR 的方式,安装 Istio 目标版本的控制平面 (这里,我们假设目标修订版本为 1.8.1): {{< text bash >}} @@ -210,7 +219,7 @@ $ istio-1.8.1/bin/istioctl operator init --revision 1-8-1 {{< /text >}} {{< tip >}} -你也可以通过 Helm 用不同的修订设置部署另一个 operator: +您也可以通过 Helm 用不同的修订设置部署另一个 Operator: {{< text bash >}} $ helm install istio-operator manifests/charts/istio-operator \ @@ -221,10 +230,26 @@ $ helm install istio-operator manifests/charts/istio-operator \ --set revision=1-7-0 {{< /text >}} -注意:你需要[下载 Istio 的发行版本](/zh/docs/setup/getting-started/#download)来运行上面的命令。 +注意:您需要[下载 Istio 的发行版本](/zh/docs/setup/getting-started/#download)来运行上面的命令。 {{< /tip >}} -运行该命令后,你将看到两组并排运行的控制平面 deployments 和 services: +复制 `example-istiocontrolplane` CR 并将其另存为 `example-istiocontrolplane-1-8-1.yaml` 文件。 +在 CR 中修改该文件的名称为 `example-istiocontrolplane-1-8-1`,并添加 `revision: 1-8-1`。 +更新后的 `IstioOperator` CR 如下所示: + +{{< text bash >}} +$ cat example-istiocontrolplane-1-8-1.yaml +apiVersion: install.istio.io/v1alpha1 +kind: IstioOperator +metadata: + namespace: istio-system + name: example-istiocontrolplane-1-8-1 +spec: + revision: 1-8-1 + profile: demo +{{< /text >}} + +运行该命令后,您将看到两组并排运行的控制平面 Deployments 和 Services: {{< text bash >}} $ kubectl get pods -n istio-system -l app=istiod @@ -240,41 +265,29 @@ istiod ClusterIP 10.87.7.69 15010/TCP,15012/TCP,443/T istiod-1-8-1 ClusterIP 10.87.4.92 15010/TCP,15012/TCP,443/TCP,15014/TCP,853/TCP 7m55s {{< /text >}} -要完成升级,请给工作负载的命名空间打这个标签: `istio.io/rev=1-8-1` ,并重新启动工作负载, -就如 [数据平面升级](/zh/docs/setup/upgrade/canary/#data-plane) 文档的描述。 +要完成升级,请给工作负载的命名空间打这个标签:`istio.io/rev=1-8-1`,并重新启动工作负载,就如 [数据平面升级](/zh/docs/setup/upgrade/canary/#data-plane) 文档的描述。 ## 卸载 -如果你使用 operator 完成了控制平面的金丝雀升级, -请运行以下命令卸载旧版本的控件平面,并保留新版本: - -{{< text bash >}} -$ istioctl operator remove --revision -{{< /text >}} - -否则,删除集群内运行的 `IstioOperator` CR,该 CR 将卸载正在运行的 Istio 的所有修订版本: +如果您使用 Operator 完成了控制平面的金丝雀升级,请运行以下命令卸载旧版本的控件平面,并保留新版本: {{< text bash >}} $ kubectl delete istiooperators.install.istio.io -n istio-system example-istiocontrolplane {{< /text >}} 等到 Istio 卸载完成 - 这可能需要一些时间。 - 然后删除 Istio 运算符: +然后删除 Istio Operator: {{< text bash >}} -$ istioctl operator remove +$ istioctl operator remove --revision {{< /text >}} -或: +如果省略 `revision` 标志,则 Istio Operator 的所有修订版本都将被删除。 -{{< text bash >}} -$ kubectl delete ns istio-operator --grace-period=0 --force -{{< /text >}} - -注意:在 Istio 完全移除之前删除 operator 可能会导致 Istio 资源残留。 -需要清理 operator 未删除的内容: +注意:在 Istio 完全移除之前删除 Operator 可能会导致 Istio 资源残留。 +需要清理 Operator 未删除的内容: {{< text bash >}} $ istioctl manifest generate | kubectl delete -f - $ kubectl delete ns istio-system --grace-period=0 --force - {{< /text >}} +{{< /text >}}