3.3. 部署集群应用程序迁移 (CAM) 工具

部署集群应用程序迁移 (CAM) 工具需要在 OpenShift Container Platform 4.2 源OpenShift Container Platform 4.2 目标集群上安装 CAM Operator。 并在OpenShift Container Platform 4.2 源集群中配置跨原始资源共享。

Cluster Application Migration Operator 默认在目标集群上安装 CAM 工具(CAM web 控制台和迁移控制器)。您可以 在 OpenShift Container Platform 3 和远程集群中安装 CAM 工具

3.3.1. 在 OpenShift Container Platform 4.2 源集群上安装 Cluster Application Migration Operator

您可以使用 OLM 在 OpenShift Container Platform 4.2 源集群上安装 Cluster Application Migration Operator。

流程

  1. 在 OpenShift Container Platform Web 控制台中,点击 OperatorsOperatorHub
  2. 使用 Filter by keyword 项(在这里是 Migration)找到 Cluster Application Migration Operator
  3. 选择 Cluster Application Migration Operator 并点 Install
  4. Create Operator Subscription 页面中,选择 openshift-migration 命名空间,并指定批准策略。
  5. Subscribe

    Installed Operators 页中,Cluster Application Migration Operator 会出现在 openshift-migration 项目中,其状态为 InstallSucceeded

  6. Provided APIs 中点 View 12 more…​.
  7. Create NewMigrationController
  8. spec 小节中更新 migration_controller 和 migration_ui 参数:

    spec:
      [...]
      migration_controller: false
      migration_ui: false
      [...]
  9. 点击 Create
  10. WorkloadsPod 来验证 Restic 和 Velero Pod 是否正在运行。

3.3.2. 在 OpenShift Container Platform 4.2 目标集群上安装 Cluster Application Migration Operator

您可以使用 OLM 在 OpenShift Container Platform 4.2 目标集群上安装 Cluster Application Migration Operator。

默认情况下,Cluster Application Migration Operator 会在目标集群上安装 CAM 工具:

流程

  1. 在 OpenShift Container Platform Web 控制台中,点击 OperatorsOperatorHub
  2. 使用 Filter by keyword 项(在这里是 Migration)找到 Cluster Application Migration Operator
  3. 选择 Cluster Application Migration Operator 并点 Install
  4. Create Operator Subscription 页面中,选择 openshift-migration 命名空间,并指定批准策略。
  5. Subscribe

    Installed Operators 页中,Cluster Application Migration Operator 会出现在 openshift-migration 项目中,其状态为 InstallSucceeded

  6. Provided APIs 中点 View 12 more…​.
  7. Create NewMigrationController
  8. 点击 Create
  9. WorkloadsPod 来验证 Controller Manager 、Migration UI 、Restic 和 Velero Pod 是否正在运行。

3.3.3. 在 OpenShift Container Platform 4.2 源集群中配置跨原始资源共享

您必须在 OpenShift Container Platform 4.2 源集群中配置跨原始资源共享,以启用源集群 API 服务器和 CAM 工具之间的通信。

流程

  1. 登录到已安装 CAM 工具的集群。
  2. 获取 CORS 配置的值:

    $ oc get -n openshift-migration route/migration -o go-template='(?i)//{{ .spec.host }}(:|\z){{ println }}' | sed 's,\.,\\.,g'
  3. 登录到源集群。
  4. 编辑 Kubernetes API 服务器 CR:

    $ oc edit apiserver.config.openshift.io cluster
  5. 将 CORS 配置值添加到 spec 小节中的 additionalCORSAllowedOrigins

    spec:
      additionalCORSAllowedOrigins:
      - (?i)//migration-openshift-migration\.apps\.cluster\.com(:|\z) 1
    1
    指定您的 CORS 配置值。
  6. 保存文件以使改变生效。
  7. 验证配置:

    $ curl -v -k -X OPTIONS \
    "<cluster_url>/apis/migration.openshift.io/v1alpha1/namespaces/openshift-migration/migclusters" \ 1
    -H "Access-Control-Request-Method: GET" \
    -H "Access-Control-Request-Headers: authorization" \
    -H "Origin: https://<CAM_web_console_url>" 2
    1
    指定您配置的 CORS 集群的 URL。
    2
    指定 CAM web 控制台的 URL。URL 基于 CORS 配置值,例如 https://migration-openshift-migration.apps.cluster

    输出结果类似如下:

    < HTTP/2 204
    < access-control-allow-credentials: true
    < access-control-allow-headers: Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, X-Requested-With, If-Modified-Since
    < access-control-allow-methods: POST, GET, OPTIONS, PUT, DELETE, PATCH
    < access-control-allow-origin: https://migration-openshift-migration.apps.cluster
    < access-control-expose-headers: Date
    < cache-control: no-store