3.3. 在 Red Hat Ansible Automation Platform operator 上为自动化控制器配置外部数据库
对于希望使用外部数据库部署 Ansible Automation Platform 的用户,可以通过使用实例凭证和连接信息配置 secret,然后使用 oc create
命令将其应用到其集群中。
默认情况下,Red Hat Ansible Automation Platform Operator 会在与 Ansible Automation Platform 部署相同的命名空间中创建并配置一个受管 PostgreSQL pod。您可以使用外部数据库部署 Ansible Automation Platform,而不是 Red Hat Ansible Automation Platform Operator 自动创建的受管 PostgreSQL pod。
使用外部数据库可让您共享和重复使用资源,并手动管理备份、升级和性能优化。
只要数据库名称不同,同一个外部数据库(PostgreSQL 实例)可用于自动化 hub 和自动化控制器。换句话说,您可以在一个 PostgreSQL 实例中,带有使用不同名称的多个数据库。
以下部分概述了在 Ansible Automation Platform operator 上为自动化控制器配置外部数据库的步骤。
前提条件
外部数据库必须是 PostgreSQL 数据库,这是 Ansible Automation Platform 当前发行版本支持的版本。
Ansible Automation Platform 2.4 支持 PostgreSQL 13。
流程
外部 postgres 实例凭证和连接信息必须存储在 secret 中,然后在自动化控制器 spec 中设置。
按照下面的模板,创建一个
postgres_configuration_secret
.yaml 文件:apiVersion: v1 kind: Secret metadata: name: external-postgres-configuration namespace: <target_namespace> 1 stringData: host: "<external_ip_or_url_resolvable_by_the_cluster>" 2 port: "<external_port>" 3 database: "<desired_database_name>" username: "<username_to_connect_as>" password: "<password_to_connect_with>" 4 sslmode: "prefer" 5 type: "unmanaged" type: Opaque
使用
oc create
命令将external-postgres-configuration-secret.yml
应用到您的集群。$ oc create -f external-postgres-configuration-secret.yml
在创建
AutomationController
自定义资源对象时,在 spec 中指定 secret,参见以下示例:apiVersion: automationcontroller.ansible.com/v1beta1 kind: AutomationController metadata: name: controller-dev spec: postgres_configuration_secret: external-postgres-configuration