-
Notifications
You must be signed in to change notification settings - Fork 35
/
cloud-native-observable-operation-and-maintenance.yml
368 lines (359 loc) · 10.4 KB
/
cloud-native-observable-operation-and-maintenance.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
ROSTemplateFormatVersion: '2015-09-01'
Description:
zh-cn: 创建云原生可观测运维环境,含VPC、Kubernetes集群、SLS日志项目、OSS存储及日志导出配置。
en: Establish a cloud-native observable operations environment, encompassing a Virtual
Private Cloud (VPC), Kubernetes cluster, Log Service (SLS) log project, Object
Storage Service (OSS) for storage, and configurations for log export.
Parameters:
ZoneId:
Type: String
AssociationProperty: ALIYUN::ECS::Instance:ZoneId
Label:
en: Availability zone
zh-cn: 可用区
Description:
en: Available area id, <a href='https://help.aliyun.com/document_detail/123712.html'
target='_blank'><b><font color='blue'>View region and zone info</font></b></a>.
zh-cn: 可用区ID,</font><a href='https://help.aliyun.com/document_detail/123712.html'
target='_blank'><b> 查看可用区信息</b><font color='blue'></a>。
EcsInstanceType:
Type: String
Label:
en: Instance type
zh-cn: 实例规格
AssociationProperty: ALIYUN::ECS::Instance::InstanceType
AllowedPattern: ^(ecs\.[a-z6-9]+\.)[1-9]?xlarge$
Description:
en: It is recommended to use a new generation of ecs instances. If the instance
specification cannot be selected, please change the availability zone again.
zh-cn: 建议使用新一代的 ecs 实例,如果选择不到实例规格,请重新更换可用区。
Resources:
Vpc:
Type: ALIYUN::ECS::VPC
Properties:
VpcName: vpc-test
CidrBlock: 192.168.0.0/16
VSwitch:
Type: ALIYUN::ECS::VSwitch
Properties:
VpcId:
Ref: Vpc
ZoneId:
Ref: ZoneId
VSwitchName: vsw-test
CidrBlock: 192.168.0.0/24
SecurityGroup:
Type: ALIYUN::ECS::SecurityGroup
Properties:
VpcId:
Ref: Vpc
SlsProject:
Type: ALIYUN::SLS::Project
Properties:
Name:
Fn::Sub: project-test-${ALIYUN::StackId}
SSHKeyPair:
Type: ALIYUN::ECS::SSHKeyPair
Properties:
KeyPairName:
Fn::Sub: ess-${ALIYUN::StackId}
K8sCluster:
Type: ALIYUN::CS::ManagedKubernetesCluster
Properties:
VpcId:
Ref: Vpc
VSwitchIds:
- Ref: VSwitch
PodVswitchIds:
- Ref: VSwitch
SecurityGroupId:
Ref: SecurityGroup
ServiceCidr: 172.16.0.0/16
ZoneIds:
- Ref: ZoneId
WorkerInstanceTypes:
- Ref: EcsInstanceType
Name:
Fn::Sub: ACK-test-${ALIYUN::StackId}
ClusterSpec: ack.pro.small
NumOfNodes: 0
NodePools:
- NodePoolInfo:
Name: default-nodepool
ScalingGroup:
VSwitchIds:
- Ref: VSwitch
InstanceTypes:
- Ref: EcsInstanceType
SystemDiskSize: 120
SystemDiskCategory: cloud_essd
KeyPair:
Fn::GetAtt:
- SSHKeyPair
- KeyPairName
KubernetesConfig:
Runtime: containerd
RuntimeVersion: 1.6.20
Count: 3
Addons:
- Name: terway-eniip
- Name: csi-plugin
- Name: csi-provisioner
- Name: logtail-ds
Config:
Fn::Sub:
- '{"IngressDashboardEnabled":"true","sls_project_name":"${sls_project_name}"}'
- sls_project_name:
Fn::GetAtt:
- SlsProject
- Name
OssBucket:
Type: ALIYUN::OSS::Bucket
Properties:
BucketName:
Fn::Sub: oss-test-${ALIYUN::StackId}
StorageClass: Standard
DeletionForce: true
RedundancyType: ZRS
Sleep:
Type: ALIYUN::ROS::Sleep
Properties:
CreateDuration: 300
DependsOn: K8sCluster
LogStores:
Type: DATASOURCE::SLS::Logstores
DependsOn: Sleep
Properties:
Project:
Fn::GetAtt:
- SlsProject
- Name
LogstoreName: audit
SlsLogtailConfig:
Type: ALIYUN::SLS::LogtailConfig
DependsOn: Sleep
Properties:
ProjectName:
Ref: SlsProject
LogtailConfigName: app01
LogstoreName:
Fn::Select:
- 0
- Fn::GetAtt:
- LogStores
- Logstores
RawConfigData:
configName: logtail-test
inputDetail:
adjustTimezone: false
advanced:
collect_containers_flag: false
force_multiconfig: false
k8s:
ExternalEnvTag: { }
tail_size_kb: 1024
delayAlarmBytes: 0
delaySkipBytes: 0
discardNonUtf8: false
discardUnmatch: false
dockerExcludeEnv: { }
dockerExcludeLabel: { }
dockerFile: true
dockerIncludeEnv: { }
dockerIncludeLabel: { }
enableRawLog: false
enableTag: false
fileEncoding: utf8
filePattern: '*.Log'
filterKey: [ ]
filterRegex: [ ]
key:
- content
localStorage: true
logBeginRegex: .*
logPath: /apsara/nuwa
logTimezone: ''
logType: common_reg_log
maxDepth: 10
maxSendRate: -1
mergeType: topic
preserve: true
preserveDepth: 1
priority: 0
regex: (.*)
sendRateExpire: 0
sensitive_keys: [ ]
shardHashKey: [ ]
tailExisted: false
timeFormat: ''
topicFormat: none
inputType: file
logSample: ''
outputDetail:
compressType: ''
logstoreName:
Fn::Select:
- 0
- Fn::GetAtt:
- LogStores
- Logstores
outputType: LogService
ApplyConfigToMachineGroup:
Type: ALIYUN::SLS::ApplyConfigToMachineGroup
DependsOn: Sleep
Properties:
ProjectName:
Fn::GetAtt:
- SlsProject
- Name
ConfigName:
Fn::GetAtt:
- SlsLogtailConfig
- LogtailConfigName
GroupName:
Fn::Sub:
- 'k8s-group-${your_k8s_cluster_id}'
- your_k8s_cluster_id:
Fn::GetAtt:
- K8sCluster
- ClusterId
DealLogOssExportStack:
Type: ALIYUN::ROS::Stack
DependsOn:
- Sleep
Properties:
Parameters:
sls_project_name:
Fn::GetAtt:
- SlsProject
- Name
sls_logstore_name:
Fn::Select:
- 0
- Fn::GetAtt:
- LogStores
- Logstores
bucket_name:
Fn::GetAtt:
- OssBucket
- Name
export_name: app01
aliuid:
Ref: ALIYUN::TenantId
role_name:
Fn::Sub: oss-export-${ALIYUN::StackId}
TemplateBody:
ROSTemplateFormatVersion: '2015-09-01'
Transform: 'Aliyun::Terraform-v1.2'
Workspace:
main.tf: |-
variable "sls_project_name" {
type = string
}
variable "sls_logstore_name" {
type = string
}
variable "bucket_name" {
type = string
}
variable "export_name" {
type = string
}
variable "aliuid" {
type = string
}
variable "role_name" {
type = string
}
resource "alicloud_ram_role" "log_export_to_oss_role" {
name = var.role_name
document = <<EOF
{
"Statement": [
{
"Action": "sts:AssumeRole",
"Effect": "Allow",
"Principal": {
"Service": [
"${var.aliuid}@log.aliyuncs.com",
"log.aliyuncs.com"
]
}
}
],
"Version": "1"
}
EOF
}
resource "alicloud_ram_role_policy_attachment" "oss_write_attachment" {
policy_name = "AliyunOSSFullAccess"
policy_type = "System"
role_name = var.role_name
depends_on = [
alicloud_ram_role.log_export_to_oss_role
]
}
resource "alicloud_ram_role_policy_attachment" "log_read_attachment" {
policy_name = "AliyunLogReadOnlyAccess"
policy_type = "System"
role_name = var.role_name
depends_on = [
alicloud_ram_role.log_export_to_oss_role
]
}
resource "alicloud_log_oss_export" "example" {
project_name = var.sls_project_name
logstore_name = var.sls_logstore_name
export_name = var.export_name
display_name = var.export_name
bucket = var.bucket_name
prefix = "app01"
suffix = ""
buffer_interval = 300
buffer_size = 250
compress_type = "gzip"
path_format = "%Y/%m/%d/%H/%M"
content_type = "json"
json_enable_tag = true
role_arn = "acs:ram::${var.aliuid}:role/${var.role_name}"
time_zone = "+0800"
depends_on = [
alicloud_ram_role_policy_attachment.log_read_attachment,
alicloud_ram_role_policy_attachment.oss_write_attachment
]
}
Outputs:
BucketName:
Description:
en: OSS bucket name.
zh-cn: OSS bucket名称。
Value:
Fn::GetAtt:
- OssBucket
- Name
ProjectName:
Description:
en: SLS project name.
zh-cn: 日志project名称。
Value:
Fn::GetAtt:
- SlsProject
- Name
LogstoreName:
Description:
en: SLS logstore name.
zh-cn: 日志logstore名称。
Value:
Fn::Select:
- 0
- Fn::GetAtt:
- LogStores
- Logstores
Metadata:
'ALIYUN::ROS::Interface':
ParameterGroups:
- Parameters:
- ZoneId
- EcsInstanceType
TemplateTags:
- acs:technical-solution:Storage:云原生可观测运维-tech_solu_54