4.4. 在 Red Hat Ansible Automation Platform operator 上为自动化中心配置外部数据库
对于希望使用外部数据库部署 Ansible Automation Platform 的用户,可以通过使用实例凭证和连接信息配置 secret,然后使用 oc create 命令将其应用到其集群中。
默认情况下,Red Hat Ansible Automation Platform Operator 会在与 Ansible Automation Platform 部署相同的命名空间中创建并配置一个受管 PostgreSQL pod。
如果用户更喜欢使用专用节点来确保专用资源或手动管理备份、升级或性能调整,则用户可能会选择使用外部数据库。
只要数据库名称不同,同一个外部数据库(PostgreSQL 实例)可用于自动化 hub 和自动化控制器。换句话说,您可以在一个 PostgreSQL 实例中,带有使用不同名称的多个数据库。
以下概述了在 Ansible Automation Platform operator 上为您的自动化中心配置外部数据库的步骤。
前提条件
外部数据库必须是 PostgreSQL 数据库,这是 Ansible Automation Platform 当前发行版本支持的版本。
Ansible Automation Platform 2.0 和 2.1 支持 PostgreSQL 12。
步骤
外部 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在创建
AutomationHub自定义资源对象时,在 spec 中指定 secret,如下例所示:apiVersion: awx.ansible.com/v1beta1 kind: AutomationHub metadata: name: hub-dev spec: postgres_configuration_secret: external-postgres-configuration