Added simple samples that exercise autoscaling
Added trivial templates that can be used to exercise basic scaling group functionality: the mechanics of the scaling actions. These examples are deliberately spare, to minimize dependencies. Change-Id: Iddd63acc629d617f861215c12e20d250c53edd11 Partial-Bug: 1305425
This commit is contained in:
parent
683dbbad92
commit
ac8502c45d
74
cfn/aws_asg.template
Normal file
74
cfn/aws_asg.template
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
{
|
||||||
|
"AWSTemplateFormatVersion" : "2010-09-09",
|
||||||
|
|
||||||
|
"Description" : "This is a very simple template that illustrates the basic features of an AWS::AutoScaling::AutoScalingGroup. By virtue of its simplicity this example should be usable in many contexts. In particular, this example does not require Neutron nor any particular support for software in the VMs. In fact, the VMs in this example do not actually do anything. This example does no automatic scaling, but does discuss manual scaling. For a more complete example, see autoscaling.yaml.",
|
||||||
|
|
||||||
|
"Parameters" : {
|
||||||
|
"KeyName" : {
|
||||||
|
"Type" : "String",
|
||||||
|
"Description" : "Name of an existing key pair to use for the instances"
|
||||||
|
},
|
||||||
|
"Flavor" : {
|
||||||
|
"Type" : "String",
|
||||||
|
"Description" : "Flavor for the instances to be created",
|
||||||
|
"Default" : "m1.small"
|
||||||
|
},
|
||||||
|
"Image" : {
|
||||||
|
"Type" : "String",
|
||||||
|
"Description" : "Name or ID of the image to use for the instances. You can get Fedora 20 images with cloud-init from http://cloud.fedoraproject.org/fedora-20.x86_64.qcow2 . There is also http://cloud.fedoraproject.org/fedora-20.i386.qcow2 . Any image should work since this template does not ask the VMs to do anything."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"Resources" : {
|
||||||
|
"ASG" : {
|
||||||
|
"Type" : "AWS::AutoScaling::AutoScalingGroup",
|
||||||
|
"Properties" : {
|
||||||
|
"AvailabilityZones" : {"Fn::GetAZs": ""},
|
||||||
|
"LaunchConfigurationName" : {"Ref": "LaunchConfig"},
|
||||||
|
"MinSize" : 1,
|
||||||
|
"DesiredCapacity" : 3,
|
||||||
|
"MaxSize" : 5
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"LaunchConfig" : {
|
||||||
|
"Type" : "AWS::AutoScaling::LaunchConfiguration",
|
||||||
|
"Properties" : {
|
||||||
|
"ImageId" : {"Ref": "Image"},
|
||||||
|
"InstanceType" : {"Ref": "Flavor"},
|
||||||
|
"KeyName" : { "Ref": "KeyName" }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"ScaleUpPolicy" : {
|
||||||
|
"Type" : "AWS::AutoScaling::ScalingPolicy",
|
||||||
|
"Properties" : {
|
||||||
|
"AdjustmentType": "ChangeInCapacity",
|
||||||
|
"AutoScalingGroupName" : {"Ref": "ASG"},
|
||||||
|
"Cooldown": 60,
|
||||||
|
"ScalingAdjustment": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"ScaleDnPolicy" : {
|
||||||
|
"Type" : "AWS::AutoScaling::ScalingPolicy",
|
||||||
|
"Properties" : {
|
||||||
|
"AdjustmentType" : "ChangeInCapacity",
|
||||||
|
"AutoScalingGroupName" : {"Ref": "ASG"},
|
||||||
|
"Cooldown": 60,
|
||||||
|
"ScalingAdjustment": -1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"Outputs" : {
|
||||||
|
"scale_up_url" : {
|
||||||
|
"Description" : "This URL is the webhook to scale up the group. You can invoke the scale-up operation by doing an HTTP POST to this URL; no body nor extra headers are needed.",
|
||||||
|
"Value" : {"Fn::GetAtt": ["ScaleUpPolicy", "AlarmUrl"]}
|
||||||
|
},
|
||||||
|
"scale_dn_url" : {
|
||||||
|
"Description" : "This URL is the webhook to scale down the group. You can invoke the scale-dwon operation by doing an HTTP POST to this URL; no body nor extra headers are needed.",
|
||||||
|
"Value" : {"Fn::GetAtt": ["ScaleDnPolicy", "AlarmUrl"]}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
89
hot/asg_of_servers.yaml
Normal file
89
hot/asg_of_servers.yaml
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
heat_template_version: 2013-05-23
|
||||||
|
|
||||||
|
description: >
|
||||||
|
This is a very simple template that illustrates the basic features
|
||||||
|
of OS::Heat::AutoScalingGroup when the scaled resource is an
|
||||||
|
OS::Nova::Server. By virtue of its simplicity this example should
|
||||||
|
be usable in many contexts. In particular, this example does not
|
||||||
|
require Neutron nor a load balancer nor any particular support for
|
||||||
|
software in the VMs. In fact, the VMs in this example do not
|
||||||
|
actually do anything. This example does no automatic scaling, but
|
||||||
|
does discuss manual scaling.
|
||||||
|
For a more complete example, see autoscaling.yaml.
|
||||||
|
|
||||||
|
parameters:
|
||||||
|
key_name:
|
||||||
|
type: string
|
||||||
|
description: Name of an existing key pair to use for the instances
|
||||||
|
constraints:
|
||||||
|
- custom_constraint: nova.keypair
|
||||||
|
description: Must name a public key (pair) known to Nova
|
||||||
|
flavor:
|
||||||
|
type: string
|
||||||
|
description: Flavor for the instances to be created
|
||||||
|
default: m1.small
|
||||||
|
constraints:
|
||||||
|
- custom_constraint: nova.flavor
|
||||||
|
description: Must be a flavor known to Nova
|
||||||
|
image:
|
||||||
|
type: string
|
||||||
|
description: >
|
||||||
|
Name or ID of the image to use for the instances.
|
||||||
|
You can get the default from
|
||||||
|
http://cloud.fedoraproject.org/fedora-20.x86_64.qcow2
|
||||||
|
There is also
|
||||||
|
http://cloud.fedoraproject.org/fedora-20.i386.qcow2
|
||||||
|
Any image should work since this template
|
||||||
|
does not ask the VMs to do anything.
|
||||||
|
constraints:
|
||||||
|
- custom_constraint: glance.image
|
||||||
|
description: Must identify an image known to Glance
|
||||||
|
network:
|
||||||
|
type: string
|
||||||
|
description: The network for the VM
|
||||||
|
default: private
|
||||||
|
|
||||||
|
resources:
|
||||||
|
my_asg:
|
||||||
|
type: OS::Heat::AutoScalingGroup
|
||||||
|
properties:
|
||||||
|
resource:
|
||||||
|
type: OS::Nova::Server
|
||||||
|
properties:
|
||||||
|
key_name: { get_param: key_name }
|
||||||
|
image: { get_param: image }
|
||||||
|
flavor: { get_param: flavor }
|
||||||
|
networks: [{network: {get_param: network} }]
|
||||||
|
min_size: 1
|
||||||
|
desired_capacity: 3
|
||||||
|
max_size: 10
|
||||||
|
|
||||||
|
scale_up_policy:
|
||||||
|
type: OS::Heat::ScalingPolicy
|
||||||
|
properties:
|
||||||
|
adjustment_type: change_in_capacity
|
||||||
|
auto_scaling_group_id: {get_resource: my_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: my_asg}
|
||||||
|
cooldown: 60
|
||||||
|
scaling_adjustment: '-1'
|
||||||
|
|
||||||
|
outputs:
|
||||||
|
scale_up_url:
|
||||||
|
description: >
|
||||||
|
This URL is the webhook to scale up the 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: [scale_up_policy, alarm_url]}
|
||||||
|
scale_dn_url:
|
||||||
|
description: >
|
||||||
|
This URL is the webhook to scale down the 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: [scale_down_policy, alarm_url]}
|
89
hot/asg_of_stacks.yaml
Normal file
89
hot/asg_of_stacks.yaml
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
heat_template_version: 2013-05-23
|
||||||
|
|
||||||
|
description: >
|
||||||
|
This is a very simple template that illustrates the basic features
|
||||||
|
of OS::Heat::AutoScalingGroup and demonstrates that these features
|
||||||
|
are available even when the scaled resource is a nested stack. By
|
||||||
|
virtue of its simplicity this example should be usable in many
|
||||||
|
contexts. In particular, this example does not require Neutron nor
|
||||||
|
a load balancer nor any particular support for software in the VMs.
|
||||||
|
In fact, the VMs in this example do not actually do anything. This
|
||||||
|
example does no automatic scaling, but does discuss manual scaling.
|
||||||
|
For a more complete example, see autoscaling.yaml.
|
||||||
|
|
||||||
|
parameters:
|
||||||
|
key_name:
|
||||||
|
type: string
|
||||||
|
description: Name of an existing key pair to use for the instances
|
||||||
|
constraints:
|
||||||
|
- custom_constraint: nova.keypair
|
||||||
|
description: Must name a public key (pair) known to Nova
|
||||||
|
flavor:
|
||||||
|
type: string
|
||||||
|
description: Flavor for the instances to be created
|
||||||
|
default: m1.small
|
||||||
|
constraints:
|
||||||
|
- custom_constraint: nova.flavor
|
||||||
|
description: Must be a flavor known to Nova
|
||||||
|
image:
|
||||||
|
type: string
|
||||||
|
description: >
|
||||||
|
Name or ID of the image to use for the instances.
|
||||||
|
You can get the default from
|
||||||
|
http://cloud.fedoraproject.org/fedora-20.x86_64.qcow2
|
||||||
|
There is also
|
||||||
|
http://cloud.fedoraproject.org/fedora-20.i386.qcow2
|
||||||
|
Any image should work since this template
|
||||||
|
does not ask the VMs to do anything.
|
||||||
|
constraints:
|
||||||
|
- custom_constraint: glance.image
|
||||||
|
description: Must identify an image known to Glance
|
||||||
|
network:
|
||||||
|
type: string
|
||||||
|
description: The network for the VM
|
||||||
|
default: private
|
||||||
|
|
||||||
|
resources:
|
||||||
|
asg:
|
||||||
|
type: OS::Heat::AutoScalingGroup
|
||||||
|
properties:
|
||||||
|
resource:
|
||||||
|
type: vm_with_cinder.yaml
|
||||||
|
properties:
|
||||||
|
key_name: { get_param: key_name }
|
||||||
|
image: { get_param: image }
|
||||||
|
flavor: { get_param: flavor }
|
||||||
|
network: { get_param: network }
|
||||||
|
min_size: 1
|
||||||
|
desired_capacity: 3
|
||||||
|
max_size: 5
|
||||||
|
|
||||||
|
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_dn_policy:
|
||||||
|
type: OS::Heat::ScalingPolicy
|
||||||
|
properties:
|
||||||
|
adjustment_type: change_in_capacity
|
||||||
|
auto_scaling_group_id: {get_resource: asg}
|
||||||
|
cooldown: 60
|
||||||
|
scaling_adjustment: '-1'
|
||||||
|
|
||||||
|
outputs:
|
||||||
|
scale_up_url:
|
||||||
|
description: >
|
||||||
|
This URL is the webhook to scale up the 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: [scale_up_policy, alarm_url]}
|
||||||
|
scale_dn_url:
|
||||||
|
description: >
|
||||||
|
This URL is the webhook to scale down the 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: [scale_dn_policy, alarm_url]}
|
67
hot/vm_with_cinder.yaml
Normal file
67
hot/vm_with_cinder.yaml
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
heat_template_version: 2013-05-23
|
||||||
|
|
||||||
|
description: >
|
||||||
|
A HOT template that holds a VM instance with an attached
|
||||||
|
Cinder volume. The VM does nothing, it is only created.
|
||||||
|
|
||||||
|
parameters:
|
||||||
|
key_name:
|
||||||
|
type: string
|
||||||
|
description: Name of an existing key pair to use for the instance
|
||||||
|
constraints:
|
||||||
|
- custom_constraint: nova.keypair
|
||||||
|
description: Must name a public key (pair) known to Nova
|
||||||
|
flavor:
|
||||||
|
type: string
|
||||||
|
description: Flavor for the instance to be created
|
||||||
|
default: m1.small
|
||||||
|
constraints:
|
||||||
|
- custom_constraint: nova.flavor
|
||||||
|
description: Must be a flavor known to Nova
|
||||||
|
image:
|
||||||
|
type: string
|
||||||
|
description: >
|
||||||
|
Name or ID of the image to use for the instance.
|
||||||
|
You can get the default from
|
||||||
|
http://cloud.fedoraproject.org/fedora-20.x86_64.qcow2
|
||||||
|
There is also
|
||||||
|
http://cloud.fedoraproject.org/fedora-20.i386.qcow2
|
||||||
|
Any image should work since this template
|
||||||
|
does not ask the VM to do anything.
|
||||||
|
constraints:
|
||||||
|
- custom_constraint: glance.image
|
||||||
|
description: Must identify an image known to Glance
|
||||||
|
network:
|
||||||
|
type: string
|
||||||
|
description: The network for the VM
|
||||||
|
default: private
|
||||||
|
vol_size:
|
||||||
|
type: number
|
||||||
|
description: The size of the Cinder volume
|
||||||
|
default: 1
|
||||||
|
|
||||||
|
resources:
|
||||||
|
my_instance:
|
||||||
|
type: OS::Nova::Server
|
||||||
|
properties:
|
||||||
|
key_name: { get_param: key_name }
|
||||||
|
image: { get_param: image }
|
||||||
|
flavor: { get_param: flavor }
|
||||||
|
networks: [{network: {get_param: network} }]
|
||||||
|
|
||||||
|
my_vol:
|
||||||
|
type: OS::Cinder::Volume
|
||||||
|
properties:
|
||||||
|
size: { get_param: vol_size }
|
||||||
|
|
||||||
|
vol_att:
|
||||||
|
type: OS::Cinder::VolumeAttachment
|
||||||
|
properties:
|
||||||
|
instance_uuid: { get_resource: my_instance }
|
||||||
|
volume_id: { get_resource: my_vol }
|
||||||
|
mountpoint: /dev/vdb
|
||||||
|
|
||||||
|
outputs:
|
||||||
|
instance_networks:
|
||||||
|
description: The IP addresses of the deployed instance
|
||||||
|
value: { get_attr: [my_instance, networks] }
|
Loading…
Reference in New Issue
Block a user