heat stack update is failed... add/remove of lbaasV2's multiple listeners/ports/healthmonitors

Bug #1737897 reported by JungJungIn
256
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Heat
New
Undecided
Unassigned

Bug Description

(Note: Attachement is archived file of my test heat templates. please see it and text.)
i installed Newton version openstack...
all is working nicely...

in heat, when i try create just autoscalinggroup(asg) + lbaasv2(lb) for one port(http/80) heat stack... it is working good.. below command is init heat with one http/80 port.

<init stack>
# openstack stack create -e env.yaml -t lbaasv2.yaml TEST-LB-PORTS

but, i update heat template for two port(add http 8080)... and i try update exist stack...

<add new listener/pool for adding port>
# openstack stack update -e env-add-port.yaml -t lbaasv2-add-port.yaml TEST-LB-PORTS

=> result is success... but topology of stack-info is not normal.. anyway.. load-balance of request is working...

and, i try remove http/8080... like below..

<delete one port>
# openstack stack update -e env-delete-port.yaml -t lbaasv2-delete-port.yaml TEST-LB-PORTS

=> result is "Update Failed"...
=> some resource is error... autoscalinggroup resource "group"
+------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| attributes | {u'outputs_list': None, u'refs': None, u'refs_map': None, u'outputs': None, u'current_size': None} |
| creation_time | 2017-12-13T08:01:01Z |
| description | |
| links | [{u'href': u'http://controller:8004/v1/fda1f4d139d941faaa170700c4e6cfd2/stacks/TEST-LB-PORTS/981b5080-aaae-48b1-9ec5-55d78c400c73/resources/group', |
| | u'rel': u'self'}, {u'href': u'http://controller:8004/v1/fda1f4d139d941faaa170700c4e6cfd2/stacks/TEST-LB-PORTS/981b5080-aaae-48b1-9ec5-55d78c400c73', |
| | u'rel': u'stack'}, {u'href': u'http://controller:8004/v1/fda1f4d139d941faaa170700c4e6cfd2/stacks/TEST-LB-PORTS-group-iwjqhx44tuje/58e3160e-5e96-49d9 |
| | -bf4b-8b34105f7614', u'rel': u'nested'}] |
| logical_resource_id | group |
| physical_resource_id | 58e3160e-5e96-49d9-bf4b-8b34105f7614 |
| required_by | [u'scaleup_policy', u'scaledown_policy'] |
| resource_name | group |
| resource_status | UPDATE_FAILED |
| resource_status_reason | resources.group: Property error: resources.s3zu7lndwxtw.properties: unknown in facade pool_id2 |
| resource_type | OS::Heat::AutoScalingGroup |
| updated_time | 2017-12-13T08:04:09Z |
+------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

resource "pool_id2" is not exist in 'lbaasv2-delete-port.yaml',,, but resource "group" require "pool_id2"... why?

heat of newton version don't support add/delete listener/pool of lbaasv2 with "stack update"?

this is bug? or my miss configuration?

anyone.. help me...

========= Attachement ============================

(lbaasv2.yaml)

heat_template_version: 2016-10-14
description: A simple auto scaling group with LBaaS V2 Service.

#
# Common parameter definitions:
#
parameters:

  my_flavor:
    type: string
    description: Flavor for the server to be created
    default: "t1"
    constraints:
      - custom_constraint: nova.flavor

  my_accesskey:
    type: string
    description: Name of an existing key-pair
    default: "jijeong"
    constraints:
      - custom_constraint: nova.keypair

  my_image:
    type: string
    description: Image ID or image name to use for the server
    default: "Ubuntu 16.04 LTS"
    constraints:
      - custom_constraint: glance.image

  my_public_network:
    type: string
    description: Neutron Public Network
    default: "ext-net"
    constraints:
      - custom_constraint: neutron.network

  my_private_network:
    type: string
    description: Neutron Private Network
    default: "demo-net"
    constraints:
      - custom_constraint: neutron.network

  my_private_subnet:
    type: string
    description: Neutron SUB-Network
    default: "private-subnet"

  my_zone:
    type: string
    description: Availability Zone
    default: "nova"

  app_port1:
    type: string
    description: Aplication TCP Port
    default: "80"

  application_install:
    type: string
    description: HTTP Application to install
    default: "apache2"

#
# Resource Definitions
#
# Please note: The AutoScaing group resource "OS::Nova::Server::Webserver
# is defined in the environment file. You'll find with this template 3 more
# support files:
# - Template-AutoScaling-LBaaSV2-ENV-LocalCLI.yaml: Environment version to
# be used with openstack or heat "cli". It assumes your server file is
# located in the same directory as the template
# - Template-AutoScaling-LBaaSV2-ENV-HTTP-Server.yaml: Environment version
# wich assumes your server file is located in a URL (a web server).
# - webserver_lb.yaml: Your server file. Depending of your environment file,
# you should have this file locally or in a web server.
#
#
resources:

#
# Our LBaaS V2 "Load Balancer"
#
  lb:
    type: OS::Neutron::LBaaS::LoadBalancer
    properties:
      vip_subnet: { get_param: my_private_subnet }

#
# Our LBaaS V2 Listener
#
  listener1:
    type: OS::Neutron::LBaaS::Listener
    #depends_on: lb
    properties:
      loadbalancer: { get_resource: lb }
      protocol: HTTP
      protocol_port: { get_param: app_port1 }

#
# Our LBaaS V2 Pool
#
  pool1:
    type: OS::Neutron::LBaaS::Pool
    #depends_on: listener1
    properties:
      lb_algorithm: ROUND_ROBIN
      protocol: HTTP
      listener: { get_resource: listener1 }

#
# Our LBaaS V2 Health Monitor.
#
  monitor1:
    type: OS::Neutron::LBaaS::HealthMonitor
    #depends_on: pool1
    properties:
      delay: 5
      type: HTTP
      timeout: 5
      max_retries: 3
      pool: { get_resource: pool1 }

#
# Our Floating for LB-VIP
#
  floating_ip:
    type: OS::Neutron::FloatingIP
    #depends_on: lb
    properties:
      floating_network: { get_param: my_public_network }
      port_id: { get_attr: [lb, vip_port_id ]}

#
# Security Group with access to icmp, tcp port 22 (ssh) and the web application
# port
#
  sec_group:
    type: OS::Neutron::SecurityGroup
    properties:
      rules:
      - remote_ip_prefix: 0.0.0.0/0
        protocol: tcp
        port_range_min: { get_param: app_port1 }
        port_range_max: { get_param: app_port1 }
      - remote_ip_prefix: 0.0.0.0/0
        protocol: tcp
        port_range_min: 22
        port_range_max: 22
      - remote_ip_prefix: 0.0.0.0/0
        protocol: icmp

#
# Our main autoscaling group
#
  group:
    type: OS::Heat::AutoScalingGroup
    #depends_on: [ sec_group, pool1 ]
    properties:
      cooldown: 60
      desired_capacity: 2
      max_size: 3
      min_size: 2
      resource:
        type: OS::Nova::Server::Webserver
        properties:
          metadata: {"metering.stack": {get_param: "OS::stack_id"}}
          pool_id1: { get_resource: pool1 }
          instance_flavor: { get_param: my_flavor }
          server_network: { get_param: my_private_network }
          server_subnet: { get_param: my_private_subnet }
          server_image: { get_param: my_image }
          server_zone: { get_param: my_zone }
          server_secgroup: { get_resource: sec_group }
          server_port1: { get_param: app_port1 }
          server_key: { get_param: my_accesskey }
          app_install: { get_param: application_install }

#
# Scale-up-and-down policies:
#
  scaleup_policy:
    type: OS::Heat::ScalingPolicy
    #depends_on: group
    properties:
      adjustment_type: change_in_capacity
      auto_scaling_group_id: { get_resource: group }
      cooldown: 60
      scaling_adjustment: 1

  scaledown_policy:
    type: OS::Heat::ScalingPolicy
    #depends_on: group
    properties:
      adjustment_type: change_in_capacity
      auto_scaling_group_id: { get_resource: group }
      cooldown: 60
      scaling_adjustment: -1

#
# Our alarms:
#
  cpu_alarm_high:
    type: OS::Ceilometer::Alarm
    #depends_on: scaleup_policy
    properties:
      meter_name: cpu_util
      description: Scale-up if the average CPU > 50% for 1 minute
      statistic: avg
      period: 60
      evaluation_periods: 1
      threshold: 50
      alarm_actions:
        - {get_attr: [scaleup_policy, alarm_url]}
# - str_replace:
# template: http://172.16.0.11/lb_test.php?task=UP&stack_id=$STACK_ID
# params:
# $STACK_ID: {get_param: "OS::stack_id"}
      comparison_operator: gt
      matching_metadata: {'metadata.user_metadata.stack': {get_param: "OS::stack_id"}}

  cpu_alarm_low:
    type: OS::Ceilometer::Alarm
    #depends_on: scaledown_policy
    properties:
      meter_name: cpu_util
      description: Scale-down if the average CPU < 15% for 10 minutes
      statistic: avg
      period: 600
      evaluation_periods: 1
      threshold: 15
      alarm_actions:
        - {get_attr: [scaledown_policy, alarm_url]}
# - str_replace:
# template: http://172.16.0.11/lb_test.php?task=DOWN&stack_id=$STACK_ID
# params:
# $STACK_ID: {get_param: "OS::stack_id"}
      comparison_operator: lt
      matching_metadata: {'metadata.user_metadata.stack': {get_param: "OS::stack_id"}}

#
# And, our output:
#
outputs:
  Scale-UP-URL:
    value: {get_attr: [scaleup_policy, alarm_url]}
    description: Scale-UP ALARM URL
  Scale-DOWN-URL:
    value: {get_attr: [scaledown_policy, alarm_url]}
    description: Scale-DOWN ALARM URL
  Scale-UP-SIGNAL-URL:
    value: {get_attr: [scaleup_policy, signal_url]}
    description: Scale-UP Signal URL
  Scale-DOWN-SIGNAL-URL:
    value: {get_attr: [scaledown_policy, signal_url]}
    description: Scale-DOWN Signal URL
  LB-URL1:
    value:
      str_replace:
        template: http://IP_ADDRESS:PORT1
        params:
          IP_ADDRESS: { get_attr: [ floating_ip, floating_ip_address ] }
          PORT1: { get_param: app_port1 }

(webserver.yaml)
heat_template_version: 2016-10-14
description: Simple Ubuntu BASED Server with Apache and included in a pool.

#
# Common parameter definitions:
# Thos parameters are passed by the main HEAT template
#
parameters:

  metadata:
    type: json

  pool_id1:
    type: string
    description: LB Service Pool

  instance_flavor:
    type: string
    description: Instance Flavor

  server_network:
    type: string
    description: Instance Network

  server_subnet:
    type: string
    description: Instance Subnet (as a "member")

  server_image:
    type: string
    description: Instance Base Image

  server_zone:
    type: string
    description: Instance Availability Zone

  server_secgroup:
    type: string
    description: Instance Security Group

  server_port1:
    type: string
    description: Instance Application Group

  server_key:
    type: string
    description: Instance SSH Access Key

  app_install:
    type: string
    description: Instance HTTP Application

#
# Our resources:
#
resources:

#
# Our NOVA Instance definition:
#
  server:
    type: OS::Nova::Server
    properties:
      key_name: {get_param: server_key}
      security_groups: [{get_param: server_secgroup}]
      image: {get_param: server_image}
      availability_zone: {get_param: server_zone}
      flavor: {get_param: instance_flavor}
      networks:
        - network: {get_param: server_network}
      user_data_format: RAW
      metadata: {get_param: metadata}
      user_data:
        str_replace:
          template: |
            #!/bin/bash
            # This is our bootstrap secuence
            myapp="$selectedapp01"
            echo "MY APP IS $myapp"
            PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
            echo "INSTALLING APACHE2"
            apt-get update
            apt-get -y install apache2
            hostname > /var/www/html/index.html
            echo "<br>" >> /var/www/html/index.html
            curl -s http://169.254.169.254/latest/meta-data/local-ipv4 >> /var/www/html/index.html
            sed -i '/^Listen/a Listen 8080' /etc/apache2/ports.conf
            systemctl restart apache2.service
            # Comment the following two lines in order if you don't want to force
            # a autoscale event at boot
            while [ 1 ] ; do echo $((13**99)) 1>/dev/null 2>&1; done &
            while [ 1 ] ; do echo $((13**99)) 1>/dev/null 2>&1; done &
          params:
            $selectedapp01: {get_param: app_install}
#
# LBaaS V2 Member definition
#
  member1:
    type: OS::Neutron::LBaaS::PoolMember
    #depends_on: server
    properties:
      pool: { get_param: pool_id1 }
      address: { get_attr: [server, first_address] }
      protocol_port: { get_param: server_port1 }
      subnet: { get_param: server_subnet }

(env.yaml)
resource_registry:
    "OS::Nova::Server::Webserver": webserver.yaml

(lbaasv2-add-port.yaml)
heat_template_version: 2016-10-14
description: A simple auto scaling group with LBaaS V2 Service.

#
# Common parameter definitions:
#
parameters:

  my_flavor:
    type: string
    description: Flavor for the server to be created
    default: "t1"
    constraints:
      - custom_constraint: nova.flavor

  my_accesskey:
    type: string
    description: Name of an existing key-pair
    default: "jijeong"
    constraints:
      - custom_constraint: nova.keypair

  my_image:
    type: string
    description: Image ID or image name to use for the server
    default: "Ubuntu 16.04 LTS"
    constraints:
      - custom_constraint: glance.image

  my_public_network:
    type: string
    description: Neutron Public Network
    default: "ext-net"
    constraints:
      - custom_constraint: neutron.network

  my_private_network:
    type: string
    description: Neutron Private Network
    default: "demo-net"
    constraints:
      - custom_constraint: neutron.network

  my_private_subnet:
    type: string
    description: Neutron SUB-Network
    default: "private-subnet"

  my_zone:
    type: string
    description: Availability Zone
    default: "nova"

  app_port1:
    type: string
    description: Aplication TCP Port
    default: "80"

  app_port2:
    type: string
    description: Aplication TCP Port
    default: "8080"

  application_install:
    type: string
    description: HTTP Application to install
    default: "apache2"

#
# Resource Definitions
#
# Please note: The AutoScaing group resource "OS::Nova::Server::Webserver
# is defined in the environment file. You'll find with this template 3 more
# support files:
# - Template-AutoScaling-LBaaSV2-ENV-LocalCLI.yaml: Environment version to
# be used with openstack or heat "cli". It assumes your server file is
# located in the same directory as the template
# - Template-AutoScaling-LBaaSV2-ENV-HTTP-Server.yaml: Environment version
# wich assumes your server file is located in a URL (a web server).
# - webserver_lb.yaml: Your server file. Depending of your environment file,
# you should have this file locally or in a web server.
#
#
resources:

#
# Our LBaaS V2 "Load Balancer"
#
  lb:
    type: OS::Neutron::LBaaS::LoadBalancer
    properties:
      vip_subnet: { get_param: my_private_subnet }

#
# Our LBaaS V2 Listener
#
  listener1:
    type: OS::Neutron::LBaaS::Listener
    #depends_on: lb
    properties:
      loadbalancer: { get_resource: lb }
      protocol: HTTP
      protocol_port: { get_param: app_port1 }

  listener2:
    type: OS::Neutron::LBaaS::Listener
    #depends_on: lb
    properties:
      loadbalancer: { get_resource: lb }
      protocol: HTTP
      protocol_port: { get_param: app_port2 }

#
# Our LBaaS V2 Pool
#
  pool1:
    type: OS::Neutron::LBaaS::Pool
    #depends_on: listener1
    properties:
      lb_algorithm: ROUND_ROBIN
      protocol: HTTP
      listener: { get_resource: listener1 }

  pool2:
    type: OS::Neutron::LBaaS::Pool
    #depends_on: listener2
    properties:
      lb_algorithm: ROUND_ROBIN
      protocol: HTTP
      listener: { get_resource: listener2 }

#
# Our LBaaS V2 Health Monitor.
#
  monitor1:
    type: OS::Neutron::LBaaS::HealthMonitor
    #depends_on: pool1
    properties:
      delay: 5
      type: HTTP
      timeout: 5
      max_retries: 3
      pool: { get_resource: pool1 }

  monitor2:
    type: OS::Neutron::LBaaS::HealthMonitor
    #depends_on: pool2
    properties:
      delay: 5
      type: HTTP
      timeout: 5
      max_retries: 3
      pool: { get_resource: pool2 }

#
# Our Floating for LB-VIP
#
  floating_ip:
    type: OS::Neutron::FloatingIP
    #depends_on: lb
    properties:
      floating_network: { get_param: my_public_network }
      port_id: { get_attr: [lb, vip_port_id ]}

#
# Security Group with access to icmp, tcp port 22 (ssh) and the web application
# port
#
  sec_group:
    type: OS::Neutron::SecurityGroup
    properties:
      rules:
      - remote_ip_prefix: 0.0.0.0/0
        protocol: tcp
        port_range_min: { get_param: app_port1 }
        port_range_max: { get_param: app_port1 }
      - remote_ip_prefix: 0.0.0.0/0
        protocol: tcp
        port_range_min: { get_param: app_port2 }
        port_range_max: { get_param: app_port2 }
# - remote_ip_prefix: 0.0.0.0/0
# protocol: tcp
# port_range_min: 22
# port_range_max: 22
      - remote_ip_prefix: 0.0.0.0/0
        protocol: icmp

#
# Our main autoscaling group
#
  group:
    type: OS::Heat::AutoScalingGroup
    #depends_on: [ sec_group, pool1, pool2 ]
    properties:
      cooldown: 60
      desired_capacity: 3
      max_size: 10
      min_size: 2
      resource:
        type: OS::Nova::Server::Webserver
        properties:
          metadata: {"metering.stack": {get_param: "OS::stack_id"}}
          pool_id1: { get_resource: pool1 }
          pool_id2: { get_resource: pool2 }
          instance_flavor: { get_param: my_flavor }
          server_network: { get_param: my_private_network }
          server_subnet: { get_param: my_private_subnet }
          server_image: { get_param: my_image }
          server_zone: { get_param: my_zone }
          server_secgroup: { get_resource: sec_group }
          server_port1: { get_param: app_port1 }
          server_port2: { get_param: app_port2 }
          server_key: { get_param: my_accesskey }
          app_install: { get_param: application_install }

#
# Scale-up-and-down policies:
#
  scaleup_policy:
    type: OS::Heat::ScalingPolicy
    #depends_on: group
    properties:
      adjustment_type: change_in_capacity
      auto_scaling_group_id: { get_resource: group }
      cooldown: 60
      scaling_adjustment: 1

  scaledown_policy:
    type: OS::Heat::ScalingPolicy
    #depends_on: group
    properties:
      adjustment_type: change_in_capacity
      auto_scaling_group_id: { get_resource: group }
      cooldown: 60
      scaling_adjustment: -1

#
# Our alarms:
#
  cpu_alarm_high:
    type: OS::Ceilometer::Alarm
    #depends_on: scaleup_policy
    properties:
      meter_name: cpu_util
      description: Scale-up if the average CPU > 50% for 1 minute
      statistic: avg
      period: 60
      evaluation_periods: 1
      threshold: 50
      alarm_actions:
        - {get_attr: [scaleup_policy, alarm_url]}
      comparison_operator: gt
      matching_metadata: {'metadata.user_metadata.stack': {get_param: "OS::stack_id"}}

  cpu_alarm_low:
    type: OS::Ceilometer::Alarm
    #depends_on: scaledown_policy
    properties:
      meter_name: cpu_util
      description: Scale-down if the average CPU < 15% for 10 minutes
      statistic: avg
      period: 600
      evaluation_periods: 1
      threshold: 15
      alarm_actions:
        - {get_attr: [scaledown_policy, alarm_url]}
      comparison_operator: lt
      matching_metadata: {'metadata.user_metadata.stack': {get_param: "OS::stack_id"}}

#
# And, our output:
#
outputs:
  Scale-UP-URL:
    value: {get_attr: [scaleup_policy, alarm_url]}
    description: Scale-UP ALARM URL
  Scale-DOWN-URL:
    value: {get_attr: [scaledown_policy, alarm_url]}
    description: Scale-DOWN ALARM URL
  Scale-UP-SIGNAL-URL:
    value: {get_attr: [scaleup_policy, signal_url]}
    description: Scale-UP Signal URL
  Scale-DOWN-SIGNAL-URL:
    value: {get_attr: [scaledown_policy, signal_url]}
    description: Scale-DOWN Signal URL
  LB-URL1:
    value:
      str_replace:
        template:
          http://IP_ADDRESS:PORT1
        params:
          IP_ADDRESS: { get_attr: [ floating_ip, floating_ip_address ] }
          PORT1: { get_param: app_port1 }
  LB-URL2:
    value:
      str_replace:
        template:
          http://IP_ADDRESS:PORT2
        params:
          IP_ADDRESS: { get_attr: [ floating_ip, floating_ip_address ] }
          PORT2: { get_param: app_port2 }

(webserver-add-port.yaml)
heat_template_version: 2016-10-14
description: Simple Ubuntu BASED Server with Apache and included in a pool.

#
# Common parameter definitions:
# Thos parameters are passed by the main HEAT template
#
parameters:

  metadata:
    type: json

  pool_id1:
    type: string
    description: LB Service Pool

  pool_id2:
    type: string
    description: LB Service Pool

  instance_flavor:
    type: string
    description: Instance Flavor

  server_network:
    type: string
    description: Instance Network

  server_subnet:
    type: string
    description: Instance Subnet (as a "member")

  server_image:
    type: string
    description: Instance Base Image

  server_zone:
    type: string
    description: Instance Availability Zone

  server_secgroup:
    type: string
    description: Instance Security Group

  server_port1:
    type: string
    description: Instance Application Group

  server_port2:
    type: string
    description: Instance Application Group

  server_key:
    type: string
    description: Instance SSH Access Key

  app_install:
    type: string
    description: Instance HTTP Application

#
# Our resources:
#
resources:

#
# Our NOVA Instance definition:
#
  server:
    type: OS::Nova::Server
    properties:
      key_name: {get_param: server_key}
      security_groups: [{get_param: server_secgroup}]
      image: {get_param: server_image}
      availability_zone: {get_param: server_zone}
      flavor: {get_param: instance_flavor}
      networks:
        - network: {get_param: server_network}
      user_data_format: RAW
      metadata: {get_param: metadata}
      user_data:
        str_replace:
          template: |
            #!/bin/bash
            # This is our bootstrap secuence
            myapp="$selectedapp01"
            echo "MY APP IS $myapp"
            PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
            echo "INSTALLING APACHE2"
            apt-get update
            apt-get -y install apache2
            hostname > /var/www/html/index.html
            echo "<br>" >> /var/www/html/index.html
            curl -s http://169.254.169.254/latest/meta-data/local-ipv4 >> /var/www/html/index.html
            sed -i '/^Listen/a Listen 8080' /etc/apache2/ports.conf
            systemctl restart apache2.service
            # Comment the following two lines in order if you don't want to force
            # a autoscale event at boot
            #while [ 1 ] ; do echo $((13**99)) 1>/dev/null 2>&1; done &
            #while [ 1 ] ; do echo $((13**99)) 1>/dev/null 2>&1; done &
          params:
            $selectedapp01: {get_param: app_install}
#
# LBaaS V2 Member definition
#
  member1:
    type: OS::Neutron::LBaaS::PoolMember
    #depends_on: server
    properties:
      pool: { get_param: pool_id1 }
      address: { get_attr: [server, first_address] }
      protocol_port: { get_param: server_port1 }
      subnet: { get_param: server_subnet }

  member2:
    type: OS::Neutron::LBaaS::PoolMember
    #depends_on: server
    properties:
      pool: { get_param: pool_id2 }
      address: { get_attr: [server, first_address] }
      protocol_port: { get_param: server_port2 }
      subnet: { get_param: server_subnet }

(env-add-port.yaml)
resource_registry:
    "OS::Nova::Server::Webserver": webserver-add-port.yaml

(lbaasv2-delete-port.yaml)
heat_template_version: 2016-10-14
description: A simple auto scaling group with LBaaS V2 Service.

#
# Common parameter definitions:
#
parameters:

  my_flavor:
    type: string
    description: Flavor for the server to be created
    default: "t1"
    constraints:
      - custom_constraint: nova.flavor

  my_accesskey:
    type: string
    description: Name of an existing key-pair
    default: "jijeong"
    constraints:
      - custom_constraint: nova.keypair

  my_image:
    type: string
    description: Image ID or image name to use for the server
    default: "Ubuntu 16.04 LTS"
    constraints:
      - custom_constraint: glance.image

  my_public_network:
    type: string
    description: Neutron Public Network
    default: "ext-net"
    constraints:
      - custom_constraint: neutron.network

  my_private_network:
    type: string
    description: Neutron Private Network
    default: "demo-net"
    constraints:
      - custom_constraint: neutron.network

  my_private_subnet:
    type: string
    description: Neutron SUB-Network
    default: "private-subnet"

  my_zone:
    type: string
    description: Availability Zone
    default: "nova"

  app_port1:
    type: string
    description: Aplication TCP Port
    default: "80"

  application_install:
    type: string
    description: HTTP Application to install
    default: "apache2"

#
# Resource Definitions
#
# Please note: The AutoScaing group resource "OS::Nova::Server::Webserver
# is defined in the environment file. You'll find with this template 3 more
# support files:
# - Template-AutoScaling-LBaaSV2-ENV-LocalCLI.yaml: Environment version to
# be used with openstack or heat "cli". It assumes your server file is
# located in the same directory as the template
# - Template-AutoScaling-LBaaSV2-ENV-HTTP-Server.yaml: Environment version
# wich assumes your server file is located in a URL (a web server).
# - webserver_lb.yaml: Your server file. Depending of your environment file,
# you should have this file locally or in a web server.
#
#
resources:

#
# Our LBaaS V2 "Load Balancer"
#
  lb:
    type: OS::Neutron::LBaaS::LoadBalancer
    properties:
      vip_subnet: { get_param: my_private_subnet }

#
# Our LBaaS V2 Listener
#
  listener1:
    type: OS::Neutron::LBaaS::Listener
    #depends_on: lb
    properties:
      loadbalancer: { get_resource: lb }
      protocol: HTTP
      protocol_port: { get_param: app_port1 }

#
# Our LBaaS V2 Pool
#
  pool1:
    type: OS::Neutron::LBaaS::Pool
    #depends_on: listener1
    properties:
      lb_algorithm: ROUND_ROBIN
      protocol: HTTP
      listener: { get_resource: listener1 }

#
# Our LBaaS V2 Health Monitor.
#
  monitor1:
    type: OS::Neutron::LBaaS::HealthMonitor
    #depends_on: pool1
    properties:
      delay: 5
      type: HTTP
      timeout: 5
      max_retries: 3
      pool: { get_resource: pool1 }

#
# Our Floating for LB-VIP
#
  floating_ip:
    type: OS::Neutron::FloatingIP
    #depends_on: lb
    properties:
      floating_network: { get_param: my_public_network }
      port_id: { get_attr: [lb, vip_port_id ]}

#
# Security Group with access to icmp, tcp port 22 (ssh) and the web application
# port
#
  sec_group:
    type: OS::Neutron::SecurityGroup
    properties:
      rules:
      - remote_ip_prefix: 0.0.0.0/0
        protocol: tcp
        port_range_min: { get_param: app_port1 }
        port_range_max: { get_param: app_port1 }
# - remote_ip_prefix: 0.0.0.0/0
# protocol: tcp
# port_range_min: 22
# port_range_max: 22
      - remote_ip_prefix: 0.0.0.0/0
        protocol: icmp

#
# Our main autoscaling group
#
  group:
    type: OS::Heat::AutoScalingGroup
    #depends_on: [ sec_group, pool1 ]
    properties:
      cooldown: 60
      desired_capacity: 3
      max_size: 10
      min_size: 2
      resource:
        type: OS::Nova::Server::Webserver
        properties:
          metadata: {"metering.stack": {get_param: "OS::stack_id"}}
          pool_id1: { get_resource: pool1 }
          instance_flavor: { get_param: my_flavor }
          server_network: { get_param: my_private_network }
          server_subnet: { get_param: my_private_subnet }
          server_image: { get_param: my_image }
          server_zone: { get_param: my_zone }
          server_secgroup: { get_resource: sec_group }
          server_port1: { get_param: app_port1 }
          server_key: { get_param: my_accesskey }
          app_install: { get_param: application_install }

#
# Scale-up-and-down policies:
#
  scaleup_policy:
    type: OS::Heat::ScalingPolicy
    #depends_on: group
    properties:
      adjustment_type: change_in_capacity
      auto_scaling_group_id: { get_resource: group }
      cooldown: 60
      scaling_adjustment: 1

  scaledown_policy:
    type: OS::Heat::ScalingPolicy
    #depends_on: group
    properties:
      adjustment_type: change_in_capacity
      auto_scaling_group_id: { get_resource: group }
      cooldown: 60
      scaling_adjustment: -1

#
# Our alarms:
#
  cpu_alarm_high:
    type: OS::Ceilometer::Alarm
    #depends_on: scaleup_policy
    properties:
      meter_name: cpu_util
      description: Scale-up if the average CPU > 50% for 1 minute
      statistic: avg
      period: 60
      evaluation_periods: 1
      threshold: 50
      alarm_actions:
        - {get_attr: [scaleup_policy, alarm_url]}
      comparison_operator: gt
      matching_metadata: {'metadata.user_metadata.stack': {get_param: "OS::stack_id"}}

  cpu_alarm_low:
    type: OS::Ceilometer::Alarm
    #depends_on: scaledown_policy
    properties:
      meter_name: cpu_util
      description: Scale-down if the average CPU < 15% for 10 minutes
      statistic: avg
      period: 600
      evaluation_periods: 1
      threshold: 15
      alarm_actions:
        - {get_attr: [scaledown_policy, alarm_url]}
      comparison_operator: lt
      matching_metadata: {'metadata.user_metadata.stack': {get_param: "OS::stack_id"}}

#
# And, our output:
#
outputs:
  Scale-UP-URL:
    value: {get_attr: [scaleup_policy, alarm_url]}
    description: Scale-UP ALARM URL
  Scale-DOWN-URL:
    value: {get_attr: [scaledown_policy, alarm_url]}
    description: Scale-DOWN ALARM URL
  Scale-UP-SIGNAL-URL:
    value: {get_attr: [scaleup_policy, signal_url]}
    description: Scale-UP Signal URL
  Scale-DOWN-SIGNAL-URL:
    value: {get_attr: [scaledown_policy, signal_url]}
    description: Scale-DOWN Signal URL
  LB-URL1:
    value:
      str_replace:
        template:
          http://IP_ADDRESS:PORT1
        params:
          IP_ADDRESS: { get_attr: [ floating_ip, floating_ip_address ] }
          PORT1: { get_param: app_port1 }

(wwebserver-delete-port.yaml)
heat_template_version: 2016-10-14
description: Simple Ubuntu BASED Server with Apache and included in a pool.

#
# Common parameter definitions:
# Thos parameters are passed by the main HEAT template
#
parameters:

  metadata:
    type: json

  pool_id1:
    type: string
    description: LB Service Pool

  instance_flavor:
    type: string
    description: Instance Flavor

  server_network:
    type: string
    description: Instance Network

  server_subnet:
    type: string
    description: Instance Subnet (as a "member")

  server_image:
    type: string
    description: Instance Base Image

  server_zone:
    type: string
    description: Instance Availability Zone

  server_secgroup:
    type: string
    description: Instance Security Group

  server_port1:
    type: string
    description: Instance Application Group

  server_key:
    type: string
    description: Instance SSH Access Key

  app_install:
    type: string
    description: Instance HTTP Application

#
# Our resources:
#
resources:

#
# Our NOVA Instance definition:
#
  server:
    type: OS::Nova::Server
    properties:
      key_name: {get_param: server_key}
      security_groups: [{get_param: server_secgroup}]
      image: {get_param: server_image}
      availability_zone: {get_param: server_zone}
      flavor: {get_param: instance_flavor}
      networks:
        - network: {get_param: server_network}
      user_data_format: RAW
      metadata: {get_param: metadata}
      user_data:
        str_replace:
          template: |
            #!/bin/bash
            # This is our bootstrap secuence
            myapp="$selectedapp01"
            echo "MY APP IS $myapp"
            PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
            echo "INSTALLING APACHE2"
            apt-get update
            apt-get -y install apache2
            hostname > /var/www/html/index.html
            echo "<br>" >> /var/www/html/index.html
            curl -s http://169.254.169.254/latest/meta-data/local-ipv4 >> /var/www/html/index.html
            sed -i '/^Listen/a Listen 8080' /etc/apache2/ports.conf
            systemctl restart apache2.service
            # Comment the following two lines in order if you don't want to force
            # a autoscale event at boot
            #while [ 1 ] ; do echo $((13**99)) 1>/dev/null 2>&1; done &
            #while [ 1 ] ; do echo $((13**99)) 1>/dev/null 2>&1; done &
          params:
            $selectedapp01: {get_param: app_install}
#
# LBaaS V2 Member definition
#
  member1:
    type: OS::Neutron::LBaaS::PoolMember
    #depends_on: server
    properties:
      pool: { get_param: pool_id1 }
      address: { get_attr: [server, first_address] }
      protocol_port: { get_param: server_port1 }
      subnet: { get_param: server_subnet }

(env-delete-port.yaml)
resource_registry:
    "OS::Nova::Server::Webserver": webserver-delete-port.yaml

Revision history for this message
JungJungIn (call518) wrote :
JungJungIn (call518)
tags: added: lbaas listener
description: updated
JungJungIn (call518)
description: updated
Rico Lin (rico-lin)
Changed in heat:
milestone: none → no-priority-tag-bugs
JungJungIn (call518)
information type: Public → Public Security
To post a comment you must log in.
This report contains Public Security information  
Everyone can see this security related information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.