Skip to content

Instantly share code, notes, and snippets.

@rakesh-patnaik
Created February 22, 2015 18:54
Show Gist options
  • Save rakesh-patnaik/b037f6a9bd4c959aee76 to your computer and use it in GitHub Desktop.
Save rakesh-patnaik/b037f6a9bd4c959aee76 to your computer and use it in GitHub Desktop.
CPU Util based simple autoscaling heat HOT template
heat_template_version: 2013-05-23
description: cpu_util based scale up or scale down. Please adjust thresholds below(in my case 0.65% cpu_util) to match cpu_util observed in your instances.
parameters:
flavor:
type: string
description: Flavor for the instances to be created
default: m1.nano
constraints:
- custom_constraint: nova.flavor
description: Must be a flavor known to Nova
image:
type: string
description: Image ID or image name to use for the server. Please find this under images horizon page.
default: 23ed70af-d254-4b63-b488-cc94eb1a2add
constraints:
- custom_constraint: glance.image
description: Must identify an image known to Glance
resources:
asg:
type: OS::Heat::AutoScalingGroup
properties:
resource:
type: OS::Nova::Server
properties:
image: { get_param: image }
flavor: { get_param: flavor }
metadata: {"metering.stack": {get_param: "OS::stack_id"}}
cooldown: 60
desired_capacity: 2
max_size: 3
min_size: 1
scale_up_policy:
type: OS::Heat::ScalingPolicy
properties:
adjustment_type: change_in_capacity
auto_scaling_group_id: { get_resource: asg }
cooldown: 60
scaling_adjustment: 1
scale_down_policy:
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:
meter_name: cpu_util
statistic: avg
period: 600
evaluation_periods: 1
threshold: 0.65
alarm_actions:
- {get_attr: [scale_up_policy, alarm_url]}
comparison_operator: gt
matching_metadata:
'metadata.user_metadata.stack': {get_param: "OS::stack_id"}
cpu_alarm_low:
type: OS::Ceilometer::Alarm
properties:
meter_name: cpu_util
statistic: avg
period: 600
evaluation_periods: 1
threshold: 0.65
alarm_actions:
- {get_attr: [scale_down_policy, alarm_url]}
comparison_operator: le
matching_metadata:
'metadata.user_metadata.stack': {get_param: "OS::stack_id"}
outputs:
scale_up_url:
description: This URL is the webhook to scale up the group.
value: {get_attr: [scale_up_policy, alarm_url]}
scale_dn_url:
description: This URL is the webhook to scale down the group.
value: {get_attr: [scale_down_policy, alarm_url]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment