¿ù°£ Àα⠰Խù°

°Ô½Ã¹° 708°Ç
   
·Îµå¹ë·£½º »ý¼º + ¿ÀÅ佺ÄÉÀϸµ - heat
±Û¾´ÀÌ : ÃÖ°í°ü¸®ÀÚ ³¯Â¥ : 2016-07-01 (±Ý) 13:09 Á¶È¸ : 515
                                

heat_template_version: 2015-10-15
description: add lbaas resource 
parameters:

  app_port:
    type: number
    default: 80
    description: Port used by the servers

  lb_port:
    type: number
    default: 80
    description: Port used by the load balancer

  image:
    type: string
    default: ubuntu
    description: Image used for servers
    constraints:
    - custom_constraint: glance.image

  flavor:
    type: string
    default: smile
    description: Flavor used for servers
    constraints:
    - custom_constraint: nova.flavor

  public_network:
    type: string
    default: c6bc83b9-1bde-4a8b-bfe5-090f98f89118
    description: Network used by the load balancer
    constraints:
    - custom_constraint: neutron.network

  networks:
    type: string
    default: 6bcf7324-99d9-4940-8c65-4a5312e8e864
    description: Network used by the servers
    constraints:
    - custom_constraint: neutron.network

  subnet:
    type: string
    default: 6041f625-224d-4111-8305-65730e6172a4
    description: Subnet on which the load balancer will be located
    constraints:
    - custom_constraint: neutron.subnet


resources:
  asg:
    type: OS::Heat::AutoScalingGroup
    properties:
      min_size: 1
      max_size: 5
      resource:
#        type: file:///root/hot/lbaasv2/lb_server.yaml
        type: lb_server.yaml
        properties:
          flavor: {get_param: flavor}
          image: {get_param: image}
          metadata: {"metering.stack": {get_param: "OS::stack_id"}}
          networks: {get_param: networks}
          subnet: {get_param: subnet}
          pool: {get_resource: pool}
          app_port: {get_param: app_port}

  scaleup:
    type: OS::Heat::ScalingPolicy
    properties:
      adjustment_type: change_in_capacity
      auto_scaling_group_id: {get_resource: asg}
      cooldown: 60
      scaling_adjustment: 1

  scaledown:
    type: OS::Heat::ScalingPolicy
    properties:
      adjustment_type: change_in_capacity
      auto_scaling_group_id: {get_resource: asg}
      cooldown: 60
      scaling_adjustment: -1

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

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

  monitor:
    type: OS::Neutron::LBaaS::HealthMonitor
    properties:
      delay: 3
      type: HTTP
      timeout: 3
      max_retries: 3
      pool: { get_resource: pool }

  pool:
    type: OS::Neutron::LBaaS::Pool
    properties:
      lb_algorithm: ROUND_ROBIN
      protocol: HTTP
      listener: { get_resource: listener }

  listener:
    type: OS::Neutron::LBaaS::Listener
    properties:
      loadbalancer: { get_resource: loadbalancer }
      protocol: HTTP
      protocol_port: { get_param: lb_port }

  loadbalancer:
    type: OS::Neutron::LBaaS::LoadBalancer
    properties:
      vip_subnet: { get_param: subnet }

  floating_ip:
    type: OS::Neutron::FloatingIP
    properties:
      floating_network: { get_param: public_network }
      port_id: { get_attr: [loadbalancer, vip_port_id ]}


outputs:

  scale_up_url:
    description: >
      This URL is the webhook to scale up the autoscaling group.  You
      can invoke the scale-up operation by doing an HTTP POST to this
      URL; no body nor extra headers are needed.
    value: {get_attr: [scaleup, alarm_url]}

  scale_dn_url:
    description: >
      This URL is the webhook to scale down the autoscaling group.
      You can invoke the scale-down operation by doing an HTTP POST to
      this URL; no body nor extra headers are needed.
    value: {get_attr: [scaledown, alarm_url]}

  server_list:
    description: >
      List of server names that are part of the group.
    value: {get_attr: [asg, outputs_list, name]}

  lburl:
    description: URL of the loadbalancer
    value:
      str_replace:
        template: http://IP_ADDRESS:PORT
        params:
          IP_ADDRESS: { get_attr: [ floating_ip, floating_ip_address ] }
          PORT: { get_param: lb_port }
    description: >
      This URL is the "external" URL that can be used to access the
      load balancer.


# lb_server.yaml


heat_template_version: 2013-05-23

description: A Group of Load Balanced Servers

parameters:
  app_port:
    type: number
    description: Port used by the servers

  image:
    type: string
    description: Image used for servers
    constraints:
    - custom_constraint: glance.image

  flavor:
    type: string
    description: Flavor used for servers
    constraints:
    - custom_constraint: nova.flavor

  pool:
    type: string
    description: Pool to contact

  metadata:
    type: json

  networks:
    type: string
    description: Network used by the server

  subnet:
    type: string
    description: Subnet on which the load balancer will be located
    constraints:
    - custom_constraint: neutron.subnet


resources:
  server:
    type: OS::Nova::Server
    properties:
      flavor: {get_param: flavor}
      image: {get_param: image}
      metadata: {get_param: metadata}
      networks: [{network: {get_param: networks} }]

  pool_member:
    type: OS::Neutron::LBaaS::PoolMember
    properties:
      pool: { get_param: pool }
      address: { get_attr: [ server, first_address ]}
      protocol_port: { get_param: app_port }
      subnet: { get_param: subnet }


outputs:
  server_ip:
    description: IP Address of the load-balanced server.
    value: { get_attr: [server, first_address] }

  lb_member:
    description: LB member details.
    value: { get_attr: [pool_member, show] }
 - ½ºÅÃÀÌ »ý¼ºµÇ°í ¼­¹ö Áõ°¨¼Ò ¾ÈµÇ´Â °æ¿ì°¡ °£È¤ ÀÖ´Ù.


À̸§ Æнº¿öµå
ºñ¹Ð±Û (üũÇÏ¸é ±Û¾´À̸¸ ³»¿ëÀ» È®ÀÎÇÒ ¼ö ÀÖ½À´Ï´Ù.)
¿ÞÂÊÀÇ ±ÛÀÚ¸¦ ÀÔ·ÂÇϼ¼¿ä.
   

 



 
»çÀÌÆ®¸í : ¸ðÁö¸®³× | ´ëÇ¥ : ÀÌ°æÇö | °³ÀÎÄ¿¹Â´ÏƼ : ·©Å°´åÄÄ ¿î¿µÃ¼Á¦(OS) | °æ±âµµ ¼º³²½Ã ºÐ´ç±¸ | ÀüÀÚ¿ìÆí : mojily°ñ¹ðÀÌchonnom.com Copyright ¨Ï www.chonnom.com www.kyunghyun.net www.mojily.net. All rights reserved.