-
Notifications
You must be signed in to change notification settings - Fork 2
/
service.yaml
222 lines (209 loc) · 6.21 KB
/
service.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
tosca_definitions_version: tosca_simple_yaml_1_3
metadata:
template_name: "policy-triggers"
template_author: "XLAB"
template_version: "1.0"
node_types:
radon.nodes.OpenStack.VM:
derived_from: tosca.nodes.Compute
attributes:
available_instances:
type: integer
default: 42
available_space:
type: integer
default: 1000
properties:
name:
type: string
image:
type: string
flavor:
type: string
network:
type: string
key_name:
type: string
interfaces:
Standard:
type: tosca.interfaces.node.lifecycle.Standard
operations:
create: playbooks/create.yaml
delete: playbooks/delete.yaml
scaling_up:
type: radon.interfaces.scaling.ScaleUp
scaling_down:
type: radon.interfaces.scaling.ScaleDown
autoscaling:
type: radon.interfaces.scaling.AutoScale
requirements:
- host:
capability: tosca.capabilities.Compute
relationship: tosca.relationships.HostedOn
interface_types:
radon.interfaces.scaling.ScaleDown:
derived_from: tosca.interfaces.Root
operations:
scale_down:
inputs:
adjustment: { default: 1, type: integer }
description: Operation for scaling down.
implementation: playbooks/scale_down.yaml
radon.interfaces.scaling.ScaleUp:
derived_from: tosca.interfaces.Root
operations:
scale_up:
inputs:
adjustment: { default: 1, type: integer }
description: Operation for scaling up.
implementation: playbooks/scale_up.yaml
radon.interfaces.scaling.AutoScale:
derived_from: tosca.interfaces.Root
operations:
retrieve_info:
description: Operation for autoscaling.
implementation: playbooks/retrieve_info.yaml
autoscale:
description: Operation for autoscaling.
implementation: playbooks/auto_scale.yaml
policy_types:
radon.policies.scaling.ScaleDown:
derived_from: tosca.policies.Scaling
properties:
cpu_lower_bound:
description: The lower bound for the CPU
type: float
required: false
constraints:
- less_or_equal: 20.0
adjustment:
description: The amount by which to scale
type: integer
required: true
constraints:
- greater_or_equal: -1
targets: [ radon.nodes.OpenStack.VM ]
triggers:
radon.triggers.scaling.ScaleDown:
description: A trigger for scaling down
event: scale_down_trigger
target_filter:
node: radon.nodes.OpenStack.VM
condition:
constraint:
- not:
- and:
- available_instances: [ { greater_than: 42 } ]
- available_space: [ { greater_than: 1000 } ]
action:
- call_operation:
operation: scaling_down.scale_down
inputs:
adjustment: { get_property: [ SELF, adjustment ] }
radon.policies.scaling.ScaleUp:
derived_from: tosca.policies.Scaling
properties:
cpu_upper_bound:
description: The upper bound for the CPU
type: float
required: false
constraints:
- greater_or_equal: 80.0
adjustment:
description: The amount by which to scale
type: integer
required: true
constraints:
- greater_or_equal: 1
targets: [ radon.nodes.OpenStack.VM ]
triggers:
radon.triggers.scaling.ScaleUp:
description: A trigger for scaling up
event: scale_up_trigger
target_filter:
node: radon.nodes.OpenStack.VM
condition:
constraint:
- not:
- and:
- available_instances: [ { greater_than: 42 } ]
- available_space: [ { greater_than: 1000 } ]
action:
- call_operation:
operation: scaling_up.scale_up
inputs:
adjustment: { get_property: [ SELF, adjustment ] }
radon.policies.scaling.AutoScale:
derived_from: tosca.policies.Scaling
properties:
min_size:
type: integer
description: The minimum number of instances
required: true
status: supported
constraints:
- greater_or_equal: 1
max_size:
type: integer
description: The maximum number of instances
required: true
status: supported
constraints:
- less_or_equal: 10
topology_template:
node_templates:
workstation:
type: tosca.nodes.Compute
attributes:
private_address: localhost
public_address: localhost
openstack_vm:
type: radon.nodes.OpenStack.VM
properties:
name: HostVM
image: centos7
flavor: m1.xsmall
network: provider_64_net
key_name: my_key
requirements:
- host: workstation
policies:
- scale_down:
type: radon.policies.scaling.ScaleDown
properties:
cpu_lower_bound: 10
adjustment: 1
targets: [ openstack_vm ]
- scale_up:
type: radon.policies.scaling.ScaleUp
properties:
cpu_upper_bound: 90
adjustment: 1
targets: [ openstack_vm ]
- autoscale:
type: radon.policies.scaling.AutoScale
properties:
min_size: 3
max_size: 7
targets: [ openstack_vm ]
triggers:
radon.triggers.scaling.AutoScale:
description: A trigger for autoscaling
event: auto_scale_trigger
schedule:
start_time: 2020-04-08T21:59:43.10-06:00
end_time: 2022-04-08T21:59:43.10-06:00
target_filter:
node: openstack_vm
condition:
constraint:
- not:
- and:
- available_instances: [ { greater_than: 42 } ]
- available_space: [ { greater_than: 1000 } ]
period: 60 s
evaluations: 2
method: average
action:
- call_operation: autoscaling.retrieve_info
- call_operation: autoscaling.autoscale