8.2. 准备迁移

在将当前的 Ansible Automation Platform 部署迁移到 Ansible Automation Platform Operator 之前,您需要备份您的现有数据,为 secret 密钥和 postgresql 配置创建 k8s secret。

注意

如果要迁移自动化控制器和自动化中心实例,请重复 创建 secret 密钥 secret 的步骤并为这两者 创建一个 postgresql 配置 secret,然后继续 将数据迁移到 Ansible Automation Platform Operator

8.2.1. 先决条件

要将 Ansible Automation Platform 部署迁移到 Ansible Automation Platform Operator,您必须有以下几项:

  • Secret 密钥 secret
  • PostgreSQL 配置
  • 新 OpenShift 集群上命名空间的基于角色的访问控制
  • 新的 OpenShift 集群必须能够连接到前面的 PostgreSQL 数据库
注意

Secret 密钥信息可以位于初始 Red Hat Ansible Automation Platform 安装过程中创建的清单文件中。如果您无法记住您的 secret 密钥或发现您的清单文件时遇到问题,请通过红帽客户门户网站联系 Ansible 支持

在从 Ansible Automation Platform 2.x 或更早版本迁移数据前,您必须备份您的数据以防丢失。要备份数据,请执行以下操作:

流程

  1. 登录您当前的部署项目。
  2. 运行 setup.sh 来创建当前数据/部署的备份:

    对于版本 2.x 或更早版本的前文部署:

    $ ./setup.sh -b

    对于版本 2.0 之前的 OpenShift 部署(非 Operator 部署):

    ./setup_openshift.sh -b

8.2.2. 创建 secret 密钥 secret

要将数据迁移到 OpenShift Container Platform 上的 Ansible Automation Platform Operator,您必须创建一个 secret 密钥,该 secret 键与清单文件在初始安装过程中定义的 secret 键匹配。否则,迁移后,迁移的数据将保持加密且不可用。

流程

  1. 在之前安装中用于部署 AAP 的清单文件中找到旧的 secret 密钥。
  2. 为您的 secret 密钥创建一个 yaml 文件:

    apiVersion: v1
    kind: Secret
    metadata:
      name: <resourcename>-secret-key
      namespace: <target-namespace>
    stringData:
      secret_key: <old-secret-key>
    type: Opaque
  3. 将 secret key yaml 应用到集群:

    oc apply -f <secret-key.yml>

8.2.3. 创建 postgresql 配置 secret

要成功迁移,您必须为现有部署提供数据库的访问权限。

流程

  1. 为您的 postgresql 配置 secret 创建 yaml 文件:

    apiVersion: v1
    kind: Secret
    metadata:
      name: <resourcename>-old-postgres-configuration
      namespace: <target namespace>
    stringData:
      host: "<external ip or url resolvable by the cluster>"
      port: "<external port, this usually defaults to 5432>"
      database: "<desired database name>"
      username: "<username to connect as>"
      password: "<password to connect with>"
    type: Opaque
  2. 将 postgresql 配置 yaml 应用到集群:
oc apply -f <old-postgres-configuration.yml>

8.2.4. 验证网络连接

要确保成功迁移数据,请验证您是否有从新操作器部署到旧部署数据库的网络连接。

先决条件

记录现有部署的主机和端口信息。此信息位于位于 conf.d 目录中的 postgres.py 文件中。

流程

  1. 创建一个 yaml 文件来验证新部署和旧部署数据库之间的连接:

    apiVersion: v1
    kind: Pod
    metadata:
        name: dbchecker
    spec:
      containers:
        - name: dbchecker
          image: registry.redhat.io/rhel8/postgresql-13:latest
          command: ["sleep"]
          args: ["600"]
  2. 将 connection checker yaml 文件应用到您的新项目更新中:

    oc project ansible-automation-platform
    oc apply -f connection_checker.yaml
  3. 验证连接检查程序 pod 是否正在运行:

    oc get pods
  4. 连接到 pod shell:

    oc rsh dbchecker
  5. 在 pod 中打开 shell 会话后,验证新项目是否可以连接到您的旧项目集群:

    pg_isready -h <old-host-address> -p <old-port-number> -U awx

    示例

    <old-host-address>:<old-port-number> - accepting connections