5.2. 准备迁移
在将当前 Ansible Automation Platform 部署迁移到 Ansible Automation Platform Operator 之前,您必须备份现有数据,并为 secret 密钥和 postgresql 配置创建 Kubernetes secret。
如果要迁移自动化控制器和自动化中心实例,请重复 创建 secret 密钥 secret 的步骤并为这两者 创建一个 postgresql 配置 secret,然后继续 将数据迁移到 Ansible Automation Platform Operator。
5.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.4 迁移数据前,您必须备份数据以防止丢失。
流程
- 登录您当前的部署项目。
-
运行
$ ./setup.sh -b
以创建当前数据或部署的备份。
5.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
)。
流程
- 在之前安装中用于部署 Ansible Automation Platform 的清单文件中找到旧的 secret 密钥。
为您的 secret 密钥创建 YAML 文件:
--- apiVersion: v1 kind: Secret metadata: name: <controller-resourcename>-secret-key namespace: <target-namespace> stringData: secret_key: <content of /etc/tower/SECRET_KEY from old controller> type: Opaque --- apiVersion: v1 kind: Secret metadata: name: <eda-resourcename>-secret-key namespace: <target-namespace> stringData: secret_key: </etc/ansible-automation-platform/eda/SECRET_KEY> type: Opaque --- apiVersion: v1 kind: Secret metadata: name: <hub-resourcename>-secret-key namespace: <target-namespace> stringData: database_fields.symmetric.key: </etc/pulp/certs/database_fields.symmetric.key> type: Opaque
注意如果没有提供
admin_password_secret
,Operator 会为 admin 密码查找名为 <resourcename>-admin-password
的 secret。如果不存在,Operator 会生成密码并从中创建一个名为 <resourcename>-admin-password
的 secret。将 secret 密钥 YAML 应用到集群:
oc apply -f <yaml-file>
5.2.3. 创建 postgresql 配置 secret
要成功迁移,您必须为现有部署提供数据库的访问权限。
流程
为您的 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
- 将 postgresql 配置 yaml 应用到集群:
oc apply -f <old-postgres-configuration.yml>
5.2.4. 验证网络连接
要确保成功迁移数据,请验证您是否有从新操作器部署到旧部署数据库的网络连接。
先决条件
记录现有部署的主机和端口信息。此信息位于位于 conf.d 目录中的 postgres.py 文件中。
流程
创建 YAML 文件以验证新部署和旧部署数据库之间的连接:
apiVersion: v1 kind: Pod metadata: name: dbchecker spec: containers: - name: dbchecker image: registry.redhat.io/rhel8/postgresql-13:latest command: ["sleep"] args: ["600"]
将 connection checker yaml 文件应用到您的新项目更新中:
oc project ansible-automation-platform oc apply -f connection_checker.yaml
验证连接检查程序 pod 是否正在运行:
oc get pods
连接到 pod shell:
oc rsh dbchecker
在 pod 中打开 shell 会话后,验证新项目是否可以连接到您的旧项目集群:
pg_isready -h <old-host-address> -p <old-port-number> -U AutomationContoller
示例
<old-host-address>:<old-port-number> - accepting connections