aboutsummaryrefslogtreecommitdiffstats
path: root/meta-openstack/recipes-devtools/python/python-heat/autoscaling_example.template
blob: 1479a99549e71fdc863e2cf42d11cb4ac6e74ac2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
heat_template_version: 2013-05-23
description: AutoScaling
parameters:
  instance_type:
    type: string
    description: Type of the instance to be created.
    default: m1.tiny
    constraints:
      - allowed_values: [m1.tiny, m1.small, m1.medium, m1.large]
        description:
          Value must be one of 'm1.tiny', 'm1.small', 'm1.medium' or 'm1.large'.
  image_id:
    type: string
    description: ID of the image to use for the instance to be created.
    default: myfirstimage
resources:
  web_server_group_launch_conf:
     type: AWS::AutoScaling::LaunchConfiguration
     properties:
       ImageId: { get_param: image_id }
       InstanceType: { get_param: instance_type }
  server_group:
    type: AWS::AutoScaling::AutoScalingGroup
    properties:
      AvailabilityZones: ["RegionOne"]
      MinSize: '1'
      MaxSize: '3'
      LaunchConfigurationName: {get_resource: web_server_group_launch_conf}
  web_server_scaleup_policy:
    type: AWS::AutoScaling::ScalingPolicy
    properties:
      AdjustmentType: ChangeInCapacity
      AutoScalingGroupName: {get_resource: server_group}
      Cooldown: 60
      ScalingAdjustment: 1
  web_server_scaledown_policy:
    type: AWS::AutoScaling::ScalingPolicy
    properties:
      AdjustmentType: ChangeInCapacity
      AutoScalingGroupName: {get_resource: server_group}
      Cooldown: 60
      ScalingAdjustment: -1
  cpu_alarm_high:
    type: OS::Ceilometer::Alarm
    properties:
      description: Scale-up if the average CPU > 80% for 5 minute
      meter_name: cpu_util
      statistic: avg
      period: '300'
      evaluation_periods: '1'
      threshold: '80'
      alarm_actions:
        - {get_attr: [web_server_scaleup_policy, AlarmUrl]}
      comparison_operator: gt
  cpu_alarm_low:
    type: OS::Ceilometer::Alarm
    properties:
      description: Scale-down if the average CPU < 45% for 2 minutes
      meter_name: cpu_util
      statistic: avg
      period: '120'
      evaluation_periods: '1'
      threshold: '45'
      alarm_actions:
        - {get_attr: [web_server_scaledown_policy, AlarmUrl]}
      comparison_operator: lt