This repository has been archived by the owner on Jul 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main_scaling.yaml
125 lines (125 loc) · 3.63 KB
/
main_scaling.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
heat_template_version: 2016-10-14
description: Test AutoScaling
parameters:
image:
type: string
description: Image used for servers
default: [Image-ID]
key:
type: string
description: SSH key to connect to the servers
default: [Key-Name]
flavor:
type: string
description: flavor used by the web servers
default: [Flavor-Name]
network:
type: string
description: Network used by the server
default: [Internal-Network-ID]
subnet_id:
type: string
description: subnet on which the load balancer will be located
default: [Internal-Network-Subnet-ID]
external_network_id:
type: string
description: Neutron external network
default: [External-Network-ID]
pool_id:
type: string
description: add server on pool of loadbalancer
default: [LoadBalacner-Pool-ID]
resources:
asg:
type: OS::Heat::AutoScalingGroup
properties:
min_size: 1
max_size: 3
resource:
type: lb_server.yaml
properties:
flavor: {get_param: flavor}
image: {get_param: image}
key_name: {get_param: key}
network: {get_param: network}
pool_id: {get_param: pool_id}
subnet: {get_param: subnet_id}
metadata: {"metering.server_group": {get_param: "OS::stack_id"}}
web_server_scaleup_policy:
type: OS::Heat::ScalingPolicy
properties:
adjustment_type: change_in_capacity
auto_scaling_group_id: {get_resource: asg}
cooldown: 80
scaling_adjustment: 1
web_server_scaledown_policy:
type: OS::Heat::ScalingPolicy
properties:
adjustment_type: change_in_capacity
auto_scaling_group_id: {get_resource: asg}
cooldown: 80
scaling_adjustment: -1
cpu_alarm_high:
type: OS::Aodh::GnocchiAggregationByResourcesAlarm
properties:
description: Scale up if CPU > 80%
metric: cpu_util
aggregation_method: mean
granularity: 300
evaluation_periods: 1
threshold: 80
resource_type: instance
comparison_operator: gt
alarm_actions:
- {get_attr: [web_server_scaleup_policy, alarm_url]}
query:
str_replace:
template: '{"=": {"server_group": "stack_id"}}'
params:
stack_id: {get_param: "OS::stack_id"}
cpu_alarm_low:
type: OS::Aodh::GnocchiAggregationByResourcesAlarm
properties:
description: Scale down if CPU < 15% for 5 minutes
metric: cpu_util
aggregation_method: mean
granularity: 300
evaluation_periods: 1
threshold: 15
resource_type: instance
comparison_operator: lt
alarm_actions:
- {get_attr: [web_server_scaledown_policy, alarm_url]}
query:
str_replace:
template: '{"=": {"server_group": "stack_id"}}'
params:
stack_id: {get_param: "OS::stack_id"}
scale_out_alarm:
type: OS::Ceilometer::Alarm
properties:
description: trigger when bandwidth insufficient
meter_name: network.services.lb.incoming.bytes.rate
statistic: avg
period: 60
evaluation_periods: 1
threshold: [bytes]
repeat_actions: True
alarm_actions:
user_data:
get_file: ./aws/create_scaling.sh
comparison_operator: ge
scale_in_alarm:
type: OS::Ceilometer::Alarm
properties:
description: trigger when bandwidth overflow
meter_name: network.services.lb.incoming.bytes.rate
statistic: avg
period: 180
evaluation_periods: 1
threshold: [bytes]
repeat_actions: True
alarm_actions:
user_data:
get_file: ./aws/delete_scaling.sh
comparison_operator: le