-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathaws_eks_plugin.plugin
More file actions
400 lines (334 loc) · 8.16 KB
/
aws_eks_plugin.plugin
File metadata and controls
400 lines (334 loc) · 8.16 KB
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
name 'Amazon Elastic Kubernetes Service (Amazon EKS)'
type 'plugin'
short_description 'Amazon Web Services (AWS) - Amazon Elastic Kubernetes Service (Amazon EKS)'
rs_ca_ver 20161221
package "aws_eks"
import "sys_log"
info(
provider: "AWS",
service: "EKS"
)
pagination 'aws_pagination' do
get_page_marker do
body_path 'nextToken'
end
set_page_marker do
query 'nextToken'
end
end
parameter 'region' do
type 'string'
label 'AWS Region'
description 'The region in which the resources are created'
allowed_values "us-east-1","us-east-2","us-west-1","us-west-2","ap-south-1","ap-northeast-2","ap-southeast-1","ap-southeast-2","ap-northeast-1","ca-central-1","eu-central-1","eu-west-1","eu-west-2","eu-west-3", "sa-east-1","eu-north-1"
end
parameter 'page_size' do
type 'string'
label 'Page size for AWS responses'
default '200'
description 'The maximum results count for each page of AWS data received.'
end
plugin "aws_eks" do
short_description 'AWS-EKS plugin'
long_description 'Supports AWS EKS cluster and select resources'
version '2.0.0'
documentation_link 'source' do
label 'Source'
url 'https://github.com/rightscale/rightscale-plugins/blob/master/aws/rs_aws_eks/aws_eks_plugin.rb'
end
documentation_link 'readme' do
label 'Readme'
url 'https://github.com/rightscale/rightscale-plugins/blob/master/aws/rs_aws_eks/README.md'
end
documentation_link 'changelog' do
label 'Changelog'
url 'https://github.com/rightscale/rightscale-plugins/blob/master/aws/rs_aws_eks/CHANGELOG.md'
end
parameter 'region' do
type 'string'
label 'AWS Region'
end
parameter 'page_size' do
type 'string'
label 'Page size for AWS responses'
end
endpoint do
default_host "eks.$region.amazonaws.com"
default_scheme "https"
end
type "clusters" do
href_templates "{{cluster.name}}"
provision "provision_resource"
delete "delete_resource"
field "client_request_token" do
alias_for "clientRequestToken"
type "string"
end
field "name" do
type "string"
required true
end
field "resources_vpc_config" do
alias_for "resourcesVpcConfig"
type "composite"
required true
end
field "role_arn" do
alias_for "roleArn"
type "string"
required true
end
field "version" do
type "string"
end
field "next_token" do
alias_for "nextToken"
type "string"
location "query"
end
field "page_size" do
type 'string'
location 'query'
alias_for 'MaxResults'
end
action "create" do
verb "POST"
path "/clusters"
end
action "destroy" do
verb "DELETE"
path "$href"
end
action "get" do
verb "GET"
path "$href"
end
action "list" do
verb "GET"
path "/clusters/$cluster_name"
field "page_size" do
type 'string'
location 'query'
alias_for 'MaxResults'
end
field "cluster_name" do
location "path"
end
end
output_path "cluster"
output "endpoint","status","createdAt","certificateAuthority","arn","roleArn","clientRequestToken","version","name","resourcesVpcConfig"
polling do
field_values do
cluster_name parent_field('name')
end
period 60
action 'list'
parent 'clustersname'
end
end
type "clustersname" do
href_templates "{{clusters[]}}"
action "list" do
verb "GET"
path "/clusters"
end
output_path 'clusters'
output 'name' do
body_path '@'
end
polling do
field_values do
end
period 60
action 'list'
end
end
type "nodegroupname" do
href_templates "{{nodegroups[]}}"
field "cluster_name" do
location "path"
type "string"
end
action "list" do
verb "GET"
path "/clusters/$cluster_name/node-groups"
field "cluster_name" do
location "path"
end
end
output_path "nodegroups"
output 'name' do
body_path '@'
end
output 'cluster_name' do
body_path "$cluster_name"
end
polling do
field_values do
cluster_name parent_field('name')
end
period 60
action 'list'
parent 'clustersname'
end
end
type "nodegroups" do
href_templates "{{nodegroups.name}}"
provision "provision_resource"
delete "delete_resource"
field "next_token" do
alias_for "nextToken"
type "string"
location "query"
end
field "cluster_name" do
location "path"
type "string"
end
field "amiType" do
type "string"
location "body"
end
field "diskSize" do
type "string"
location "body"
end
field "instanceTypes" do
type "array"
location "body"
end
field "labels" do
type "composite"
location "body"
end
field "name" do
alias_for "nodegroupName"
type "string"
required "true"
location "body"
end
field "nodeRole" do
type "string"
location "body"
end
field "releaseVersion" do
type "string"
location "body"
end
field "remoteAccess" do
type "composite"
location "body"
end
field "scalingConfig" do
type "composite"
location "body"
end
field "subnets" do
type "array"
location "body"
required "true"
end
field "tags" do
type "composite"
location "body"
end
field "version" do
type "string"
location "body"
end
action "create" do
verb "POST"
path "/clusters/$cluster_name/node-groups"
end
action "destroy" do
verb "DELETE"
path "$href"
end
action "get" do
verb "GET"
path "$href"
output_path "nodegroup"
end
action "list" do
verb "GET"
path "/clusters/$cluster_name/node-groups/$node_name"
field "cluster_name" do
location "path"
end
field "node_name" do
location "path"
end
output_path "nodegroup[*]"
end
output "amiType","clusterName","createdAt","diskSize","health","instanceTypes","labels","modifiedAt","nodegroupArn","nodegroupName","nodeRole","releaseVersion","remoteAccess","resources","scalingConfig","status","subnets","tags","version"
polling do
field_values do
cluster_name parent_field('cluster_name')
node_name parent_field('name')
end
parent 'nodegroupname'
period 60
action 'list'
end
end
end
resource_pool "aws_eks" do
plugin $aws_eks
parameter_values do
region $region
page_size $page_size
end
host join(["eks.",$region,".amazonaws.com"])
auth "key", type: "aws" do
version 4
service 'eks'
access_key cred('AWS_ACCESS_KEY_ID')
secret_key cred('AWS_SECRET_ACCESS_KEY')
end
end
define no_operation() do
end
define provision_resource(@declaration) return @resource do
$object = to_object(@declaration)
$fields = $object["fields"]
$type = $object["type"]
call sys_log.set_task_target(@@deployment)
call sys_log.summary(join(["Provision ", $type]))
call sys_log.detail($object)
call start_debugging()
@operation = aws_eks.$type.empty()
sub on_error: stop_debugging() do
@operation = aws_eks.$type.create($fields)
end
call stop_debugging()
call sys_log.detail(to_object(@operation))
call start_debugging()
sub timeout: 20m, on_timeout: skip, on_error: stop_debugging() do
sleep_until(@operation.status =~ "^(ACTIVE|DELETING|FAILED)")
end
if @operation.status != "ACTIVE"
@operation.destroy()
raise "Failed to provision EKS Cluster"
end
@resource = @operation.get()
call stop_debugging()
call sys_log.detail(to_object(@resource))
end
define delete_resource(@declaration) do
call start_debugging()
@declaration.destroy()
call stop_debugging()
end
define start_debugging() do
if $$debugging == false || logic_and($$debugging != false, $$debugging != true)
initiate_debug_report()
$$debugging = true
end
end
define stop_debugging() do
if $$debugging == true
$debug_report = complete_debug_report()
call sys_log.detail($debug_report)
$$debugging = false
end
end