Mark Vanderwiel | 2e923a7 | 2015-10-19 16:12:05 -0500 | [diff] [blame] | 1 | heat_template_version: 2015-04-30 |
| 2 | |
| 3 | description: | |
| 4 | Template which tests Neutron load balancing requests to members of |
| 5 | Heat AutoScalingGroup. This uses LBaas V2. |
| 6 | Instances must be running some webserver on a given app_port |
| 7 | producing HTTP response that is different between servers |
| 8 | but stable over time for given server. |
| 9 | |
| 10 | parameters: |
| 11 | flavor: |
| 12 | type: string |
| 13 | image: |
| 14 | type: string |
| 15 | net: |
| 16 | type: string |
| 17 | subnet: |
| 18 | type: string |
| 19 | public_net: |
| 20 | type: string |
| 21 | app_port: |
| 22 | type: number |
| 23 | default: 8080 |
| 24 | lb_port: |
| 25 | type: number |
| 26 | default: 80 |
| 27 | timeout: |
| 28 | type: number |
| 29 | default: 600 |
| 30 | |
| 31 | resources: |
| 32 | |
| 33 | sec_group: |
| 34 | type: OS::Neutron::SecurityGroup |
| 35 | properties: |
| 36 | rules: |
| 37 | - remote_ip_prefix: 0.0.0.0/0 |
| 38 | protocol: tcp |
| 39 | port_range_min: { get_param: app_port } |
| 40 | port_range_max: { get_param: app_port } |
| 41 | |
| 42 | asg: |
| 43 | type: OS::Heat::AutoScalingGroup |
| 44 | properties: |
| 45 | desired_capacity: 1 |
| 46 | max_size: 2 |
| 47 | min_size: 1 |
| 48 | resource: |
| 49 | type: OS::Test::NeutronAppServer |
| 50 | properties: |
| 51 | image: { get_param: image } |
| 52 | flavor: { get_param: flavor } |
| 53 | net: { get_param: net} |
| 54 | sec_group: { get_resource: sec_group } |
| 55 | app_port: { get_param: app_port } |
| 56 | pool: { get_resource: pool } |
| 57 | subnet: { get_param: subnet } |
| 58 | timeout: { get_param: timeout } |
| 59 | |
| 60 | scale_up: |
| 61 | type: OS::Heat::ScalingPolicy |
| 62 | properties: |
| 63 | adjustment_type: change_in_capacity |
| 64 | auto_scaling_group_id: { get_resource: asg } |
| 65 | scaling_adjustment: 1 |
| 66 | |
| 67 | scale_down: |
| 68 | type: OS::Heat::ScalingPolicy |
| 69 | properties: |
| 70 | adjustment_type: change_in_capacity |
| 71 | auto_scaling_group_id: { get_resource: asg } |
| 72 | scaling_adjustment: -1 |
| 73 | |
| 74 | health_monitor: |
| 75 | type: OS::Neutron::LBaaS::HealthMonitor |
| 76 | properties: |
| 77 | delay: 3 |
| 78 | type: HTTP |
| 79 | timeout: 3 |
| 80 | max_retries: 3 |
| 81 | pool: { get_resource: pool } |
| 82 | |
| 83 | pool: |
| 84 | type: OS::Neutron::LBaaS::Pool |
| 85 | properties: |
| 86 | lb_algorithm: ROUND_ROBIN |
| 87 | protocol: HTTP |
| 88 | listener: { get_resource: listener } |
| 89 | |
| 90 | listener: |
| 91 | type: OS::Neutron::LBaaS::Listener |
| 92 | properties: |
| 93 | loadbalancer: { get_resource: loadbalancer } |
| 94 | protocol: HTTP |
| 95 | protocol_port: { get_param: lb_port } |
| 96 | |
| 97 | loadbalancer: |
| 98 | type: OS::Neutron::LBaaS::LoadBalancer |
| 99 | properties: |
| 100 | vip_subnet: { get_param: subnet } |
| 101 | |
| 102 | floating_ip: |
| 103 | type: OS::Neutron::FloatingIP |
| 104 | properties: |
| 105 | floating_network: { get_param: public_net } |
| 106 | port_id: { get_attr: [loadbalancer, vip_port_id] } |
| 107 | |
| 108 | outputs: |
| 109 | lburl: |
| 110 | description: URL of the loadbalanced app |
| 111 | value: |
| 112 | str_replace: |
| 113 | template: http://IP_ADDRESS:PORT |
| 114 | params: |
| 115 | IP_ADDRESS: { get_attr: [ floating_ip, floating_ip_address ] } |
| 116 | PORT: { get_param: lb_port } |