Skip to content

Commit aaf58a2

Browse files
authored
fix(tke): [125888388] nodePool support cdc_id (#3444)
* add * add * add * add
1 parent 3aa681d commit aaf58a2

10 files changed

+222
-4
lines changed

.changelog/3444.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_kubernetes_scale_worker: support `cdc_id`
3+
```
4+
5+
```release-note:enhancement
6+
resource/tencentcloud_kubernetes_node_pool: support `cdc_id`
7+
```

tencentcloud/services/tke/resource_tc_kubernetes_cluster_extension.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,6 +1922,10 @@ func tkeGetCvmRunInstancesPara(dMap map[string]interface{}, meta interface{},
19221922
request.TagSpecification = append(request.TagSpecification, &tmpTagSpec)
19231923
}
19241924

1925+
if v, ok := dMap["cdc_id"]; ok && v.(string) != "" {
1926+
request.DedicatedClusterId = helper.String(v.(string))
1927+
}
1928+
19251929
cvmJson = request.ToJsonString()
19261930

19271931
cvmJson = strings.Replace(cvmJson, `"Password":"",`, "", -1)

tencentcloud/services/tke/resource_tc_kubernetes_node_pool.go

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tencentcloud/services/tke/resource_tc_kubernetes_node_pool.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,64 @@ resource "tencentcloud_kubernetes_node_pool" "example" {
267267
}
268268
```
269269

270+
Create Node pool for CDC cluster
271+
272+
```hcl
273+
resource "tencentcloud_kubernetes_node_pool" "example" {
274+
name = "tf-example"
275+
cluster_id = "cls-nhhpsdx8"
276+
default_cooldown = 400
277+
max_size = 4
278+
min_size = 1
279+
desired_capacity = 2
280+
vpc_id = "vpc-pi5u9uth"
281+
subnet_ids = ["subnet-muu9a0gk"]
282+
retry_policy = "INCREMENTAL_INTERVALS"
283+
enable_auto_scale = true
284+
multi_zone_subnet_policy = "EQUALITY"
285+
node_os = "img-eb30mz89"
286+
delete_keep_instance = true
287+
288+
node_config {
289+
data_disk {
290+
disk_type = "CLOUD_SSD"
291+
disk_size = 50
292+
file_system = "ext4"
293+
mount_target = "/var/lib/data1"
294+
}
295+
}
296+
297+
auto_scaling_config {
298+
instance_type = "S5.MEDIUM4"
299+
instance_charge_type = "CDCPAID"
300+
system_disk_type = "CLOUD_SSD"
301+
system_disk_size = "100"
302+
orderly_security_group_ids = ["sg-4z20n68d"]
303+
304+
data_disk {
305+
disk_type = "CLOUD_SSD"
306+
disk_size = 50
307+
}
308+
309+
internet_charge_type = "TRAFFIC_POSTPAID_BY_HOUR"
310+
internet_max_bandwidth_out = 10
311+
public_ip_assigned = true
312+
password = "Password@123"
313+
enhanced_security_service = false
314+
enhanced_monitor_service = false
315+
host_name = "example"
316+
host_name_style = "ORIGINAL"
317+
instance_name = "example"
318+
instance_name_style = "ORIGINAL"
319+
cdc_id = "cluster-262n63e8"
320+
}
321+
322+
tags = {
323+
createBy = "Terraform"
324+
}
325+
}
326+
```
327+
270328
Import
271329

272330
tke node pool can be imported, e.g.

tencentcloud/services/tke/resource_tc_kubernetes_node_pool_extension.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,10 @@ func resourceTencentCloudKubernetesNodePoolReadPostHandleResponse1(ctx context.C
336336
launchConfig["host_name_style"] = launchCfg.HostNameSettings.HostNameStyle
337337
}
338338

339+
if launchCfg.DedicatedClusterId != nil {
340+
launchConfig["cdc_id"] = launchCfg.DedicatedClusterId
341+
}
342+
339343
asgConfig := make([]interface{}, 0, 1)
340344
asgConfig = append(asgConfig, launchConfig)
341345
if err := d.Set("auto_scaling_config", asgConfig); err != nil {
@@ -1123,6 +1127,11 @@ func composedKubernetesAsScalingConfigParaSerial(dMap map[string]interface{}, me
11231127
}
11241128
}
11251129
}
1130+
1131+
if v, ok := dMap["cdc_id"]; ok && v != "" {
1132+
request.DedicatedClusterId = helper.String(v.(string))
1133+
}
1134+
11261135
result = request.ToJsonString()
11271136
return result, errRet
11281137
}

tencentcloud/services/tke/resource_tc_kubernetes_scale_worker.go

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tencentcloud/services/tke/resource_tc_kubernetes_scale_worker.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,38 @@ resource "tencentcloud_kubernetes_scale_worker" "example" {
112112
}
113113
```
114114

115+
Create scale worker for CDC cluster
116+
117+
```hcl
118+
resource "tencentcloud_kubernetes_scale_worker" "example" {
119+
cluster_id = "cls-0o0dpx1a"
120+
121+
worker_config {
122+
count = 2
123+
instance_charge_type = "CDCPAID"
124+
instance_name = "tke_worker_demo"
125+
availability_zone = "ap-guangzhou-4"
126+
instance_type = "S5.MEDIUM2"
127+
subnet_id = "subnet-muu9a0gk"
128+
system_disk_type = "CLOUD_SSD"
129+
system_disk_size = 50
130+
internet_charge_type = "TRAFFIC_POSTPAID_BY_HOUR"
131+
security_group_ids = ["sg-4z20n68d"]
132+
133+
data_disk {
134+
disk_type = "CLOUD_SSD"
135+
disk_size = 50
136+
}
137+
138+
enhanced_security_service = false
139+
enhanced_monitor_service = false
140+
user_data = "dGVzdA=="
141+
password = "Password@123"
142+
cdc_id = "cluster-262n63e8"
143+
}
144+
}
145+
```
146+
115147
Import
116148

117149
tke scale worker can be imported, e.g.

tencentcloud/services/tke/resource_tc_kubernetes_scale_worker_extension.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ func resourceTencentCloudKubernetesScaleWorkerReadPostRequest1(ctx context.Conte
113113
mapping["tags"] = tmpList
114114
}
115115

116+
if instance.DedicatedClusterId != nil {
117+
mapping["cdc_id"] = instance.DedicatedClusterId
118+
}
119+
116120
instanceList = append(instanceList, mapping)
117121
}
118122
if importFlag1 {

website/docs/r/kubernetes_node_pool.html.markdown

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,64 @@ resource "tencentcloud_kubernetes_node_pool" "example" {
278278
}
279279
```
280280

281+
### Create Node pool for CDC cluster
282+
283+
```hcl
284+
resource "tencentcloud_kubernetes_node_pool" "example" {
285+
name = "tf-example"
286+
cluster_id = "cls-nhhpsdx8"
287+
default_cooldown = 400
288+
max_size = 4
289+
min_size = 1
290+
desired_capacity = 2
291+
vpc_id = "vpc-pi5u9uth"
292+
subnet_ids = ["subnet-muu9a0gk"]
293+
retry_policy = "INCREMENTAL_INTERVALS"
294+
enable_auto_scale = true
295+
multi_zone_subnet_policy = "EQUALITY"
296+
node_os = "img-eb30mz89"
297+
delete_keep_instance = true
298+
299+
node_config {
300+
data_disk {
301+
disk_type = "CLOUD_SSD"
302+
disk_size = 50
303+
file_system = "ext4"
304+
mount_target = "/var/lib/data1"
305+
}
306+
}
307+
308+
auto_scaling_config {
309+
instance_type = "S5.MEDIUM4"
310+
instance_charge_type = "CDCPAID"
311+
system_disk_type = "CLOUD_SSD"
312+
system_disk_size = "100"
313+
orderly_security_group_ids = ["sg-4z20n68d"]
314+
315+
data_disk {
316+
disk_type = "CLOUD_SSD"
317+
disk_size = 50
318+
}
319+
320+
internet_charge_type = "TRAFFIC_POSTPAID_BY_HOUR"
321+
internet_max_bandwidth_out = 10
322+
public_ip_assigned = true
323+
password = "Password@123"
324+
enhanced_security_service = false
325+
enhanced_monitor_service = false
326+
host_name = "example"
327+
host_name_style = "ORIGINAL"
328+
instance_name = "example"
329+
instance_name_style = "ORIGINAL"
330+
cdc_id = "cluster-262n63e8"
331+
}
332+
333+
tags = {
334+
createBy = "Terraform"
335+
}
336+
}
337+
```
338+
281339
## Argument Reference
282340

283341
The following arguments are supported:
@@ -324,14 +382,15 @@ The `auto_scaling_config` object supports the following:
324382
* `backup_instance_types` - (Optional, List) Backup CVM instance types if specified instance type sold out or mismatch.
325383
* `bandwidth_package_id` - (Optional, String) bandwidth package id. if user is standard user, then the bandwidth_package_id is needed, or default has bandwidth_package_id.
326384
* `cam_role_name` - (Optional, String, ForceNew) Name of cam role.
385+
* `cdc_id` - (Optional, String, ForceNew) CDC ID.
327386
* `data_disk` - (Optional, List) Configurations of data disk.
328387
* `enhanced_monitor_service` - (Optional, Bool, ForceNew) To specify whether to enable cloud monitor service. Default is TRUE.
329388
* `enhanced_security_service` - (Optional, Bool) To specify whether to enable cloud security service. Default is TRUE.
330389
* `host_name_style` - (Optional, String) The style of the host name of the cloud server, the value range includes ORIGINAL and UNIQUE, and the default is ORIGINAL. For usage, refer to `HostNameSettings` in https://www.tencentcloud.com/document/product/377/31001.
331390
* `host_name` - (Optional, String) The hostname of the cloud server, dot (.) and dash (-) cannot be used as the first and last characters of HostName and cannot be used consecutively. Windows instances are not supported. Examples of other types (Linux, etc.): The character length is [2, 40], multiple periods are allowed, and there is a paragraph between the dots, and each paragraph is allowed to consist of letters (unlimited case), numbers and dashes (-). Pure numbers are not allowed. For usage, refer to `HostNameSettings` in https://www.tencentcloud.com/document/product/377/31001.
332391
* `instance_charge_type_prepaid_period` - (Optional, Int) The tenancy (in month) of the prepaid instance, NOTE: it only works when instance_charge_type is set to `PREPAID`. Valid values are `1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`, `9`, `10`, `11`, `12`, `24`, `36`.
333392
* `instance_charge_type_prepaid_renew_flag` - (Optional, String) Auto renewal flag. Valid values: `NOTIFY_AND_AUTO_RENEW`: notify upon expiration and renew automatically, `NOTIFY_AND_MANUAL_RENEW`: notify upon expiration but do not renew automatically, `DISABLE_NOTIFY_AND_MANUAL_RENEW`: neither notify upon expiration nor renew automatically. Default value: `NOTIFY_AND_MANUAL_RENEW`. If this parameter is specified as `NOTIFY_AND_AUTO_RENEW`, the instance will be automatically renewed on a monthly basis if the account balance is sufficient. NOTE: it only works when instance_charge_type is set to `PREPAID`.
334-
* `instance_charge_type` - (Optional, String) Charge type of instance. Valid values are `PREPAID`, `POSTPAID_BY_HOUR`, `SPOTPAID`. The default is `POSTPAID_BY_HOUR`. NOTE: `SPOTPAID` instance must set `spot_instance_type` and `spot_max_price` at the same time.
393+
* `instance_charge_type` - (Optional, String) Charge type of instance. Valid values are `PREPAID`, `POSTPAID_BY_HOUR`, `SPOTPAID`, `CDCPAID`. The default is `POSTPAID_BY_HOUR`. NOTE: `SPOTPAID` instance must set `spot_instance_type` and `spot_max_price` at the same time.
335394
* `instance_name_style` - (Optional, String) Type of CVM instance name. Valid values: `ORIGINAL` and `UNIQUE`. Default value: `ORIGINAL`. For usage, refer to `InstanceNameSettings` in https://www.tencentcloud.com/document/product/377/31001.
336395
* `instance_name` - (Optional, String) Instance name, no more than 60 characters. For usage, refer to `InstanceNameSettings` in https://www.tencentcloud.com/document/product/377/31001.
337396
* `internet_charge_type` - (Optional, String) Charge types for network traffic. Valid value: `BANDWIDTH_PREPAID`, `TRAFFIC_POSTPAID_BY_HOUR` and `BANDWIDTH_PACKAGE`.

website/docs/r/kubernetes_scale_worker.html.markdown

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,38 @@ resource "tencentcloud_kubernetes_scale_worker" "example" {
123123
}
124124
```
125125

126+
### Create scale worker for CDC cluster
127+
128+
```hcl
129+
resource "tencentcloud_kubernetes_scale_worker" "example" {
130+
cluster_id = "cls-0o0dpx1a"
131+
132+
worker_config {
133+
count = 2
134+
instance_charge_type = "CDCPAID"
135+
instance_name = "tke_worker_demo"
136+
availability_zone = "ap-guangzhou-4"
137+
instance_type = "S5.MEDIUM2"
138+
subnet_id = "subnet-muu9a0gk"
139+
system_disk_type = "CLOUD_SSD"
140+
system_disk_size = 50
141+
internet_charge_type = "TRAFFIC_POSTPAID_BY_HOUR"
142+
security_group_ids = ["sg-4z20n68d"]
143+
144+
data_disk {
145+
disk_type = "CLOUD_SSD"
146+
disk_size = 50
147+
}
148+
149+
enhanced_security_service = false
150+
enhanced_monitor_service = false
151+
user_data = "dGVzdA=="
152+
password = "Password@123"
153+
cdc_id = "cluster-262n63e8"
154+
}
155+
}
156+
```
157+
126158
## Argument Reference
127159

128160
The following arguments are supported:
@@ -189,6 +221,7 @@ The `worker_config` object supports the following:
189221
* `availability_zone` - (Optional, String, ForceNew) Indicates which availability zone will be used.
190222
* `bandwidth_package_id` - (Optional, String) bandwidth package id. if user is standard user, then the bandwidth_package_id is needed, or default has bandwidth_package_id.
191223
* `cam_role_name` - (Optional, String, ForceNew) CAM role name authorized to access.
224+
* `cdc_id` - (Optional, String, ForceNew) CDC ID.
192225
* `count` - (Optional, Int, ForceNew) Number of cvm.
193226
* `data_disk` - (Optional, List, ForceNew) Configurations of cvm data disk.
194227
* `desired_pod_num` - (Optional, Int, ForceNew) Indicate to set desired pod number in node. valid when enable_customized_pod_cidr=true, and it override `[globe_]desired_pod_num` for current node. Either all the fields `desired_pod_num` or none.
@@ -200,7 +233,7 @@ The `worker_config` object supports the following:
200233
* `img_id` - (Optional, String) The valid image id, format of img-xxx.
201234
* `instance_charge_type_prepaid_period` - (Optional, Int, ForceNew) The tenancy (time unit is month) of the prepaid instance. NOTE: it only works when instance_charge_type is set to `PREPAID`. Valid values are `1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`, `9`, `10`, `11`, `12`, `24`, `36`.
202235
* `instance_charge_type_prepaid_renew_flag` - (Optional, String, ForceNew) Auto renewal flag. Valid values: `NOTIFY_AND_AUTO_RENEW`: notify upon expiration and renew automatically, `NOTIFY_AND_MANUAL_RENEW`: notify upon expiration but do not renew automatically, `DISABLE_NOTIFY_AND_MANUAL_RENEW`: neither notify upon expiration nor renew automatically. Default value: `NOTIFY_AND_MANUAL_RENEW`. If this parameter is specified as `NOTIFY_AND_AUTO_RENEW`, the instance will be automatically renewed on a monthly basis if the account balance is sufficient. NOTE: it only works when instance_charge_type is set to `PREPAID`.
203-
* `instance_charge_type` - (Optional, String, ForceNew) The charge type of instance. Valid values are `PREPAID` and `POSTPAID_BY_HOUR`. The default is `POSTPAID_BY_HOUR`. Note: TencentCloud International only supports `POSTPAID_BY_HOUR`, `PREPAID` instance will not terminated after cluster deleted, and may not allow to delete before expired.
236+
* `instance_charge_type` - (Optional, String, ForceNew) The charge type of instance. Valid values are `PREPAID`, `POSTPAID_BY_HOUR`, `SPOTPAID`, `CDCPAID`. The default is `POSTPAID_BY_HOUR`. Note: TencentCloud International only supports `POSTPAID_BY_HOUR`, `PREPAID` instance will not terminated after cluster deleted, and may not allow to delete before expired.
204237
* `instance_name` - (Optional, String, ForceNew) Name of the CVMs.
205238
* `internet_charge_type` - (Optional, String, ForceNew) Charge types for network traffic. Available values include `TRAFFIC_POSTPAID_BY_HOUR`.
206239
* `internet_max_bandwidth_out` - (Optional, Int) Max bandwidth of Internet access in Mbps. Default is 0.

0 commit comments

Comments
 (0)