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 Operator

先决条件

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

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

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

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

流程

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

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

    $ ./setup.sh -b
    Copy to Clipboard Toggle word wrap

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

    ./setup_openshift.sh -b
    Copy to Clipboard Toggle word wrap

8.2.2. 创建 secret 密钥 secret

要将数据迁移到 OpenShift Container Platform 上的 Ansible Automation Platform Operator,您必须创建一个 secret 密钥。如果要迁移自动化控制器、自动化中心和 Event-Driven Ansible,您必须在初始安装过程中具有与清单文件中定义的 secret 密钥匹配的 secret 密钥。否则,迁移的数据会在迁移后保持加密且不可用。

注意

在自定义资源中指定对称加密 secret 密钥时,请注意,对于自动化控制器,该字段名为 secret_key_name。但是,对于自动化中心和 Event-Driven Ansible,该字段名为 db_fields_encryption_secret

注意

在 Kubernetes secret 中,自动化控制器和 Event-Driven Ansible 使用相同的 stringData 密钥(secret_key),但自动化中心使用不同的密钥(database_fields.symmetric.key)。

流程

  1. 在之前安装中用于部署 Ansible Automation Platform 的清单文件中找到旧的 secret 密钥。
  2. 为您的 secret 密钥创建 YAML 文件:

    ---
    apiVersion: v1
    kind: Secret
    metadata:
      name: <controller-resourcename>-secret-key
      namespace: <target-namespace>
    stringData:
      secret_key: <replaceme-with-controller-secret>
    type: Opaque
    ---
    apiVersion: v1
    kind: Secret
    metadata:
      name: <eda-resourcename>-secret-key
      namespace: <target-namespace>
    stringData:
      secret_key: <replaceme-with-eda-secret>
    type: Opaque
    ---
    apiVersion: v1
    kind: Secret
    metadata:
      name: <hub-resourcename>-secret-key
      namespace: <target-namespace>
    stringData:
      database_fields.symmetric.key: <replace-me-withdb-fields-encryption-key>
    type: Opaque
    Copy to Clipboard Toggle word wrap
    注意

    如果没有提供 admin_password_secret,Operator 会为 admin 密码查找名为 < resourcename>-admin-password 的 secret。如果不存在,Operator 会生成密码并从中创建一个名为 < resourcename>-admin-password 的 secret。

  3. 将 secret 密钥 YAML 应用到集群:

    oc apply -f <yaml-file>
    Copy to Clipboard Toggle word wrap

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
    Copy to Clipboard Toggle word wrap
  2. 将 postgresql 配置 yaml 应用到集群:
oc apply -f <old-postgres-configuration.yml>
Copy to Clipboard Toggle word wrap

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"]
    Copy to Clipboard Toggle word wrap
  2. 将 connection checker yaml 文件应用到您的新项目更新中:

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

    oc get pods
    Copy to Clipboard Toggle word wrap
  4. 连接到 pod shell:

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

    pg_isready -h <old-host-address> -p <old-port-number> -U awx
    Copy to Clipboard Toggle word wrap

    示例

    <old-host-address>:<old-port-number> - accepting connections
    Copy to Clipboard Toggle word wrap

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2025 Red Hat