-
Notifications
You must be signed in to change notification settings - Fork 35
/
new-vpc-ack-and-jump-server.yml
476 lines (472 loc) · 13.4 KB
/
new-vpc-ack-and-jump-server.yml
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
ROSTemplateFormatVersion: '2015-09-01'
Description:
zh-cn: 创建VPC、交换机、安全组,部署Kubernetes托管集群,配置跳板机通过kubectl部署应用。
en: Create a Virtual Private Cloud (VPC), set up switches, configure security groups,
deploy a managed Kubernetes cluster, and set up a bastion host to deploy applications
via kubectl.
Parameters:
PayType:
Type: String
Label:
en: ECS Instance Charge Type
zh-cn: 付费类型
AssociationProperty: ChargeType
AssociationPropertyMetadata:
LocaleKey: InstanceChargeType
Default: PostPaid
AllowedValues:
- PostPaid
- PrePaid
PayPeriodUnit:
Type: String
Label:
en: Pay Period Unit
zh-cn: 购买资源时长周期
AssociationProperty: PayPeriodUnit
AssociationPropertyMetadata:
Visible:
Condition:
Fn::Not:
Fn::Equals:
- ${PayType}
- PostPaid
Default: Month
AllowedValues:
- Month
- Year
PayPeriod:
Type: Number
Label:
en: Period
zh-cn: 购买资源时长
AssociationProperty: PayPeriod
AssociationPropertyMetadata:
Visible:
Condition:
Fn::Not:
Fn::Equals:
- ${PayType}
- PostPaid
Default: 1
AllowedValues:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
ZoneId:
Type: String
Label:
en: Zone ID
zh-cn: 可用区
AssociationProperty: ALIYUN::ECS::Instance:ZoneId
VpcCidrBlock:
Type: String
Label:
en: VPC CIDR IPv4 Block
zh-cn: 专有网络IPv4网段
Description:
zh-cn: VPC的ip地址段范围,<br>您可以使用以下的ip地址段或其子网:<br><font color='green'>[10.0.0.0/8]</font><br><font
color='green'>[172.16.0.0/12]</font><br><font color='green'>[192.168.0.0/16]</font>
en: 'The ip address range of the VPC in the CidrBlock form; <br>You can use
the following ip address ranges and their subnets: <br><font color=''green''>[10.0.0.0/8]</font><br><font
color=''green''>[172.16.0.0/12]</font><br><font color=''green''>[192.168.0.0/16]</font>'
AssociationProperty: ALIYUN::VPC::VPC::CidrBlock
Default: 192.168.0.0/16
VSwitchCidrBlock:
Type: String
Label:
en: VSwitch CIDR Block
zh-cn: 交换机子网网段
Description:
zh-cn: 必须属于VPC的子网段。
en: Must belong to the subnet segment of VPC.
AssociationProperty: ALIYUN::VPC::VSwitch::CidrBlock
AssociationPropertyMetadata:
VpcCidrBlock: VpcCidrBlock
Default: 192.168.1.0/24
LoginPassword:
Type: String
Label:
en: Instance Password
zh-cn: 实例密码
Description:
en: 'Length 8-32 characters, can contain size letters, Numbers and special symbols,
including:! @ # $ % ^ & * ( ) _ + - ='
zh-cn: 长度8-32个字符,可包含大小字母、数字及特殊符号(包含:!@#$%^&*()_+-=)
ConstraintDescription:
en: '8-32 characters, can contain size letters, Numbers and special symbols,
including:! @ # $ % ^ & * ( ) _ + - ='
zh-cn: 8-32个字符,可包含大小字母、数字及特殊符号(包含:!@#$%^&*()_+-=)
AssociationProperty: ALIYUN::ECS::Instance::Password
MinLength: 8
MaxLength: 32
NoEcho: true
WorkerInstanceType:
Type: String
Label:
en: Worker Nodes Types
zh-cn: Worker节点规格
AssociationProperty: ALIYUN::ECS::Instance::InstanceType
AssociationPropertyMetadata:
ZoneId: ${ZoneId}
Default: ecs.g6.large
WorkerSystemDiskCategory:
Type: String
Label:
en: Worker System Disk Category
zh-cn: Worker 系统盘磁盘类型
AssociationPropertyMetadata:
LocaleKey: DiskCategory
InstanceType: ${WorkerInstanceType}
Default: cloud_essd
AllowedValues:
- cloud_efficiency
- cloud_ssd
- cloud_essd
WorkerSystemDiskSize:
Type: Number
Label:
en: Worker System Disk Size(GB)
zh-cn: Worker节点系统盘大小(GB)
Default: 120
MinValue: 1
PodCidr:
Type: String
Label:
zh-cn: Pod 网络 CIDR
en: Pod Network CIDR
Description:
zh-cn: 请填写有效的私有网段,即以下网段及其子网:10.0.0.0/8,172.16-31.0.0/12-16,192.168.0.0/16<br>不能与
VPC 及 VPC 内已有 Kubernetes 集群使用的网段重复。<font color='blue'><b>创建成功后不能修改</b></font>
en: 'Please fill in a valid private segment, i.e. the following segments and
their subnets: 10.0.0.0/8, 172.16-31.0.0/12-16, 192.168.0.0/16<br> which cannot
duplicate the network segments already used by clusters in VPC and VPC Kunetberes.
<font color=''blue''><b>Cannot be modified after successful creation</b></font>'
AssociationProperty: ALIYUN::CS::ManagedKubernetesCluster::PodCidr
Default: 10.0.0.0/16
ServiceCidr:
Type: String
Label:
zh-cn: Service CIDR
en: Service CIDR
Description:
zh-cn: 可选范围:10.0.0.0/16-24,172.16-31.0.0/16-24,192.168.0.0/16-24<br>不能与 VPC
及 VPC 内已有 Kubernetes 集群使用的网段重复。<font color='blue'><b>创建成功后不能修改</b></font>
en: 'Optional range: 10.0.0.0/16-24, 172.16-31.0.0/16-24, 192.168.0.0/16-24<br>
cannot duplicate segments already used by existing Kubernetes clusters in
VPC and VPC.<font color=''blue''><b>Cannot be modified after successful creation</b></font>'
AssociationProperty: ALIYUN::CS::ManagedKubernetesCluster::ServiceCidr
Default: 172.16.0.0/16
EcsInstanceType:
Type: String
Label:
en: Instance Type
zh-cn: 跳板机实例类型
AssociationProperty: ALIYUN::ECS::Instance::InstanceType
AssociationPropertyMetadata:
ZoneId: ${ZoneId}
Default: ecs.g6.large
SystemDiskSize:
Type: Number
Label:
zh-cn: 系统盘空间 (GB)
en: System Disk Space (GB)
Default: 40
SystemDiskCategory:
Type: String
Label:
en: System Disk Category
zh-cn: 系统盘类型
AssociationProperty: ALIYUN::ECS::Disk::SystemDiskCategory
AssociationPropertyMetadata:
LocaleKey: DiskCategory
InstanceType: ${EcsInstanceType}
Default: cloud_essd
AllowedValues:
- cloud_efficiency
- cloud_ssd
- cloud_essd
LoadBalancerSpec:
Type: String
Label:
en: Specifications
zh-cn: 规格
AssociationProperty: ALIYUN::SLB::Instance::InstanceType
Default: slb.s1.small
Resources:
EcsVpc:
Type: ALIYUN::ECS::VPC
Properties:
CidrBlock:
Ref: VpcCidrBlock
VpcName:
Ref: ALIYUN::StackName
EcsVSwitch:
Type: ALIYUN::ECS::VSwitch
Properties:
ZoneId:
Ref: ZoneId
VpcId:
Ref: EcsVpc
CidrBlock:
Ref: VSwitchCidrBlock
EcsSecurityGroup:
Type: ALIYUN::ECS::SecurityGroup
Properties:
VpcId:
Ref: EcsVpc
SecurityGroupEgress:
- PortRange: -1/-1
Priority: 1
IpProtocol: all
DestCidrIp: 0.0.0.0/0
NicType: intranet
ManagedKubernetesCluster:
Type: ALIYUN::CS::ManagedKubernetesCluster
Properties:
VpcId:
Ref: EcsVpc
VSwitchIds:
- Ref: EcsVSwitch
SecurityGroupId:
Ref: EcsSecurityGroup
ChargeType:
Ref: PayType
Period:
Ref: PayPeriod
PeriodUnit:
Ref: PayPeriodUnit
WorkerInstanceTypes:
- Ref: WorkerInstanceType
NumOfNodes: 3
ClusterSpec: ack.pro.small
ContainerCidr:
Ref: PodCidr
ServiceCidr:
Ref: ServiceCidr
ZoneIds:
- Ref: ZoneId
WorkerSystemDiskCategory:
Ref: WorkerSystemDiskCategory
WorkerSystemDiskSize:
Ref: WorkerSystemDiskSize
LoginPassword:
Ref: LoginPassword
SnatEntry: true
Addons:
- Name: flannel
Config: ''
Name:
Ref: ALIYUN::StackName
Slb:
Type: ALIYUN::SLB::LoadBalancer
Properties:
VpcId:
Ref: EcsVpc
VSwitchId:
Ref: EcsVSwitch
PayType:
Ref: PayType
PricingCycle:
Ref: PayPeriodUnit
Duration:
Ref: PayPeriod
LoadBalancerName:
Ref: ALIYUN::StackName
LoadBalancerSpec:
Ref: LoadBalancerSpec
AddressType: intranet
EipSlbAddress:
Type: ALIYUN::VPC::EIP
Properties:
InternetChargeType: PayByTraffic
Bandwidth: 100
EipSlbAddressAssociation:
Type: ALIYUN::VPC::EIPAssociation
Properties:
InstanceId:
Ref: Slb
AllocationId:
Ref: EipSlbAddress
WaitConditionHandle:
Type: ALIYUN::ROS::WaitConditionHandle
Properties: {}
WaitCondition:
Type: ALIYUN::ROS::WaitCondition
Properties:
Count: 1
Handle:
Ref: WaitConditionHandle
Timeout: 300
DependsOn:
- ManagedKubernetesCluster
EcsInstanceJumpBox:
Type: ALIYUN::ECS::InstanceGroup
Properties:
ZoneId:
Ref: ZoneId
VpcId:
Ref: EcsVpc
VSwitchId:
Ref: EcsVSwitch
SecurityGroupId:
Ref: EcsSecurityGroup
ImageId: centos_7
InstanceChargeType:
Ref: PayType
Period:
Ref: PayPeriod
PeriodUnit:
Ref: PayPeriodUnit
InstanceName: jumpbox
InstanceType:
Ref: EcsInstanceType
AllocatePublicIP: false
Password:
Ref: LoginPassword
MaxAmount: 1
SystemDiskSize:
Ref: SystemDiskSize
SystemDiskCategory:
Ref: SystemDiskCategory
DependsOn:
- ManagedKubernetesCluster
- Slb
InstanceRunCommand:
Type: ALIYUN::ECS::RunCommand
Properties:
InstanceIds:
Fn::GetAtt:
- EcsInstanceJumpBox
- InstanceIds
CommandContent:
Fn::Sub:
- |
#!/bin/bash
# 安装kubectl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
install -o root -g root -m 0755 kubectl /usr/bin/kubectl
# 配置kubeconfig信息
mkdir -p ~/.kube
echo '${KubeConfig}' >> ~/.kube/config
echo '${ApplicationYaml}' > ~/application.yaml
sleep 10
# 应用容器模版
kubectl --kubeconfig ~/.kube/config apply -f ~/application.yaml
# 执行成功回调WaitCondition结束waitCondition的等待
${CurlCli} -d "{\"Data\" : \"Success\", \"status\" : \"SUCCESS\"}"
- KubeConfig:
Fn::GetAtt:
- ManagedKubernetesCluster
- PrivateUserKubConfig
CurlCli:
Fn::GetAtt:
- WaitConditionHandle
- CurlCli
ApplicationYaml:
Fn::Sub:
- |
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
labels:
app: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-id: ${LoadBalancerId}
service.beta.kubernetes.io/alicloud-loadbalancer-force-override-listeners: "true"
labels:
app: nginx
name: nginx-svc
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
app: nginx
type: LoadBalancer
- LoadBalancerId:
Fn::GetAtt:
- Slb
- LoadBalancerId
Type: RunShellScript
Timeout: 300
Outputs:
endpoint:
Description:
zh-cn: 对外暴露的公网IP地址
en: Public IP Addresses
Value:
Fn::Sub:
- http://${ServerAddress}
- ServerAddress:
Fn::GetAtt:
- EipSlbAddress
- EipAddress
Metadata:
ALIYUN::ROS::Interface:
ParameterGroups:
- Parameters:
- PayType
- PayPeriodUnit
- PayPeriod
Label:
default:
en: PayType Configuration
zh-cn: 付费类型配置
- Parameters:
- ZoneId
- VpcCidrBlock
- VSwitchCidrBlock
- LoginPassword
Label:
en: Basic Configuration
zh-cn: 基础配置
- Parameters:
- WorkerInstanceType
- WorkerSystemDiskCategory
- WorkerSystemDiskSize
- PodCidr
- ServiceCidr
Label:
en: Kubernetes Configuration
zh-cn: Kubernetes配置
- Parameters:
- EcsInstanceType
- SystemDiskSize
- SystemDiskCategory
Label:
en: ECS JumpServer Configuration
zh-cn: ECS跳板机配置
- Parameters:
- LoadBalancerSpec
Label:
en: SLB Configuration
zh-cn: 负载均衡配置
TemplateTags:
- acs:example:ISV软件部署:新建一组Kubernetes托管版集群,并创建一台跳板机使用kubectl部署应用