AutoScale Heatテンプレート例
hello_world_autoscaling.yaml
AutoScale用のテンプレート例です。
heat_template_version: 2013-05-23
description:
Autoscaling test HOT.
parameters:
az:
type: string
default: jp-east-1b
param-image-id:
type: string
default: 839c1db6-738c-4e2b-9a1d-c14977564203
param-flavor:
type: string
default: (仮想サーバのサーバタイプを記載します。)
key-name:
type: string
description: SSH key to connect to the servers
default: (任意のキーペア名)
autoscale-security-group:
type: comma_delimited_list
default: (任意のセキュリティグループ名)
subnet-id:
type: string
description: subnet id
default: (任意のサブネットID)
resources:
web-server-group:
depends_on:
- launch_config
- fj-elb
type: FCX::AutoScaling::AutoScalingGroup
properties:
AvailabilityZones: [{get_param: az}]
LaunchConfigurationName: {get_resource: launch_config}
MinSize: '2'
MaxSize: '3'
VPCZoneIdentifier: [{get_param: subnet-id}]
LoadBalancerNames:
- {get_resource: fj-elb}
launch_config:
type: FCX::AutoScaling::LaunchConfiguration
properties:
ImageId: { get_param: param-image-id }
InstanceType: { get_param: param-flavor }
KeyName: {get_param: key-name}
SecurityGroups: {get_param: autoscale-security-group}
BlockDeviceMappingsV2: [{source_type: 'image', destination_type: 'volume', boot_index: '0', device_name: '/dev/vda', volume_size: '30', uuid: {get_param: param-image-id}, delete_on_termination: true, volume_type: 'F2'}]
fj-elb:
type: FCX::ExpandableLoadBalancer::LoadBalancer
properties:
Subnets: [{get_param: subnet-id}]
Listeners:
- {LoadBalancerPort: '80', InstancePort: '80',
Protocol: 'HTTP', InstanceProtocol: 'HTTP' }
HealthCheck: {Target: 'HTTP:80/healthcheck', HealthyThreshold: '3',
UnhealthyThreshold: '5', Interval: '30', Timeout: '5'}
Version: 2014-09-30
Scheme: internal
LoadBalancerName: (任意のロードバランサー名※)
※任意のロードバランサー名に「_」(アンダースコア)を指定しないでください。
「_」を指定してスタックを作成した場合、スタックのステータスが
「CREATE_FAILED」となります。
web_server_scaleup_policy:
type: FCX::AutoScaling::ScalingPolicy
properties:
AdjustmentType: ChangeInCapacity
AutoScalingGroupName: {get_resource: web-server-group}
Cooldown: '60'
ScalingAdjustment: '1'
web_server_scaledown_policy:
type: FCX::AutoScaling::ScalingPolicy
properties:
AdjustmentType: ChangeInCapacity
AutoScalingGroupName: {get_resource: web-server-group}
Cooldown: '60'
ScalingAdjustment: '-1'
cpu_alarm_high:
type: OS::Ceilometer::Alarm
properties:
description: Scale-up if the average CPU > 50% for 1 minute
meter_name: fcx.compute.cpu_util
statistic: avg
period: '60'
evaluation_periods: '1'
threshold: '50'
alarm_actions:
- {get_attr: [web_server_scaleup_policy, AlarmUrl]}
matching_metadata: {'metadata.user_metadata.groupname': {get_resource: 'web-server-group'}}
comparison_operator: gt
cpu_alarm_low:
type: OS::Ceilometer::Alarm
properties:
description: Scale-down if the average CPU < 15% for 1 minute
meter_name: fcx.compute.cpu_util
statistic: avg
period: '60'
evaluation_periods: '1'
threshold: '15'
alarm_actions:
- {get_attr: [web_server_scaledown_policy, AlarmUrl]}
matching_metadata: {'metadata.user_metadata.groupname': {get_resource: 'web-server-group'}}
comparison_operator: lt