Skip to content

Commit b099052

Browse files
authored
Merge pull request #656 from tencentcloudstack/fix/k8s-cluster-disk-settings
Fix/k8s cluster disk settings
2 parents c9d5d42 + c74d5a1 commit b099052

10 files changed

+162
-11
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,29 @@
1+
## 1.58.3 (Aug 18, 2021)
2+
3+
ENHANCEMENTS:
4+
5+
* Extend kubernetes node instance disk allow types
6+
* Resource `resource_tc_kubernetes_cluster_attachment.go` add `disk_partition` field
7+
8+
BUGFIXES:
9+
10+
* Resource `resource_tc_kubernetes_cluster` fix `auto_format_and_mount` default value to `false`
11+
112
## 1.58.2 (Aug 18, 2021)
13+
214
ENHANCEMENTS:
15+
316
* Resource `resource_tc_kubernetes_cluster.go` tke instance creation - add RuntimeVersion param
417
* Resource `resource_tc_kubernetes_cluster.go` extend worker instance data disk mount settings
518

619
## 1.58.1 (Aug 17, 2021)
720

821
ENHANCEMENTS:
22+
923
* Resource `resource_tc_mysql_instance.go` add cpu params for mysql
1024

1125
BUG_FIXES:
26+
1227
* Resource `resource_tc_instance.go` fix read cvm data_disks bug
1328

1429
## 1.58.0 (Aug 11, 2021)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export HTTPS_PROXY=$http_proxy
4747

4848
You can edit your own terraform configuration files. Learn examples from examples directory.
4949

50-
### Terrafrom it
50+
### Terraform it
5151

5252
Now you can try your terraform demo:
5353

tencentcloud/extension_as.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ const (
1111
)
1212

1313
var SYSTEM_DISK_ALLOW_TYPE = []string{
14+
SYSTEM_DISK_TYPE_LOCAL_BASIC,
15+
SYSTEM_DISK_TYPE_LOCAL_SSD,
16+
SYSTEM_DISK_TYPE_CLOUD_BASIC,
1417
SYSTEM_DISK_TYPE_CLOUD_PREMIUM,
1518
SYSTEM_DISK_TYPE_CLOUD_SSD,
1619
SYSTEM_DISK_TYPE_CLOUD_HSSD,

tencentcloud/resource_tc_kubernetes_cluster.go

Lines changed: 69 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ resource "tencentcloud_kubernetes_cluster" "managed_cluster" {
4343
cluster_internet = true
4444
managed_cluster_internet_security_policies = ["3.3.3.3", "1.1.1.1"]
4545
cluster_deploy_type = "MANAGED_CLUSTER"
46-
data_disk {
47-
disk_type = "CLOUD_PREMIUM"
48-
disk_size = 50
49-
}
5046
5147
worker_config {
5248
count = 1
@@ -267,6 +263,62 @@ resource "tencentcloud_kubernetes_cluster" "test_node_pool_global_config" {
267263
}
268264
}
269265
```
266+
267+
Using VPC-CNI network type
268+
```hcl
269+
variable "availability_zone" {
270+
default = "ap-guangzhou-1"
271+
}
272+
273+
variable "vpc" {
274+
default = "vpc-r1m1fyx5"
275+
}
276+
277+
variable "default_instance_type" {
278+
default = "SA2.SMALL2"
279+
}
280+
281+
resource "tencentcloud_kubernetes_cluster" "managed_cluster" {
282+
vpc_id = var.vpc
283+
cluster_max_pod_num = 32
284+
cluster_name = "test"
285+
cluster_desc = "test cluster desc"
286+
cluster_max_service_num = 256
287+
cluster_internet = true
288+
managed_cluster_internet_security_policies = ["3.3.3.3", "1.1.1.1"]
289+
cluster_deploy_type = "MANAGED_CLUSTER"
290+
network_type = "VPC-CNI"
291+
eni_subnet_ids = ["subnet-bk1etlyu"]
292+
service_cidr = "10.1.0.0/24"
293+
294+
worker_config {
295+
count = 1
296+
availability_zone = var.availability_zone
297+
instance_type = var.default_instance_type
298+
system_disk_type = "CLOUD_PREMIUM"
299+
system_disk_size = 60
300+
internet_charge_type = "TRAFFIC_POSTPAID_BY_HOUR"
301+
internet_max_bandwidth_out = 100
302+
public_ip_assigned = true
303+
subnet_id = "subnet-t5dv27rs"
304+
305+
data_disk {
306+
disk_type = "CLOUD_PREMIUM"
307+
disk_size = 50
308+
}
309+
310+
enhanced_security_service = false
311+
enhanced_monitor_service = false
312+
user_data = "dGVzdA=="
313+
password = "ZZXXccvv1212"
314+
}
315+
316+
labels = {
317+
"test1" = "test1",
318+
"test2" = "test2",
319+
}
320+
}
321+
```
270322
*/
271323
package tencentcloud
272324

@@ -474,7 +526,7 @@ func TkeCvmCreateInfo() map[string]*schema.Schema {
474526
Type: schema.TypeBool,
475527
ForceNew: true,
476528
Optional: true,
477-
Default: true,
529+
Default: false,
478530
Description: "Indicate whether to auto format and mount or not. Default is `false`.",
479531
},
480532
"mount_target": {
@@ -483,6 +535,12 @@ func TkeCvmCreateInfo() map[string]*schema.Schema {
483535
Optional: true,
484536
Description: "Mount target.",
485537
},
538+
"disk_partition": {
539+
Type: schema.TypeString,
540+
ForceNew: true,
541+
Optional: true,
542+
Description: "The name of the device or partition to mount.",
543+
},
486544
},
487545
},
488546
},
@@ -1739,6 +1797,7 @@ func resourceTencentCloudTkeClusterCreate(d *schema.ResourceData, meta interface
17391797
fileSystem = disk["file_system"].(string)
17401798
autoFormatAndMount = disk["auto_format_and_mount"].(bool)
17411799
mountTarget = disk["mount_target"].(string)
1800+
diskPartition = disk["disk_partition"].(string)
17421801
)
17431802

17441803
dataDisk := &tke.DataDisk{
@@ -1750,10 +1809,15 @@ func resourceTencentCloudTkeClusterCreate(d *schema.ResourceData, meta interface
17501809
if fileSystem != "" {
17511810
dataDisk.FileSystem = &fileSystem
17521811
}
1812+
17531813
if mountTarget != "" {
17541814
dataDisk.MountTarget = &mountTarget
17551815
}
17561816

1817+
if diskPartition != "" {
1818+
dataDisk.DiskPartition = &diskPartition
1819+
}
1820+
17571821
iDiskMountSetting.DataDisks = append(iDiskMountSetting.DataDisks, dataDisk)
17581822
}
17591823

tencentcloud/resource_tc_kubernetes_cluster_attachment.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,12 @@ func TkeInstanceAdvancedSetting() map[string]*schema.Schema {
171171
Default: "",
172172
Description: "Mount target.",
173173
},
174+
"disk_partition": {
175+
Type: schema.TypeString,
176+
ForceNew: true,
177+
Optional: true,
178+
Description: "The name of the device or partition to mount.",
179+
},
174180
},
175181
},
176182
},
@@ -316,12 +322,14 @@ func tkeGetInstanceAdvancedPara(dMap map[string]interface{}, meta interface{}) (
316322
fileSystem = value["file_system"].(string)
317323
autoFormatAndMount = value["auto_format_and_mount"].(bool)
318324
mountTarget = value["mount_target"].(string)
325+
diskPartition = value["disk_partition"].(string)
319326
dataDisk = tke.DataDisk{
320327
DiskType: &diskType,
321328
DiskSize: &diskSize,
322329
FileSystem: &fileSystem,
323330
AutoFormatAndMount: &autoFormatAndMount,
324331
MountTarget: &mountTarget,
332+
DiskPartition: &diskPartition,
325333
}
326334
)
327335
setting.DataDisks = append(setting.DataDisks, &dataDisk)

tencentcloud/resource_tc_kubernetes_cluster_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,10 @@ resource "tencentcloud_kubernetes_cluster" "managed_cluster" {
178178
data_disk {
179179
disk_type = "CLOUD_PREMIUM"
180180
disk_size = 50
181+
file_system = "ext3"
182+
auto_format_and_mount = "true"
183+
mount_target = "/var/lib/docker"
184+
disk_partition = "/dev/sdb1"
181185
}
182186
183187
enhanced_security_service = false

website/docs/r/kubernetes_cluster.html.markdown

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ resource "tencentcloud_kubernetes_cluster" "managed_cluster" {
5353
cluster_internet = true
5454
managed_cluster_internet_security_policies = ["3.3.3.3", "1.1.1.1"]
5555
cluster_deploy_type = "MANAGED_CLUSTER"
56-
data_disk {
57-
disk_type = "CLOUD_PREMIUM"
58-
disk_size = 50
59-
}
6056
6157
worker_config {
6258
count = 1
@@ -278,6 +274,63 @@ resource "tencentcloud_kubernetes_cluster" "test_node_pool_global_config" {
278274
}
279275
```
280276

277+
Using VPC-CNI network type
278+
279+
```hcl
280+
variable "availability_zone" {
281+
default = "ap-guangzhou-1"
282+
}
283+
284+
variable "vpc" {
285+
default = "vpc-r1m1fyx5"
286+
}
287+
288+
variable "default_instance_type" {
289+
default = "SA2.SMALL2"
290+
}
291+
292+
resource "tencentcloud_kubernetes_cluster" "managed_cluster" {
293+
vpc_id = var.vpc
294+
cluster_max_pod_num = 32
295+
cluster_name = "test"
296+
cluster_desc = "test cluster desc"
297+
cluster_max_service_num = 256
298+
cluster_internet = true
299+
managed_cluster_internet_security_policies = ["3.3.3.3", "1.1.1.1"]
300+
cluster_deploy_type = "MANAGED_CLUSTER"
301+
network_type = "VPC-CNI"
302+
eni_subnet_ids = ["subnet-bk1etlyu"]
303+
service_cidr = "10.1.0.0/24"
304+
305+
worker_config {
306+
count = 1
307+
availability_zone = var.availability_zone
308+
instance_type = var.default_instance_type
309+
system_disk_type = "CLOUD_PREMIUM"
310+
system_disk_size = 60
311+
internet_charge_type = "TRAFFIC_POSTPAID_BY_HOUR"
312+
internet_max_bandwidth_out = 100
313+
public_ip_assigned = true
314+
subnet_id = "subnet-t5dv27rs"
315+
316+
data_disk {
317+
disk_type = "CLOUD_PREMIUM"
318+
disk_size = 50
319+
}
320+
321+
enhanced_security_service = false
322+
enhanced_monitor_service = false
323+
user_data = "dGVzdA=="
324+
password = "ZZXXccvv1212"
325+
}
326+
327+
labels = {
328+
"test1" = "test1",
329+
"test2" = "test2",
330+
}
331+
}
332+
```
333+
281334
## Argument Reference
282335

283336
The following arguments are supported:
@@ -335,6 +388,7 @@ The `cluster_extra_args` object supports the following:
335388
The `data_disk` object supports the following:
336389

337390
* `auto_format_and_mount` - (Optional, ForceNew) Indicate whether to auto format and mount or not. Default is `false`.
391+
* `disk_partition` - (Optional, ForceNew) The name of the device or partition to mount.
338392
* `disk_size` - (Optional, ForceNew) Volume of disk in GB. Default is `0`.
339393
* `disk_type` - (Optional, ForceNew) Types of disk, available values: `CLOUD_PREMIUM` and `CLOUD_SSD` and `CLOUD_HSSD` and `CLOUD_TSSD`.
340394
* `file_system` - (Optional, ForceNew) File system, e.g. `ext3/ext4/xfs`.

website/docs/r/kubernetes_cluster_attachment.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ The following arguments are supported:
121121
The `data_disk` object supports the following:
122122

123123
* `auto_format_and_mount` - (Optional, ForceNew) Indicate whether to auto format and mount or not. Default is `false`.
124+
* `disk_partition` - (Optional, ForceNew) The name of the device or partition to mount.
124125
* `disk_size` - (Optional, ForceNew) Volume of disk in GB. Default is `0`.
125126
* `disk_type` - (Optional, ForceNew) Types of disk, available values: `CLOUD_PREMIUM` and `CLOUD_SSD`.
126127
* `file_system` - (Optional, ForceNew) File system, e.g. `ext3/ext4/xfs`.

website/docs/r/kubernetes_node_pool.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ The `auto_scaling_config` object supports the following:
144144
The `data_disk` object supports the following:
145145

146146
* `auto_format_and_mount` - (Optional, ForceNew) Indicate whether to auto format and mount or not. Default is `false`.
147+
* `disk_partition` - (Optional, ForceNew) The name of the device or partition to mount.
147148
* `disk_size` - (Optional, ForceNew) Volume of disk in GB. Default is `0`.
148149
* `disk_type` - (Optional, ForceNew) Types of disk, available values: `CLOUD_PREMIUM` and `CLOUD_SSD`.
149150
* `file_system` - (Optional, ForceNew) File system, e.g. `ext3/ext4/xfs`.

website/docs/r/kubernetes_scale_worker.html.markdown

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,12 @@ The following arguments are supported:
127127
The `data_disk` object supports the following:
128128

129129
* `auto_format_and_mount` - (Optional, ForceNew) Indicate whether to auto format and mount or not. Default is `false`.
130+
* `disk_partition` - (Optional, ForceNew) The name of the device or partition to mount.
130131
* `disk_size` - (Optional, ForceNew) Volume of disk in GB. Default is `0`.
131132
* `disk_type` - (Optional, ForceNew) Types of disk, available values: `CLOUD_PREMIUM` and `CLOUD_SSD` and `CLOUD_HSSD` and `CLOUD_TSSD`.
132133
* `file_system` - (Optional, ForceNew) File system, e.g. `ext3/ext4/xfs`.
133134
* `mount_target` - (Optional, ForceNew) Mount target.
135+
* `snapshot_id` - (Optional, ForceNew) Data disk snapshot ID.
134136

135137
The `data_disk` object supports the following:
136138

@@ -139,7 +141,6 @@ The `data_disk` object supports the following:
139141
* `disk_type` - (Optional, ForceNew) Types of disk, available values: `CLOUD_PREMIUM` and `CLOUD_SSD` and `CLOUD_HSSD` and `CLOUD_TSSD`.
140142
* `file_system` - (Optional, ForceNew) File system, e.g. `ext3/ext4/xfs`.
141143
* `mount_target` - (Optional, ForceNew) Mount target.
142-
* `snapshot_id` - (Optional, ForceNew) Data disk snapshot ID.
143144

144145
The `worker_config` object supports the following:
145146

0 commit comments

Comments
 (0)