Skip to content

Commit e6ee299

Browse files
committed
add e2e test and doc
1 parent cb7d011 commit e6ee299

File tree

3 files changed

+425
-20
lines changed

3 files changed

+425
-20
lines changed

tencentcloud/services/tke/resource_tc_kubernetes_log_config.go

Lines changed: 13 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tencentcloud/services/tke/resource_tc_kubernetes_log_config.md

Lines changed: 193 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,203 @@ Provides a resource to create a tke kubernetes_log_config
22

33
Example Usage
44

5+
Create a cls log config
6+
57
```hcl
6-
resource "tencentcloud_kubernetes_log_config" "kubernetes_log_config" {
8+
locals {
9+
first_vpc_id = data.tencentcloud_vpc_subnets.vpc_one.instance_list.0.vpc_id
10+
first_subnet_id = data.tencentcloud_vpc_subnets.vpc_one.instance_list.0.subnet_id
11+
zone_id = data.tencentcloud_availability_zones_by_product.gz.zones.0.id
12+
}
13+
14+
variable "example_cluster_cidr" {
15+
default = "10.31.0.0/16"
16+
}
17+
18+
data "tencentcloud_vpc_subnets" "vpc_one" {
19+
is_default = true
20+
availability_zone = "ap-guangzhou-3"
721
}
8-
```
922
10-
Import
23+
data "tencentcloud_availability_zones_by_product" "gz" {
24+
name = "ap-guangzhou-3"
25+
product = "ckafka"
26+
}
27+
28+
resource "tencentcloud_kubernetes_cluster" "example" {
29+
vpc_id = local.first_vpc_id
30+
cluster_cidr = var.example_cluster_cidr
31+
cluster_max_pod_num = 32
32+
cluster_name = "tf_example_cluster"
33+
cluster_desc = "example for tke cluster"
34+
cluster_max_service_num = 32
35+
cluster_internet = false # (can be ignored) open it after the nodes added
36+
cluster_version = "1.22.5"
37+
cluster_os = "tlinux2.2(tkernel3)x86_64"
38+
cluster_deploy_type = "MANAGED_CLUSTER"
39+
# without any worker config
40+
}
1141
12-
tke kubernetes_log_config can be imported using the id, e.g.
42+
resource "tencentcloud_cls_logset" "logset" {
43+
logset_name = "example"
44+
tags = {
45+
"createdBy" = "terraform"
46+
}
47+
}
1348
49+
resource "tencentcloud_kubernetes_log_config" "kubernetes_log_config_cls" {
50+
log_config_name = "tf-test-cls"
51+
cluster_id = tencentcloud_kubernetes_cluster.example.id
52+
logset_id = tencentcloud_cls_logset.logset.id
53+
log_config = jsonencode(
54+
{
55+
"apiVersion" : "cls.cloud.tencent.com/v1",
56+
"kind" : "LogConfig",
57+
"metadata" : {
58+
"name" : "tf-test-cls"
59+
},
60+
"spec" : {
61+
"clsDetail" : {
62+
"extractRule" : {
63+
"backtracking" : "0",
64+
"isGBK" : "false",
65+
"jsonStandard" : "false",
66+
"unMatchUpload" : "false"
67+
},
68+
"indexs" : [
69+
{
70+
"indexName" : "namespace"
71+
},
72+
{
73+
"indexName" : "pod_name"
74+
},
75+
{
76+
"indexName" : "container_name"
77+
}
78+
],
79+
"logFormat" : "default",
80+
"logType" : "minimalist_log",
81+
"maxSplitPartitions" : 0,
82+
"region" : "ap-guangzhou",
83+
"storageType" : "",
84+
# "topicId" : "c26b66bd-617e-4923-bea0-test"
85+
},
86+
"inputDetail" : {
87+
"containerStdout" : {
88+
"metadataContainer" : [
89+
"namespace",
90+
"pod_name",
91+
"pod_ip",
92+
"pod_uid",
93+
"container_id",
94+
"container_name",
95+
"image_name",
96+
"cluster_id"
97+
],
98+
"nsLabelSelector" : "",
99+
"workloads" : [
100+
{
101+
"kind" : "deployment",
102+
"name" : "testlog1",
103+
"namespace" : "default"
104+
}
105+
]
106+
},
107+
"type" : "container_stdout"
108+
}
109+
}
110+
}
111+
)
112+
}
14113
```
15-
terraform import tencentcloud_kubernetes_log_config.kubernetes_log_config kubernetes_log_config_id
114+
115+
Create a ckafka log config
116+
117+
```hcl
118+
locals {
119+
ckafka_topic = tencentcloud_ckafka_topic.example.topic_name
120+
kafka_ip = tencentcloud_ckafka_instance.example.vip
121+
kafka_port = tencentcloud_ckafka_instance.example.vport
122+
}
123+
124+
resource "tencentcloud_ckafka_instance" "example" {
125+
instance_name = "ckafka-instance-postpaid"
126+
zone_id = local.zone_id
127+
vpc_id = local.first_vpc_id
128+
subnet_id = local.first_subnet_id
129+
msg_retention_time = 1300
130+
kafka_version = "1.1.1"
131+
disk_size = 500
132+
band_width = 20
133+
disk_type = "CLOUD_BASIC"
134+
partition = 400
135+
charge_type = "POSTPAID_BY_HOUR"
136+
137+
config {
138+
auto_create_topic_enable = true
139+
default_num_partitions = 3
140+
default_replication_factor = 3
141+
}
142+
143+
dynamic_retention_config {
144+
enable = 1
145+
}
146+
}
147+
148+
resource "tencentcloud_ckafka_topic" "example" {
149+
instance_id = tencentcloud_ckafka_instance.example.id
150+
topic_name = "tmp"
151+
note = "topic note"
152+
replica_num = 2
153+
partition_num = 1
154+
clean_up_policy = "delete"
155+
sync_replica_min_num = 1
156+
unclean_leader_election_enable = false
157+
retention = 60000
158+
}
159+
160+
resource "tencentcloud_kubernetes_log_config" "kubernetes_log_config_ckafka" {
161+
log_config_name = "tf-test-ckafka"
162+
cluster_id = tencentcloud_kubernetes_cluster.example.id
163+
logset_id = tencentcloud_cls_logset.logset.id
164+
log_config = jsonencode(
165+
{
166+
"apiVersion" : "cls.cloud.tencent.com/v1",
167+
"kind" : "LogConfig",
168+
"metadata" : {
169+
"name" : "tf-test-ckafka"
170+
},
171+
"spec" : {
172+
"inputDetail" : {
173+
"containerStdout" : {
174+
"allContainers" : true,
175+
"namespace" : "default",
176+
"nsLabelSelector" : ""
177+
},
178+
"type" : "container_stdout"
179+
},
180+
"kafkaDetail" : {
181+
"brokers" : "${local.kafka_ip}:${local.kafka_port}",
182+
"extractRule" : {},
183+
"instanceId" : "",
184+
"kafkaType" : "SelfBuildKafka",
185+
"logType" : "minimalist_log",
186+
"messageKey" : {
187+
"value" : "",
188+
"valueFrom" : {
189+
"fieldRef" : {
190+
"fieldPath" : ""
191+
}
192+
}
193+
},
194+
"metadata" : {},
195+
"timestampFormat" : "double",
196+
"timestampKey" : "",
197+
"topic" : local.ckafka_topic
198+
}
199+
}
200+
}
201+
)
202+
}
16203
```
204+

0 commit comments

Comments
 (0)