配置多个池¶
管理员可以将 DNS 命名服务器分组到多个池中,以帮助他们管理其 DNS 环境。请参阅 DNS 服务器池,以了解有关池的更多信息以及如何使用它们。
将 Designate 配置为使用多个池包括
定义新的池并将它们的定义加载到数据库中。
使用您创建的过滤器或 Designate 提供的过滤器配置池调度器。
向用户提供所需池信息,以便他们在创建区域时指定。
定义新的池¶
在 Designate 中,您在池定义文件中定义一个新的池,然后通过运行 designate-manage 命令将定义加载到 Designate 数据库中。
按照“池定义文件”中 DNS 服务器池 中记录的 YAML 格式中的所需键值对,将池添加到池定义文件中。
这是一个池定义文件
pools.yaml的示例,它配置了两个不同的池。每个池支持不同的使用级别,gold 和 standard,并且每个池包含反映其各自使用级别的区域。gold 级别为用户提供 6 个名称服务器。 standard 级别仅提供 2 个名称服务器。两个池都有一个写入的目标。
--- - name: golden_pool description: The golden pool! attributes: service_tier: gold ns_records: - hostname: ns1-gold.example.org priority: 1 - hostname: ns2-gold.example.org priority: 2 - hostname: ns3-gold.example.net priority: 3 - hostname: ns4-gold.example.net priority: 4 - hostname: ns5-gold.example.net priority: 5 - hostname: ns6-gold.example.net priority: 6 nameservers: - host: ns1-gold.example.net port: 53 - host: ns2-gold.example.net port: 53 - host: ns3-gold.example.net port: 53 - host: ns4-gold.example.net port: 53 - host: ns5-gold.example.net port: 53 - host: ns6-gold.example.net port: 53 targets: - type: bind9 description: bind9 golden master masters: - host: mdns.designate.example.com port: 5354 options: host: ns-master-gold.example.org port: 53 rndc_host: ns-master-gold.example.org rndc_port: 953 rndc_key_file: /etc/designate.rndc.key - name: standard_pool description: The standard pool attributes: service_tier: standard ns_records: - hostname: ns1-std.example.org priority: 1 - hostname: ns2-std.example.org priority: 2 nameservers: - host: ns1-std.example.net port: 53 - host: ns2-std.example.net port: 53 targets: - type: bind9 description: bind9 golden master masters: - host: mdns.designate.example.com port: 5354 options: host: ns-master-std.example.org port: 53 rndc_host: ns-master-std.example.org rndc_port: 953 rndc_key_file: /etc/designate.rndc.key
使用
designate-manage pool update命令将定义加载到 Designate 数据库中# Do a dry run $ designate-manage pool update --file pools.yaml --dry-run $ designate-manage pool update --file pools.yaml
现在,Designate 具有两个可用的池。下一步是配置池调度器,以便在选择存储区域的池时使用通过过滤器提供的属性。
显示已配置的池¶
在 Designate 中,您可以通过运行 designate-manage pool show_config 命令来显示当前配置的默认池。您可以通过添加 –pool_id <POOL_ID> 来查看不同的池,或者通过添加 --all_pools 或只是 --all 来查看所有已配置的池。
配置池调度器¶
当用户创建区域时,池调度器使用过滤器将区域分配给特定的 DNS 服务器池。作为管理员,您选择一个有序的过滤器列表,该列表在每次 zone create API 请求上运行。您可以配置调度器以使用 Designate 提供的过滤器或创建您自己的过滤器。
执行以下操作之一
编写一个或多个自定义过滤器。
请参阅 池调度器过滤器。
选择 Designate 提供的过滤器之一或多个
attribute– 将区域分配给其属性被指定的池。pool_id_attribute– 如果用户是指定角色的成员,则将区域分配给其 ID 被指定的池。default_pool– 将区域分配给 Designate 配置文件中指定的默认池。fallback– 如果没有可用的池,则将区域分配给默认池。random– 如果已指定多个池,则随机将区域分配给一个池。in_doubt_default_pool– 如果没有指定池可用,并且未指定默认池,则将区域分配给默认池。
将您希望调度器使用的过滤器添加到
designate.conf文件的service:central部分。有关更多信息,请参阅 池调度器过滤器。
按池 ID 示例安排¶
例如,要允许用户通过指定 ID 或回退到使用默认值来选择池,可以使用以下配置
[service:central]
default_pool_id = 794ccc2c-d751-44fe-b57f-8894c9f5c842
scheduler_filters = pool_id_attribute, fallback
池调度器从左到右应用过滤器。如果区域主体不包含将 pool_id 设置为有效池 ID 的 attributes 对象,则调用回退过滤器,将默认池作为该区域的计划池返回。
按层级示例安排¶
在此层级示例中,使用 attribute 过滤器选择正确的池。
[service:central]
default_pool_id = 794ccc2c-d751-44fe-b57f-8894c9f5c842 # the std pool
scheduler_filters = attribute, fallback
当用户想要将区域分配给 gold 池时,用户必须在区域中提供适当的属性。
POST /v2/zones HTTP/1.1
Accept: application/json
Content-Type: application/json
{
"attributes": {
"service_tier": "gold"
},
"email": "user@example.com",
"name": "example.net."
}
在此示例中,用户定义了计划哪个池。如果应基于租户计划区域,则可以编写一个自定义过滤器,该过滤器查找适当的组并添加适当的池。