From 7b1ed0d12d0d57d93eb2cae01b0ceb0bf2c6b2ee Mon Sep 17 00:00:00 2001 From: Vasyl Saienko Date: Wed, 22 May 2024 10:32:33 +0300 Subject: [PATCH] Implement Designate resources in heat stack * dns records created via FIP extension * dns records created via ports extension * dns records created statically Related-Prod: PRODX-42483 Change-Id: I3611abef27401aceb7a3b2b5ba1d24517add5614 --- heat-templates/fragments/AppInstances.yaml | 20 +++++++ .../fragments/DatabaseInstances.yaml | 4 +- heat-templates/fragments/Network.yaml | 52 +++++++++++++++++++ heat-templates/top.yaml | 13 +++++ 4 files changed, 88 insertions(+), 1 deletion(-) diff --git a/heat-templates/fragments/AppInstances.yaml b/heat-templates/fragments/AppInstances.yaml index 6428091..b785f20 100644 --- a/heat-templates/fragments/AppInstances.yaml +++ b/heat-templates/fragments/AppInstances.yaml @@ -63,6 +63,10 @@ parameters: type: string description: Protocol for App loadbalancer default: HTTP + app_dns_zone_id: + type: string + app_dns_zone_name: + type: string conditions: deploy_additional_app_listener: @@ -301,18 +305,24 @@ resources: properties: floating_network_id: { get_param: public_network_id } port_id: { get_resource: private_server_01_port } + dns_name: app01 + dns_domain: { get_param: app_dns_zone_name } server_02_floating_ip: type: OS::Neutron::FloatingIP properties: floating_network_id: { get_param: public_network_id } port_id: { get_resource: private_server_02_port } + dns_name: app02 + dns_domain: { get_param: app_dns_zone_name } server_03_floating_ip: type: OS::Neutron::FloatingIP properties: floating_network_id: { get_param: public_network_id } port_id: { get_resource: private_server_03_port } + dns_name: app03 + dns_domain: { get_param: app_dns_zone_name } server_04_floating_ip: type: OS::Neutron::FloatingIP @@ -320,6 +330,8 @@ resources: properties: floating_network_id: { get_param: public_network_id } port_id: { get_resource: private_server_04_port } + dns_name: app04 + dns_domain: { get_param: app_dns_zone_name } wait_handle: type: OS::Heat::WaitConditionHandle @@ -403,6 +415,14 @@ resources: floating_network_id: {get_param: public_network_id} port_id: {get_attr: [lb, vip_port_id]} + app_vip_redcordset: + type: OS::Designate::RecordSet + properties: + name: app-vip + records: [ { get_attr: [ lb_floating, floating_ip_address ] } ] + type: A + zone: { get_param: app_dns_zone_id } + outputs: app_private_ips: description: Private IP addresses of app nodes diff --git a/heat-templates/fragments/DatabaseInstances.yaml b/heat-templates/fragments/DatabaseInstances.yaml index 0cf3102..21be2a0 100644 --- a/heat-templates/fragments/DatabaseInstances.yaml +++ b/heat-templates/fragments/DatabaseInstances.yaml @@ -200,6 +200,7 @@ resources: properties: network_id: { get_param: database_network_id } port_security_enabled: false + dns_name: db01 fixed_ips: - subnet: { get_param: database_subnet_id } @@ -208,6 +209,7 @@ resources: properties: network_id: { get_param: database_network_id } port_security_enabled: false + dns_name: db02 fixed_ips: - subnet: { get_param: database_subnet_id } @@ -216,6 +218,7 @@ resources: properties: network_id: { get_param: database_network_id } port_security_enabled: false + dns_name: db03 fixed_ips: - subnet: { get_param: database_subnet_id } @@ -350,7 +353,6 @@ resources: protocol_port: 3306 subnet: { get_param: database_subnet_id } - outputs: database_private_ips: description: Private IP addresses of database nodes diff --git a/heat-templates/fragments/Network.yaml b/heat-templates/fragments/Network.yaml index e2ed60d..acfcb8a 100644 --- a/heat-templates/fragments/Network.yaml +++ b/heat-templates/fragments/Network.yaml @@ -11,11 +11,35 @@ parameters: default: 'public' dns_nameservers: type: json + dns_zone: + type: string resources: + dns_random_string: + type: OS::Heat::RandomString + properties: + character_classes: [{"class": lowercase, "min": 10}] + length: 10 + + database_zone_name: + type: OS::Heat::Value + properties: + value: + list_join: [ '.', [ { get_resource: dns_random_string }, 'db', { get_param: dns_zone } ]] + type: string + + database_zone: + type: OS::Designate::Zone + properties: + name: { get_attr: [database_zone_name, value] } + description: String + email: refapp-admin@test.test + database_network: type: OS::Neutron::Net + properties: + dns_domain: { get_attr: [database_zone_name, value] } database_subnet: type: OS::Neutron::Subnet properties: @@ -24,8 +48,24 @@ resources: cidr: { get_param: database_network_cidr } dns_nameservers: { get_param: dns_nameservers } + app_zone_name: + type: OS::Heat::Value + properties: + value: + list_join: [ '.', [ { get_resource: dns_random_string }, 'app', { get_param: dns_zone } ]] + type: string + + app_zone: + type: OS::Designate::Zone + properties: + name: { get_attr: [app_zone_name, value] } + description: String + email: refapp-admin@test.test + app_network: type: OS::Neutron::Net + properties: + dns_domain: { get_attr: [app_zone_name, value] } app_subnet: type: OS::Neutron::Subnet properties: @@ -59,9 +99,21 @@ outputs: database_subnet_id: description: The uuid of database subnet value: { get_resource: database_subnet } + database_dns_zone_id: + description: The uuid of refapp DB DNS zone + value: { get_resource: database_zone } + database_dns_zone_name: + description: The name for DNS zone with database refapp + value: { get_attr: [database_zone_name, value] } app_network_id: description: The uuid of app network value: { get_resource: app_network } app_subnet_id: description: The uuid of app subnet value: { get_resource: app_subnet } + app_dns_zone_id: + description: The uuid of refapp APP DNS zone + value: { get_resource: app_zone } + app_dns_zone_name: + description: The name for DNS zone with APPs refapp + value: { get_attr: [app_zone_name, value] } diff --git a/heat-templates/top.yaml b/heat-templates/top.yaml index 6c86a95..9982cf3 100644 --- a/heat-templates/top.yaml +++ b/heat-templates/top.yaml @@ -64,6 +64,10 @@ parameters: type: string description: Algorithm for Database loadbalancer default: SOURCE_IP + dns_zone: + type: string + default: 'refapp.test.' + resources: key_pair: type: OS::Nova::KeyPair @@ -79,6 +83,7 @@ resources: app_network_cidr: { get_param: app_network_cidr } public_network_id: { get_param: public_network_id } dns_nameservers: { get_param: dns_nameservers } + dns_zone: { get_param: dns_zone } database: type: ./fragments/DatabaseInstances.yaml @@ -116,6 +121,8 @@ resources: app_lb_algorithm: { get_param: app_lb_algorithm } app_lb_protocol: { get_param: app_lb_protocol } app_database_password: { get_param: app_database_password } + app_dns_zone_id: { get_attr: [network, app_dns_zone_id ] } + app_dns_zone_name: { get_attr: [network, app_dns_zone_name ] } outputs: database_private_ips: @@ -133,6 +140,12 @@ outputs: database_floating_ips: description: Database instances floating IPs value: { get_attr: [database, database_floating_ips] } + database_dns_zone_name: + description: The name for DNS zone with database refapp + value: { get_attr: [database, app_dns_zone_name] } + app_dns_zone_name: + description: The name for DNS zone with APPs refapp + value: { get_attr: [app, database_dns_zone_name] } app_url: description: API url for the reference application value: