Pavlo Shchelokovskyy | 9ede185 | 2015-03-19 17:54:52 +0000 | [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. |
| 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_id: { get_resource: pool } |
| 57 | timeout: { get_param: timeout } |
| 58 | |
| 59 | scale_up: |
| 60 | type: OS::Heat::ScalingPolicy |
| 61 | properties: |
| 62 | adjustment_type: change_in_capacity |
| 63 | auto_scaling_group_id: { get_resource: asg } |
| 64 | scaling_adjustment: 1 |
| 65 | |
| 66 | scale_down: |
| 67 | type: OS::Heat::ScalingPolicy |
| 68 | properties: |
| 69 | adjustment_type: change_in_capacity |
| 70 | auto_scaling_group_id: { get_resource: asg } |
| 71 | scaling_adjustment: -1 |
| 72 | |
| 73 | health_monitor: |
| 74 | type: OS::Neutron::HealthMonitor |
| 75 | properties: |
| 76 | delay: 3 |
| 77 | type: HTTP |
| 78 | timeout: 3 |
| 79 | max_retries: 3 |
| 80 | |
| 81 | pool: |
| 82 | type: OS::Neutron::Pool |
| 83 | properties: |
| 84 | lb_method: ROUND_ROBIN |
| 85 | protocol: HTTP |
| 86 | subnet: { get_param: subnet } |
| 87 | monitors: |
| 88 | - { get_resource: health_monitor } |
| 89 | vip: |
| 90 | protocol_port: { get_param: lb_port } |
| 91 | |
| 92 | floating_ip: |
| 93 | type: OS::Neutron::FloatingIP |
| 94 | properties: |
| 95 | floating_network: { get_param: public_net } |
| 96 | port_id: |
| 97 | { get_attr: [pool, vip, 'port_id'] } |
| 98 | |
| 99 | loadbalancer: |
| 100 | type: OS::Neutron::LoadBalancer |
| 101 | properties: |
| 102 | pool_id: { get_resource: pool } |
| 103 | protocol_port: { get_param: app_port } |
| 104 | |
| 105 | outputs: |
| 106 | lburl: |
| 107 | description: URL of the loadbalanced app |
| 108 | value: |
| 109 | str_replace: |
| 110 | template: http://IP_ADDRESS:PORT |
| 111 | params: |
| 112 | IP_ADDRESS: { get_attr: [ floating_ip, floating_ip_address ] } |
| 113 | PORT: { get_param: lb_port } |