heat_template_version: '2021-04-16'
parameters:
desired_capacity:
default: 1
type: number
flavor_name:
description: Name of the flavor to use for the instances.
type: string
image_id:
description: ID of the image to use for the instances.
type: string
key_name:
type: string
max_instances:
default: 5
type: number
min_instances:
default: 1
type: number
scale_down_threshold:
default: 30
type: number
scale_up_threshold:
default: 60
type: number
resources:
autoscaling_group:
properties:
desired_capacity:
get_param: desired_capacity
max_size:
get_param: max_instances
min_size:
get_param: min_instances
resource:
properties:
flavor:
get_param: flavor_name
image:
get_param: image_id
key_name:
get_param: key_name
networks:
- port:
get_resource: instance_port
type: OS::Nova::Server
type: OS::Heat::AutoScalingGroup
instance_port:
properties:
fixed_ips:
- subnet_id:
get_resource: subnet
network:
get_resource: network
type: OS::Neutron::Port
network:
properties:
name: private
type: OS::Neutron::Net
scale_down_alarm:
properties:
aggregation_method: mean
alarm_actions:
- get_attr:
- scale_down_policy
- alarm_url
comparison_operator: lt
evaluation_periods: 1
granularity: 60
metric: cpu_util
query: 'metric=cpu_util:mean{resource_id={get_resource: autoscaling_group},flavor_id={get_param:
flavor_name}}<{get_param:scale_down_threshold}'
resource_type: instance
threshold:
get_param: scale_down_threshold
type: OS::Aodh::GnocchiAggregationByResourcesAlarm
scale_down_policy:
properties:
adjustment_type: change_in_capacity
auto_scaling_group_id:
get_resource: autoscaling_group
cooldown: 60
scaling_adjustment: -1
type: OS::Heat::ScalingPolicy
scale_up_alarm:
properties:
aggregation_method: mean
alarm_actions:
- get_attr:
- scale_up_policy
- alarm_url
comparison_operator: gt
evaluation_periods: 1
granularity: 60
metric: cpu_util
query: 'metric=cpu_util:mean{resource_id={get_resource: autoscaling_group},flavor_id={get_param:
flavor_name}}>{get_param:scale_up_threshold}'
resource_type: instance
threshold:
get_param: scale_up_threshold
type: OS::Aodh::GnocchiAggregationByResourcesAlarm
scale_up_policy:
properties:
adjustment_type: change_in_capacity
auto_scaling_group_id:
get_resource: autoscaling_group
cooldown: 60
scaling_adjustment: 1
type: OS::Heat::ScalingPolicy
subnet:
properties:
cidr: 10.0.0.0/24
network_id:
get_resource: network
type: OS::Neutron::Subnet
Resource Create Failed: Badrequest: Resources.Scale Up Alarm: Invalid Input For Field/Attribute Rule/Query. Value: 'Metric=Cpu Util:Mean{Resource Id={Get Resource: Autoscaling Group},Flavor Id={Get Param: Flavor Name}}>{Get Param:Scale Up Threshold}'. (Http 400) (Request-Id: Req-2b11fd26-6380-4fe0-B36a-2ae90300a769)
我确实使用这个命令来更新
openstack 堆栈更新 SCALE -t test.yaml --parameter key_name=key --parameter image_id=ec873a2d-0e7b-42e4-8c2a-7afb75953805 --parameter flavor_name=m1.tiny
这是我的 HOT 拓扑的照片 https://gyazo.com/9d28a7c106e4c43c3228f8c3d15688e7
我正在尝试在 openstack 中添加自动缩放,但我在最后一部分遇到了问题,请看照片