第 3 章 多租户迁移指南


3.1. 多租户迁移指南

本指南适用于当前运行 Red Hat OpenShift Service Mesh 2.6.9 的多租户部署的用户,并迁移到 OpenShift Service Mesh 3.0。

重要

如果您还没有完成迁移清单,您必须首先完成它们,然后才能开始迁移部署。

3.1.1. 迁移多租户部署

info 示例应用程序用于演示目的,其中的一个最小示例用于 Istio 资源。如需有关 OpenShift Service Mesh 2 ServiceMeshControlPlane 资源和 OpenShift Service Mesh 3 Istio 资源之间的配置差异的更多信息,请参阅 "ServiceMeshControlPlane 资源到 Istio 资源字段映射"。

您可以在您自己的工作负载中遵循相同的步骤。

先决条件

  • 您已部署了 OpenShift Container Platform 4.14 或更高版本。
  • 以具有 cluster-admin 角色的用户身份登录到 OpenShift Container Platform Web 控制台。
  • 您已完成了迁移前检查清单。
  • 已安装 OpenShift Service Mesh 2.6.9 Operator。
  • 已安装 OpenShift Service Mesh 3 Operator。
  • 您创建了 IstioCNI 资源。
  • 已安装 istioctl 工具。
  • 您正在运行 MultiTenant ServiceMeshControlPlane
  • 已安装 info 应用程序。

流程

  1. 创建 Istio 资源。

    Istio 资源示例

    apiVersion: sailoperator.io/v1
    kind: Istio
    metadata:
      name: istio-tenant-a
    spec:
      namespace: istio-system-tenant-a 
    1
    
      version: v1.24.3
      values:
        meshConfig:
          discoverySelectors: 
    2
    
            - matchLabels:
                tenant: tenant-a
          extensionProviders:  
    3
    
            - name: prometheus
              prometheus: {}
            - name: otel
              opentelemetry:
                port: 4317
                service: otel-collector.opentelemetrycollector-3.svc.cluster.local
    Copy to Clipboard Toggle word wrap

    1
    Istio 资源中的 spec.namespace 字段必须与 ServiceMeshControlPlane 资源的命名空间相同。如果将 Istio 资源中的 spec.namespace 字段设置为与 ServiceMeshControlPlane 资源不同的命名空间,则迁移将无法成功完成。
    2
    默认情况下,control plane 会监视整个集群。在单一集群中管理多个 control plane 时,您必须通过设置 discoverySelectors 字段来缩小每个 control plane 的范围。本例中使用了标签 tenant-a,但您可以使用任意标签或标签组合。
    3
    可选: 如果要迁移指标和追踪,请根据追踪和指标配置更新 extensionProviders 字段。
  2. 通过为每个 dataplane 命名空间运行以下命令来将 租户 标签添加到每个 dataplane 命名空间:

    $ oc label ns info tenant=tenant-a
    Copy to Clipboard Toggle word wrap
    注意

    在 OpenShift Service Mesh 2.6 中,命名空间已注册到网格中,方法是将命名空间添加到 ServiceMeshMemberRoll 资源中。在 OpenShift Service Mesh 3 中,您必须标记每个 dataplane 命名空间之一以匹配 discoverySelectors 字段。

3.1.2. 在多租户部署中迁移工作负载

现在,您可以将工作负载从 OpenShift Service Mesh 2.6 control plane 迁移到 OpenShift Service Mesh 3.0 control plane。

注意

您可以单独迁移工作负载和网关,并以任何顺序迁移。如需更多信息,请参阅"缓解网关"。

流程

  1. 运行以下命令,查找 OpenShift Service Mesh 3.0 control plane 的当前 IstioRevision

    $ oc get istios istio-tenant-a
    Copy to Clipboard Toggle word wrap

    输出示例

    NAME             REVISIONS   READY   IN USE   ACTIVE REVISION   STATUS    VERSION   AGE
    istio-tenant-a   1           1       0        istio-tenant-a    Healthy   v1.24.3   30s
    Copy to Clipboard Toggle word wrap

    注意

    修订版本的命名格式取决于您为 Istio 实例选择的升级策略。

  2. 复制 ACTIVE REVISION,以在下一步中用作 istio.io/rev 标签。
  3. 运行以下命令,更新 dataplane 命名空间中的注入标签:

    $ oc label ns info istio.io/rev=istio-tenant-a maistra.io/ignore-namespace="true" --overwrite=true
    Copy to Clipboard Toggle word wrap

    这会在命名空间中添加以下标签:

    1. istio.io/rev: istio-tenant-a label: 确保该命名空间中创建的任何新 pod 都连接到 OpenShift Service Mesh 3.0 代理。
    2. maistra.io/ignore-namespace: "true" 标签:禁用命名空间中 OpenShift Service Mesh 2.6 代理的 sidecar 注入,因此 OpenShift Service Mesh 2.6 会停止注入此命名空间中的代理,OpenShift Service Mesh 3.0 都注入代理。如果没有此标签,OpenShift Service Mesh 2.6 注入 Webhook 会尝试注入 pod,注入的 sidecar 代理将拒绝启动,因为它会同时具有 OpenShift Service Mesh 2.6 和 OpenShift Service Mesh 3.0 Container Network Interface (CNI)注解。

      注意

      应用 maistra.io/ignore-namespace 标签后,在该命名空间中创建的任何新 pod 都将连接到 OpenShift Service Mesh 3.0 代理。工作负载仍然可以相互通信,无论它们连接到哪个 controlplane。

  4. 使用以下选项之一重启工作负载:

    1. 要一次重启所有工作负载,以便新 pod 注入 OpenShift Service Mesh 3.0 代理,请运行以下命令:

      info 应用程序的命令示例

      $ oc rollout restart deployments -n info
      Copy to Clipboard Toggle word wrap

    2. 要单独重启每个工作负载,请对每个工作负载运行以下命令:

      带有 info 应用程序的命令示例

      $ oc rollout restart deployments productpage-v1 -n info
      Copy to Clipboard Toggle word wrap

  5. 运行以下命令等待 productpage 应用程序重启:

    $ oc rollout status deployment productpage-v1 -n info
    Copy to Clipboard Toggle word wrap

验证

  1. 检查您的工作负载是否已连接到新的 control plane。

    1. 运行以下命令,获取仍然使用 istioctl 工具连接到 OpenShift Service Mesh 2.6 control plane 的代理列表:

      $ istioctl ps --istioNamespace istio-system-tenant-a --revision basic
      Copy to Clipboard Toggle word wrap

      在本例中,basicServiceMeshControlPlane 的名称:

      输出示例

         NAME                                              CLUSTER        CDS        LDS        EDS        RDS          ECDS         ISTIOD                            VERSION
         details-v1-7b49464bc-zr7nr.info               Kubernetes     SYNCED     SYNCED     SYNCED     SYNCED       NOT SENT     istiod-basic-6c9f8d9894-sh6lx     1.20.8
         ratings-v1-d6f449f59-9rds2.info               Kubernetes     SYNCED     SYNCED     SYNCED     SYNCED       NOT SENT     istiod-basic-6c9f8d9894-sh6lx     1.20.8
         reviews-v1-686cd989df-9x59z.info              Kubernetes     SYNCED     SYNCED     SYNCED     SYNCED       NOT SENT     istiod-basic-6c9f8d9894-sh6lx     1.20.8
         reviews-v2-785b8b48fc-l7xkj.info              Kubernetes     SYNCED     SYNCED     SYNCED     SYNCED       NOT SENT     istiod-basic-6c9f8d9894-sh6lx     1.20.8
         reviews-v3-67889ffd49-7bhxn.info              Kubernetes     SYNCED     SYNCED     SYNCED     SYNCED       NOT SENT     istiod-basic-6c9f8d9894-sh6lx     1.20.8
      Copy to Clipboard Toggle word wrap

    2. 运行以下命令,查看迁移到新的 OpenShift Service Mesh 3.0 control plane 的列表代理:

      $ istioctl ps --istioNamespace istio-system-tenant-a --revision istio-tenant-a
      Copy to Clipboard Toggle word wrap

      输出示例

      NAME                                         CLUSTER        CDS        LDS        EDS        RDS        ECDS     ISTIOD                      VERSION
      productpage-v1-7745c5cc94-wpvth.info     Kubernetes     SYNCED     SYNCED     SYNCED     SYNCED              istiod-5bbf98dccf-n8566     1.24.3
      Copy to Clipboard Toggle word wrap

  2. 验证您的应用仍然正常工作。对于 info 应用程序,运行以下命令:

    $ oc exec -it -n info deployments/productpage-v1 -c istio-proxy -- curl localhost:9080/productpage
    Copy to Clipboard Toggle word wrap

后续步骤

如果使用网关,则必须在完成部署和工作负载的迁移过程前迁移它们。

如果您没有使用网关,并验证了 mulitenant 迁移,您可以继续完成迁移并删除 OpenShift Service Mesh 2 资源。

3.1.3. 使用 cert-manager 迁移多租户部署

info 示例应用程序用于演示目的,其中的一个最小示例用于 Istio 资源。如需有关 OpenShift Service Mesh 2 ServiceMeshControlPlane 资源和 OpenShift Service Mesh 3 Istio 资源之间的配置差异的更多信息,请参阅 "ServiceMeshControlPlane 资源到 Istio 资源字段映射"。

您可以在您自己的工作负载中遵循相同的步骤。

先决条件

  • 您已部署了 OpenShift Container Platform 4.14 或更高版本。
  • 以具有 cluster-admin 角色的用户身份登录到 OpenShift Container Platform Web 控制台。
  • 您已完成了迁移前检查清单。
  • 已安装 OpenShift Service Mesh 2.6.9 Operator。
  • 已安装 OpenShift Service Mesh 3 Operator。
  • 您创建了 IstioCNI 资源。
  • 已安装 istioctl 工具。
  • 在多租户部署中,您使用 cert-manager 和 istio-csr 工具。
  • OpenShift Service Mesh 2 ServiceMeshControlPlane 使用 cert-manager 工具进行配置。

步骤

  1. 检查 OpenShift Service Mesh 2 ServiceMeshControlPlane 是否使用 cert-manager-tool 配置:

    ServiceMeshControlPlane cert-manager 配置示例

    apiVersion: maistra.io/v2
    kind: ServiceMeshControlPlane
    metadata:
      name: basic
      namespace: istio-system
    spec:
      ...
      security:
        certificateAuthority:
          cert-manager:
            address: cert-manager-istio-csr.istio-system.svc:443
          type: cert-manager
        dataPlane:
          mtls: true
        identity:
          type: ThirdParty
        manageNetworkPolicy: false
    Copy to Clipboard Toggle word wrap

  2. 运行以下命令,更新 istio-csr 部署,使其包含 OpenShift Service Mesh 3 control plane:

      helm upgrade cert-manager-istio-csr jetstack/cert-manager-istio-csr \
          --install \
          --reuse-values \
          --namespace istio-system \
          --wait \
          --set "app.istio.revisions={basic,istio-tenant-a}" 
    1
    Copy to Clipboard Toggle word wrap
    1
    在创建 Istio 资源 app.istio.revisions 字段需要包括您的 OpenShift Service Mesh 3.0 control plane 修订版本,以便代理可以正确地与 OpenShift Service Mesh 3.0 control plane 通信。
  3. 创建 Istio 资源。

    带有 cert-manager 的 Istio 资源示例

    apiVersion: sailoperator.io/v1
    kind: Istio
    metadata:
      name: istio-tenant-a
    spec:
      namespace: istio-system-tenant-a 
    1
    
      version: v1.24.3
      values:
        meshConfig:
          discoverySelectors: 
    2
    
            - matchLabels:
                tenant: tenant-a
          extensionProviders:  
    3
    
            - name: prometheus
              prometheus: {}
            - name: otel
              opentelemetry:
               port: 4317
               service: otel-collector.opentelemetrycollector-3.svc.cluster.local
        global:
          caAddress: cert-manager-istio-csr.istio-system.svc:443
        pilot:
          env:
            ENABLE_CA_SERVER: "false"
    Copy to Clipboard Toggle word wrap

    1
    Istio 资源中的 spec.namespace 字段必须与 ServiceMeshControlPlane 资源的命名空间 相同。如果将 Istio 资源中的 spec.namespace 字段设置为与 ServiceMeshControlPlane 资源不同的命名空间,则迁移将无法正常工作。
    2
    默认情况下,control plane 会监视整个集群。在单一集群中管理多个 control plane 时,您必须通过设置 discoverySelectors 字段来缩小每个 control plane 的范围。本例中使用了标签 tenant-a,但您可以使用任意标签或标签组合。
    3
    可选: 如果要迁移指标和追踪,请根据追踪和指标配置更新 extensionProviders 字段。
  4. 通过为每个 dataplane 命名空间运行以下命令来将 租户 标签添加到每个 dataplane 命名空间:

    $ oc label ns info tenant=tenant-a
    Copy to Clipboard Toggle word wrap
    注意

    在 OpenShift Service Mesh 2.6 中,命名空间已注册到网格中,方法是将命名空间添加到 ServiceMeshMemberRoll 资源中。在 OpenShift Service Mesh 3 中,您必须标记每个 dataplane 命名空间之一以匹配 discoverySelectors 字段。

现在,您可以将工作负载从 OpenShift Service Mesh 2.6 control plane 迁移到 OpenShift Service Mesh 3.0 control plane。

注意

您可以单独迁移工作负载和网关,并以任何顺序迁移。如需更多信息,请参阅"缓解网关"。

步骤

  1. 运行以下命令,查找 OpenShift Service Mesh 3.0 control plane 的当前 IstioRevision

    $ oc get istios istio-tenant-a
    Copy to Clipboard Toggle word wrap

    输出示例

    NAME             REVISIONS   READY   IN USE   ACTIVE REVISION   STATUS    VERSION   AGE
    istio-tenant-a   1           1       0        istio-tenant-a    Healthy   v1.24.3   30s
    Copy to Clipboard Toggle word wrap

    注意

    修订版本的命名格式取决于您为 Istio 实例选择的升级策略。

  2. 复制 ACTIVE REVISION,以在下一步中用作 istio.io/rev 标签。
  3. 运行以下命令,更新 dataplane 命名空间中的注入标签:

    $ oc label ns info istio.io/rev=istio-tenant-a maistra.io/ignore-namespace="true" --overwrite=true
    Copy to Clipboard Toggle word wrap

    这会在命名空间中添加以下标签:

    1. istio.io/rev: istio-tenant-a label: 确保该命名空间中创建的任何新 pod 都连接到 OpenShift Service Mesh 3.0 代理。
    2. maistra.io/ignore-namespace: "true" 标签:禁用命名空间中 OpenShift Service Mesh 2.6 代理的 sidecar 注入,因此 OpenShift Service Mesh 2.6 会停止注入此命名空间中的代理,OpenShift Service Mesh 3.0 都注入代理。如果没有此标签,OpenShift Service Mesh 2.6 注入 Webhook 会尝试注入 pod,注入的 sidecar 代理将拒绝启动,因为它会同时具有 OpenShift Service Mesh 2.6 和 OpenShift Service Mesh 3.0 Container Network Interface (CNI)注解。

      注意

      应用 maistra.io/ignore-namespace 标签后,在该命名空间中创建的任何新 pod 都连接到 OpenShift Service Mesh 3.0 代理。工作负载仍然可以相互通信,无论它们连接到哪个 controlplane。

  4. 使用以下选项之一重启工作负载:

    1. 要一次重启所有工作负载,以便新 pod 注入 OpenShift Service Mesh 3.0 代理,请运行以下命令:

      info 应用程序的命令示例

      $ oc rollout restart deployments -n info
      Copy to Clipboard Toggle word wrap

    2. 要单独重启每个工作负载,请对每个工作负载运行以下命令:

      带有 info 应用程序的命令示例

      $ oc rollout restart deployments productpage-v1 -n info
      Copy to Clipboard Toggle word wrap

  5. 运行以下命令等待 productpage 应用程序重启:

    $ oc rollout status deployment productpage-v1 -n info
    Copy to Clipboard Toggle word wrap

验证

  1. 检查您的工作负载是否已连接到新的 control plane。

    1. 运行以下命令,获取仍然使用 istioctl 工具连接到 OpenShift Service Mesh 2.6 control plane 的代理列表:

      $ istioctl ps --istioNamespace istio-system-tenant-a --revision basic
      Copy to Clipboard Toggle word wrap

      在本例中,basicServiceMeshControlPlane 的名称:

      输出示例

         NAME                                              CLUSTER        CDS        LDS        EDS        RDS          ECDS         ISTIOD                            VERSION
         details-v1-7b49464bc-zr7nr.info               Kubernetes     SYNCED     SYNCED     SYNCED     SYNCED       NOT SENT     istiod-basic-6c9f8d9894-sh6lx     1.20.8
         ratings-v1-d6f449f59-9rds2.info               Kubernetes     SYNCED     SYNCED     SYNCED     SYNCED       NOT SENT     istiod-basic-6c9f8d9894-sh6lx     1.20.8
         reviews-v1-686cd989df-9x59z.info              Kubernetes     SYNCED     SYNCED     SYNCED     SYNCED       NOT SENT     istiod-basic-6c9f8d9894-sh6lx     1.20.8
         reviews-v2-785b8b48fc-l7xkj.info              Kubernetes     SYNCED     SYNCED     SYNCED     SYNCED       NOT SENT     istiod-basic-6c9f8d9894-sh6lx     1.20.8
         reviews-v3-67889ffd49-7bhxn.info              Kubernetes     SYNCED     SYNCED     SYNCED     SYNCED       NOT SENT     istiod-basic-6c9f8d9894-sh6lx     1.20.8
      Copy to Clipboard Toggle word wrap

    2. 运行以下命令,查看迁移到新的 OpenShift Service Mesh 3.0 control plane 的列表代理:

      $ istioctl ps --istioNamespace istio-system-tenant-a --revision istio-tenant-a
      Copy to Clipboard Toggle word wrap

      输出示例

      NAME                                         CLUSTER        CDS        LDS        EDS        RDS        ECDS     ISTIOD                      VERSION
      productpage-v1-7745c5cc94-wpvth.info     Kubernetes     SYNCED     SYNCED     SYNCED     SYNCED              istiod-5bbf98dccf-n8566     1.24.3
      Copy to Clipboard Toggle word wrap

  2. 验证您的应用仍然正常工作。对于 info 应用程序,运行以下命令:

    $ oc exec -it -n info deployments/productpage-v1 -c istio-proxy -- curl localhost:9080/productpage
    Copy to Clipboard Toggle word wrap

后续步骤

如果使用网关,则必须在完成部署和工作负载的迁移过程前迁移它们。

迁移网关后,您必须更新 istio-csr 部署中的 app.controller.configmapNamespaceSelector 字段。

如果不使用网关,您可以使用 cert-manager 完成迁移。

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat