{
"Type" : "AWS::AutoScaling::AutoScalingGroup",
"Properties" : {
"AvailabilityZones" : [ String, ... ],
"Cooldown" : String,
"DesiredCapacity" : String,
"HealthCheckGracePeriod" : Integer,
"HealthCheckType" : String,
"InstanceId" : String,
"LaunchConfigurationName" : String,
"LoadBalancerNames" : [ String, ... ],
"MaxSize" : String,
"MetricsCollection" : [ MetricsCollection, ... ]
"MinSize" : String,
"NotificationConfigurations" : [ NotificationConfigurations, ... ],
"PlacementGroup" : String,
"Tags" : [ Auto Scaling Tag, ..., ],
"TargetGroupARNs" : [ String, ... ],
"TerminationPolicies" : [ String, ..., ],
"VPCZoneIdentifier" : [ String, ... ]
}
}
{
"Type" : "AWS::AutoScaling::LaunchConfiguration",
"Properties" : {
"AssociatePublicIpAddress" : Boolean,
"BlockDeviceMappings" : [ BlockDeviceMapping, ... ],
"ClassicLinkVPCId" : String,
"ClassicLinkVPCSecurityGroups" : [ String, ... ],
"EbsOptimized" : Boolean,
"IamInstanceProfile" : String,
"ImageId" : String,
"InstanceId" : String,
"InstanceMonitoring" : Boolean,
"InstanceType" : String,
"KernelId" : String,
"KeyName" : String,
"PlacementTenancy" : String,
"RamDiskId" : String,
"SecurityGroups" : [ SecurityGroup, ... ],
"SpotPrice" : String,
"UserData" : String
}
}
{
"Type" : "AWS::AutoScaling::ScalingPolicy",
"Properties" : {
"AdjustmentType" : String,
"AutoScalingGroupName" : String,
"Cooldown" : String,
"EstimatedInstanceWarmup" : Integer,
"MetricAggregationType" : String,
"MinAdjustmentMagnitude" : Integer,
"PolicyType" : String,
"ScalingAdjustment" : Integer,
"StepAdjustments" : [ StepAdjustments, ... ]
}
}
heat_template_version: 2013-05-23
description: Heat template for autoscaling
parameters:#定义一些变量
flavor:
type: string
default: m1.small
image:
type: string
default: 1a2b3c4f-1a2b-3c4f-5d6e-4130ff5203de
availability_zone:
type: string
default: nova
alarm_scaleout_threshold:#阈值
type: number
default: 80
alarm_scalein_threshold:#阈值
type: number
default: 20
resources:
neutron_network:
type: OS::Neutron::Net
properties:
name: {get_param: "OS::stack_name"}
neutron_subnet:
type: OS::Neutron::Subnet
properties:
name: {get_param: "OS::stack_name"}
network_id: { get_resource: neutron_network }
cidr: '192.168.111.0/24'
gateway_ip: '192.168.111.1'
allocation_pools:
- start: '192.168.111.2'
end: '192.168.111.254'
neutron_router:
type: OS::Neutron::Router
properties:
name: {get_param: "OS::stack_name"}
add_router_interface:
type: OS::Neutron::RouterInterface
properties:
router_id: { get_resource: neutron_router }
subnet_id: { get_resource: neutron_subnet }
nova_server_security_group:
type: OS::Neutron::SecurityGroup
properties:
description: 'security group for VM'
name: {get_param: "OS::stack_name"}
rules: [
{direction: 'ingress',
remote_ip_prefix: '0.0.0.0/0',
port_range_min: 0,
port_range_max: 30000,
ethertype: IPv4,
protocol: 'tcp'},
{direction: 'egress',
remote_ip_prefix: '0.0.0.0/0',
port_range_min: 0,
port_range_max: 65535,
ethertype: 'IPv4',
protocol: 'tcp'},
{direction: 'egress',
remote_ip_prefix: '0.0.0.0/0',
port_range_min: 0,
port_range_max: 65535,
ethertype: 'IPv4',
protocol: 'udp'},
{direction: 'ingress',
remote_ip_prefix: '0.0.0.0/0',
port_range_min: null,
port_range_max: null,
ethertype: 'IPv4',
protocol: 'icmp'},
{direction: egress,
remote_ip_prefix: '0.0.0.0/0',
port_range_min: null,
port_range_max: null,
ethertype: 'IPv4',
protocol: 'icmp'}
]
launch_config:#Scale group中的实例的配置
type: AWS::AutoScaling::LaunchConfiguration
properties:
ImageId: { get_param: image }#实例使用的image
InstanceType: { get_param: flavor }#实例使用的flavor
SecurityGroups: [ get_resource: nova_server_security_group ]
UserData: |#实例启动时运行的脚本
#!/bin/bash
passwd root << EOD
123456
123456
EOD
server_group:#伸缩组
type: AWS::AutoScaling::AutoScalingGroup
properties:
AvailabilityZones: []
Cooldown: '60'#冷却时间
LaunchConfigurationName: { get_resource: launch_config }#组中实例的配置
MinSize: '1'#最小实例数
MaxSize: '4'#最大实例数
VPCZoneIdentifier: [ get_resource: neutron_subnet ]
scaleout_policy:#向上扩展的策略
type: AWS::AutoScaling::ScalingPolicy
properties:
AdjustmentType: ChangeInCapacity
#heat 支持三种调整方式:change_in_capacity (new = current + adjustment), #exact_capacity (new = adjustment), percent_change_in_capacity (在current 的基#础上上按照 adjustment 的 百分比调整)
AutoScalingGroupName: { get_resource: server_group }
ScalingAdjustment: '1'#每次的调整量,即增加一个实例
scalein_policy:#向下收缩的策略
type: AWS::AutoScaling::ScalingPolicy
properties:
AdjustmentType: ChangeInCapacity
AutoScalingGroupName: { get_resource: server_group }
ScalingAdjustment: '-1'#每次的调整量,即减少一个实例
neutron_port:
type: OS::Neutron::Port
properties:
network_id: { get_resource: neutron_network }
fixed_ips:
- subnet_id: { get_resource: neutron_subnet }
security_groups: [ { get_resource: nova_server_security_group } ]
alarm_scaleout: #定义一个 ceilometer alarm
type: OS::Ceilometer::Alarm
properties:
description: Scale-up if the average CPU > 80% for 10 minute
meter_name: cpu_util #监控虚拟机的 cpu_util
statistic: avg #statistic 的计算方法为 avg 即平均值法
period: 600 #统计周期
evaluation_periods: 1 #连续几个周期才算有效
repeat_actions: true
threshold: { get_param: alarm_scaleout_threshold }# cpu_util 的阈值
alarm_actions: #该告警在alarm 状态时的 action。
- {get_attr: [scaleout_policy, AlarmUrl]}
matching_metadata: {'metadata.user_metadata.groupname': {get_resource: 'server_group'}}
comparison_operator: gt #检测值和阈值的比较方式为 gt 即大于
alarm_scalein:
type: OS::Ceilometer::Alarm
properties:
description: Scale-down if the average CPU < 20% for 10 minutes
meter_name: cpu_util
statistic: avg
period: 600
evaluation_periods: 1
repeat_actions: true
threshold: { get_param: alarm_scalein_threshold }
alarm_actions:
- {get_attr: [scalein_policy, AlarmUrl]}
matching_metadata: {'metadata.user_metadata.groupname': {get_resource: 'server_group'}}
comparison_operator: lt#检测值和阈值的比较方式为 lt 即小于
outputs:
scale_in_url:
value: { get_attr: [ scalein_policy, AlarmUrl ] }
scale_out_url:
value: { get_attr: [ scaleout_policy, AlarmUrl ] }
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有