将捆绑的 Istio 迁移到 Cloud Service Mesh

这些步骤特定于 Istio 的捆绑版本,该版本默认包含在 Knative serving“GKE 插件”中。

由于在您执行卸载 Knative serving“GKE 插件”的过程时,系统会卸载 Istio 的捆绑版本,因此本页面中的步骤会在集群上安装 Cloud Service Mesh,然后配置入站流量网关。

准备工作

概览

通常,从 Istio 的捆绑版本迁移时,安装 Cloud Service Mesh 的过程与执行干净的 Cloud Service Mesh 安装相同。在此过程中,Cloud Service Mesh 1.18 版随集群内控制平面一起安装。

安装 Cloud Service Mesh 1.18 版

您可以按照 Cloud Service Mesh 安装文档来安装 Cloud Service Mesh。

准备工作

  • 对于迁移,必须在后续配置步骤中单独安装入站流量网关。默认情况下,安装脚本不会安装 Ingress 网关。

  • 可选:如果您使用 Cloud Service Mesh 证书授权机构 (Mesh CA),则还必须在 Cloud Service Mesh 安装脚本中添加 --ca mesh_ca 标志。

如需安装 Cloud Service Mesh,请执行以下操作:

按照 Cloud Service Mesh 文档中的步骤操作:安装 Cloud Service Mesh 1.18 版

示例

以下是包含必需标志的默认命令的示例:

./asmcli install \
  --project_id ${PROJECT_ID} \
  --cluster_name ${CLUSTER_NAME} \
  --cluster_location ${CLUSTER_LOCATION} \
  --ca mesh_ca \
  --output_dir DIR_PATH \
  --enable_all

配置 Cloud Service Mesh 入站流量

在本部分中,迁移脚本用于在 gke-system 命名空间内创建 Cloud Service Mesh 入站流量网关。

对于迁移,将使用 gke-system 命名空间,以便在刚刚移除的“捆绑的 Istio”使用的同一命名空间中创建入站流量网关。因此,Cloud Service Mesh 入站流量 Pod 可以无缝接管流量,而无需对入站流量服务进行任何所需的配置更改。例如,您无需配置新的外部 IP 地址。

  1. 要在 gke-system 命名空间中创建入站流量网关,请运行以下命令启动迁移脚本:

    ./migration-addon.sh --command set-up-asm-ingress
    

    该过程中的终端输出类似于以下内容:

    Setting up Cloud Service Mesh ingress. Note that the Cloud Service Mesh ingress is not
    serving traffic at this step.
    namespace/gke-system labeled
    deployment.apps/istio-ingressgateway created
    horizontalpodautoscaler.autoscaling/istio-ingressgateway created
    role.rbac.authorization.k8s.io/istio-ingressgateway-sds created
    rolebinding.rbac.authorization.k8s.io/istio-ingressgateway-sds created
    Cloud Service Mesh ingress is successfully installed.
    
  2. 通过运行以下命令验证 istio-ingrerssgateway 入站流量网关正在 gke-system 命名空间中运行:

    kubectl get deployment istio-ingressgateway -n gke-system
    

    请注意,istio-ingressgateway pod 的数量是特意设置为 0。安装 Knative serving 舰队组件后,系统会执行后续步骤,即将所有流量迁移到 Cloud Service Mesh 入站流量

后续步骤

安装舰队组件

回滚

如果您需要回滚在前面步骤中所做的更改,可以使用迁移脚本执行以下操作:

  • 删除 Cloud Service Mesh 入站流量网关。
  • 卸载 Cloud Service Mesh。

如需回滚 Cloud Service Mesh 配置和安装,请执行以下操作:

  1. 运行以下命令以启动回滚。

    ./migration-addon.sh --command rollback-set-up-asm-ingress
    

    该过程中的终端输出类似于以下内容:

    Deleting Cloud Service Mesh ingress
    deployment.apps "istio-ingressgateway" deleted
    horizontalpodautoscaler.autoscaling "istio-ingressgateway" deleted
    role.rbac.authorization.k8s.io "istio-ingressgateway-sds" deleted
    rolebinding.rbac.authorization.k8s.io "istio-ingressgateway-sds" deleted
    Cloud Service Mesh ingress is successfully deleted.
    
  2. 如需验证 Cloud Service Mesh 入站流量网关是否已移除,请检查 gke-system 命名空间中是否不再存在 istio-ingressgateway 服务:

    kubectl get deployment istio-ingressgateway -n gke-system
    
  3. 卸载 Cloud Service Mesh

  4. 如需继续回滚对安装的原始状态所做的所有更改,请回滚 Knative serving“GKE 插件”