-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathclassic-architecture-on-the-cloud.yml
More file actions
624 lines (618 loc) · 15 KB
/
classic-architecture-on-the-cloud.yml
File metadata and controls
624 lines (618 loc) · 15 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
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
ROSTemplateFormatVersion: '2015-09-01'
Description:
zh-cn: 创建双可用区云上架构,含VPC、ECS实例、PolarDB数据库、ALB负载均衡,自动部署WordPress。
en: Establish a dual-Availability Zone cloud architecture comprising a Virtual Private
Cloud (VPC), Elastic Compute Service (ECS) instances, PolarDB database, and Application
Load Balancer (ALB), with automated deployment of WordPress.
Parameters:
EcsInstanceType1:
Type: String
Label:
en: Instance Type for Availability Zone1
zh-cn: 可用区1对应实例类型
AssociationProperty: 'ALIYUN::ECS::Instance::InstanceType'
AssociationPropertyMetadata:
InstanceChargeType: PostPaid
SpotStrategy: SpotAsPriceGo
ZoneId: ${Zone1}
SystemDiskCategory: cloud_essd
Description:
en: >-
If no available specifications are displayed, please select Modify
Availability Zone and try again.
zh-cn: 如果没有可用规格显示,请选择修改可用区后重试。
Default: ecs.s6-c1m1.small
EcsInstanceType2:
Type: String
Label:
en: Instance Type for Availability Zone2
zh-cn: 可用区2对应实例类型
AssociationProperty: 'ALIYUN::ECS::Instance::InstanceType'
AssociationPropertyMetadata:
InstanceChargeType: PostPaid
SpotStrategy: SpotAsPriceGo
ZoneId: ${Zone2}
SystemDiskCategory: cloud_essd
Description:
en: >-
If no available specifications are displayed, please select Modify
Availability Zone and try again.
zh-cn: 如果没有可用规格显示,请选择修改可用区后重试。
Default: ecs.s6-c1m1.small
Zone1:
Type: String
Label:
en: VSwitch Availability Zone1
zh-cn: 交换机可用区1
AssociationProperty: 'ALIYUN::ECS::Instance::ZoneId'
AssociationPropertyMetadata:
AutoSelectFirst: true
ExclusiveTo:
- Zone2
Zone2:
Type: String
Label:
en: VSwitch Availability Zone2
zh-cn: 交换机可用区2
AssociationProperty: 'ALIYUN::ECS::Instance::ZoneId'
AssociationPropertyMetadata:
AutoSelectFirst: true
ExclusiveTo:
- Zone1
InstancePassword:
Type: String
Label:
en: Instance Password
zh-cn: 实例密码
Description:
en: >-
Server login password, Length 8-30, must contain three(Capital letters,
lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special
symbol in)
zh-cn: >-
服务器登录密码,长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/
中的特殊符号),不能以特殊字符开头。
ConstraintDescription:
en: >-
Length 8-30, must contain three(Capital letters, lowercase letters,
numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)
zh-cn: '长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;''<>,.?/ 中的特殊符号),不能以特殊字符开头。'
AssociationProperty: 'ALIYUN::ECS::Instance::Password'
NoEcho: true
PolarDBName:
Type: String
Label:
en: PolarDB Name
zh-cn: 数据库名称
Default: wordpress
DBNodeClass:
Type: String
Label:
en: DBNodeClass
zh-cn: PolarDB集群规格
Default: polar.mysql.g2.medium
PolarDBAccountName:
Type: String
Label:
en: Account Name of PolarDB
zh-cn: 数据库登录名
Default: wordpress
PolarDBPassword:
Type: String
Label:
en: PolarDB Login Password
zh-cn: 数据库登录密码
Description:
en: >-
Software login password, There are three types of uppercase and lowercase letters,
numbers, and special characters, with a length of 8~32 characters; the special characters are !@#$%^&*()_+-=
zh-cn: 软件登录密码,大小写字母、数字、特殊字符占三种,长度为8~32个字符,不能以特殊字符开头,特殊字符为!@#$%^&*()_+-=
ConstraintDescription:
en: >-
There are three types of uppercase and lowercase letters, numbers, and special characters,
with a length of 8~32 characters; the special characters are !@#$%^&*()_+-=
zh-cn: '大小写字母、数字、特殊字符占三种,长度为8~32个字符,不能以特殊字符开头,特殊字符为!@#$%^&*()_+-='
AllowedPattern: '^[a-zA-Z](?=.*[a-zA-Z])(?=.*[0-9])(?=.*[!@#$%^&*()_+\-=])[A-Za-z\d!@#$%^&*()_+\-=]{7,31}$'
NoEcho: true
CommonName:
Type: String
Default: high-availability
Resources:
EcsVpc:
Type: 'ALIYUN::ECS::VPC'
Properties:
VpcName:
'Fn::Sub': '${CommonName}_vpc'
CidrBlock: 192.168.0.0/16
EcsVSwitch1:
Type: 'ALIYUN::ECS::VSwitch'
Properties:
ZoneId:
Ref: Zone1
VpcId:
Ref: EcsVpc
VSwitchName:
'Fn::Sub': '${CommonName}_vsw_001'
CidrBlock: 192.168.1.0/24
EcsVSwitch2:
Type: 'ALIYUN::ECS::VSwitch'
Properties:
ZoneId:
Ref: Zone2
VpcId:
Ref: EcsVpc
VSwitchName:
'Fn::Sub': '${CommonName}_vsw_002'
CidrBlock: 192.168.2.0/24
EcsSecurityGroup:
Type: 'ALIYUN::ECS::SecurityGroup'
Properties:
VpcId:
Ref: EcsVpc
SecurityGroupName:
'Fn::Sub': '${CommonName}_sg'
SecurityGroupIngress:
- PortRange: 3306/3306
Priority: 1
SourceCidrIp: 0.0.0.0/0
IpProtocol: tcp
NicType: internet
- PortRange: 80/80
Priority: 1
SourceCidrIp: 0.0.0.0/0
IpProtocol: tcp
NicType: internet
- PortRange: 443/443
Priority: 1
SourceCidrIp: 0.0.0.0/0
IpProtocol: tcp
NicType: internet
SecurityGroupEgress:
- PortRange: '-1/-1'
Priority: 1
IpProtocol: all
DestCidrIp: 0.0.0.0/0
NicType: internet
- PortRange: '-1/-1'
Priority: 1
IpProtocol: all
DestCidrIp: 0.0.0.0/0
NicType: intranet
EcsInstanceGroup1:
Type: 'ALIYUN::ECS::Instance'
Properties:
ZoneId:
Ref: Zone1
VpcId:
Ref: EcsVpc
VSwitchId:
Ref: EcsVSwitch1
SecurityGroupId:
Ref: EcsSecurityGroup
ImageId: centos_7_9
IoOptimized: optimized
SystemDiskSize: 20
InstanceType:
Ref: EcsInstanceType1
Password:
Ref: InstancePassword
InstanceName:
'Fn::Sub': '${CommonName}_ecs1'
SpotStrategy: SpotAsPriceGo
SystemDiskCategory: cloud_essd
EcsInstanceGroup2:
Type: 'ALIYUN::ECS::Instance'
Properties:
ZoneId:
Ref: Zone2
VpcId:
Ref: EcsVpc
VSwitchId:
Ref: EcsVSwitch2
SecurityGroupId:
Ref: EcsSecurityGroup
ImageId: centos_7_9
IoOptimized: optimized
SystemDiskSize: 20
InstanceType:
Ref: EcsInstanceType2
Password:
Ref: InstancePassword
InstanceName:
'Fn::Sub': '${CommonName}_ecs2'
SpotStrategy: SpotAsPriceGo
SystemDiskCategory: cloud_essd
InstanceRunCommand:
Type: 'ALIYUN::ECS::RunCommand'
Properties:
InstanceIds:
- Ref: EcsInstanceGroup1
- Ref: EcsInstanceGroup2
Sync: true
Type: RunShellScript
Timeout: '300'
CommandContent:
'Fn::Sub': >-
#!/bin/bash
yum install docker -y
systemctl start docker
systemctl enable docker.service
docker pull docker.io/library/wordpress:5.6
mkdir /wordpress
docker run --name my-blog --restart=always -v /wordpress:/var/www/html
-p 80:80 -d --env
WORDPRESS_DB_HOST=${PolarDBCluster.ClusterConnectionString} --env
WORDPRESS_DB_USER=${PolarDBAccountName} --env
WORDPRESS_DB_PASSWORD=${PolarDBPassword} --env
WORDPRESS_DB_NAME=${PolarDBName} wordpress:5.6
PolarDBCluster:
Type: 'ALIYUN::POLARDB::DBCluster'
Properties:
ZoneId:
Ref: Zone2
VpcId:
Ref: EcsVpc
VSwitchId:
Ref: EcsVSwitch2
SecurityGroupIds:
- Ref: EcsSecurityGroup
DBType: MySQL
ClusterNetworkType: VPC
DBVersion: '8.0'
CreationOption: Normal
DBNodeClass:
Ref: DBNodeClass
SecurityIPList: 192.168.0.0/16
PayType: Postpaid
PolarDBInstance:
Type: 'ALIYUN::POLARDB::DBInstance'
Properties:
DBClusterId:
Ref: PolarDBCluster
CharacterSetName: utf8mb4
DBName:
Ref: PolarDBName
PolarDBAccount:
Type: 'ALIYUN::POLARDB::Account'
Properties:
DBClusterId:
Ref: PolarDBCluster
AccountName:
Ref: PolarDBAccountName
AccountPrivilege: ReadWrite
AccountType: Normal
AccountPassword:
Ref: PolarDBPassword
DBName:
Ref: PolarDBInstance
AlbLoadBalancer:
Type: 'ALIYUN::ALB::LoadBalancer'
Properties:
VpcId:
Ref: EcsVpc
LoadBalancerName:
'Fn::Sub': '${CommonName}_alb'
LoadBalancerEdition: Basic
LoadBalancerBillingConfig:
PayType: PostPay
AddressType: Internet
AddressAllocatedMode: Dynamic
ZoneMappings:
- ZoneId:
Ref: Zone1
VSwitchId:
Ref: EcsVSwitch1
- ZoneId:
Ref: Zone2
VSwitchId:
Ref: EcsVSwitch2
AlbServerGroup:
Type: 'ALIYUN::ALB::ServerGroup'
Properties:
VpcId:
Ref: EcsVpc
HealthCheckConfig:
HealthCheckEnabled: true
HealthCheckPath: /
HealthCheckCodes:
- http_2xx
- http_3xx
HealthCheckProtocol: HTTP
ServerGroupName:
'Fn::Sub': '${CommonName}_server_group'
StickySessionConfig:
StickySessionEnabled: false
ServerAttachment:
Type: 'ALIYUN::ALB::BackendServerAttachment'
Properties:
ServerGroupId:
Ref: AlbServerGroup
Servers:
- ServerType: Ecs
ServerId:
Ref: EcsInstanceGroup1
Port: 80
Weight: 100
- ServerType: Ecs
ServerId:
Ref: EcsInstanceGroup2
Port: 80
Weight: 100
AlbListener:
Type: 'ALIYUN::ALB::Listener'
Properties:
ListenerPort: 80
DefaultActions:
- Type: ForwardGroup
ForwardGroupConfig:
ServerGroupTuples:
- ServerGroupId:
Ref: AlbServerGroup
LoadBalancerId:
Ref: AlbLoadBalancer
ListenerProtocol: HTTP
Outputs:
WordPressUrl:
Description:
en: The url of WordPress.
zh-cn: WordPress 访问地址。
Value:
'Fn::Sub':
- 'http://${AlbDnsName}'
- AlbDnsName:
'Fn::GetAtt':
- AlbLoadBalancer
- DNSName
Metadata:
'ALIYUN::ROS::Interface':
ParameterGroups:
- Parameters:
- Zone1
- Zone2
Label:
default:
en: Availability Zone
zh-cn: 可用区配置
- Parameters:
- EcsInstanceType1
- EcsInstanceType2
- InstancePassword
Label:
default:
en: Instance
zh-cn: ECS实例配置
- Parameters:
- PolarDBName
- DBNodeClass
- PolarDBAccountName
- PolarDBPassword
Label:
default:
en: PolarDB Information
zh-cn: PolarDB配置
TemplateTags:
- >-
acs:technical-solution:high-availability-architecture:云上经典架构-tech_solu_07
Hidden:
- CommonName
ALIYUN::ROS::Composer:
1c38817e:
Rect:
- 1080
- 570
- 40
- 100
- 1
- 0
ResT: Composer::ROSParameter::AlibabaCloud
28165fb9:
Parent: 1c38817e
Rect:
- 1040
- 500
- 60
- 150
- 2
- 0
ResT: Composer::ROSParameter::Region
71ec7a89:
Res:
- EcsVpc
Parent: 28165fb9
Rect:
- 940
- 426
- 140
- 200
- 3
- 0
38bc4d48:
Res:
- InstanceRunCommand
Parent: 28165fb9
Rect:
- 40
- 40
- 80
- 200
- 3
- 0
Hidden: true
7524fd3a:
Res:
- PolarDBInstance
Parent: 71ec7a89
Rect:
- 40
- 40
- 944
- 550
- 3
- 0
ResT: ALIYUN::POLARDB::DBInstance
a64f87bb:
Res:
- PolarDBAccount
Parent: 28165fb9
Rect:
- 40
- 40
- 80
- 590
- 3
- 0
Hidden: true
2f329690:
Res:
- Zone1
Parent: 71ec7a89
Rect:
- 440
- 270
- 160
- 250
- 4
- 0
ResT: Composer::ROSParameter::Zone
2642f034:
Res:
- Zone2
Parent: 71ec7a89
Rect:
- 440
- 300
- 620
- 250
- 4
- 0
ResT: Composer::ROSParameter::Zone
41f9d470:
Res:
- EcsVSwitch1
Parent: 2f329690
Rect:
- 400
- 200
- 180
- 300
- 5
- 0
d846367a:
Res:
- EcsVSwitch2
Parent: 2642f034
Rect:
- 400
- 230
- 640
- 300
- 5
- 0
a9390e78:
Res:
- PolarDBCluster
Parent: d846367a
Rect:
- 40
- 40
- 944
- 380
- 6
- 0
22bbd8d9:
Res:
- AlbServerGroup
- ServerAttachment
Ref:
- ServerAttachment
Parent: 71ec7a89
Rect:
- 616
- 148
- 272
- 339
- 10
- 0
8a8bc17e:
Parent: 28165fb9
Edge:
- 38bc4d48
- fdef2010
Line: 0:0:0:gray:0
'00222634':
Parent: 28165fb9
Edge:
- 38bc4d48
- '7e379278'
Line: 0:0:0:gray:0
ab9087fb:
Parent: 71ec7a89
Edge:
- 7524fd3a
- a9390e78
Line: 0:0:0:gray:0
'2950e211':
Parent: 28165fb9
Edge:
- a64f87bb
- a9390e78
Line: 0:0:0:gray:0
c2abc77d:
Parent: 28165fb9
Edge:
- a64f87bb
- 7524fd3a
Line: 0:0:0:gray:0
5fd7666a:
Res:
- EcsSecurityGroup
Parent: 71ec7a89
Rect:
- 644
- 119
- 198
- 345
- 11
- 0
'7e379278':
Res:
- EcsInstanceGroup2
Parent: d846367a
Rect:
- 40
- 40
- 772
- 380
- 12
- 0
Layer:
- 5fd7666a
- 22bbd8d9
fdef2010:
Res:
- EcsInstanceGroup1
Parent: 41f9d470
Rect:
- 40
- 40
- 350
- 380
- 12
- 0
Layer:
- 5fd7666a
- 22bbd8d9
72703c74:
Res:
- AlbLoadBalancer
- AlbListener
Ref:
- AlbListener
Parent: d846367a
Rect:
- 40
- 40
- 679
- 380
- 12
- 0