Skip to content

Commit c779ace

Browse files
author
“guojunchu”
committed
add tke unschedulable
1 parent 16e4499 commit c779ace

12 files changed

+57
-6
lines changed

tencentcloud/resource_tc_kubernetes_cluster.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,12 @@ func resourceTencentCloudTkeCluster() *schema.Resource {
830830
ForceNew: true,
831831
Description: "Labels of tke cluster nodes.",
832832
},
833+
"unschedulable": {
834+
Type: schema.TypeInt,
835+
Optional: true,
836+
ForceNew: true,
837+
Description: "Sets whether the joining node participates in the schedule.",
838+
},
833839
"mount_target": {
834840
Type: schema.TypeString,
835841
Optional: true,
@@ -1291,6 +1297,9 @@ func resourceTencentCloudTkeClusterCreate(d *schema.ResourceData, meta interface
12911297
}
12921298
}
12931299

1300+
if temp, ok := d.GetOk("unschedulable"); ok {
1301+
iAdvanced.Unschedulable = temp.(int64)
1302+
}
12941303
if temp, ok := d.GetOk("docker_graph_path"); ok {
12951304
iAdvanced.DockerGraphPath = temp.(string)
12961305
}

tencentcloud/resource_tc_kubernetes_cluster_attachment.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,12 @@ func resourceTencentCloudTkeClusterAttachment() *schema.Resource {
248248
ForceNew: true,
249249
Description: "Labels of tke attachment exits CVM.",
250250
},
251+
"unschedulable": {
252+
Type: schema.TypeInt,
253+
Optional: true,
254+
ForceNew: true,
255+
Description: "Sets whether the joining node participates in the schedule.",
256+
},
251257
//compute
252258
"security_groups": {
253259
Type: schema.TypeSet,
@@ -399,6 +405,7 @@ func resourceTencentCloudTkeClusterAttachmentRead(d *schema.ResourceData, meta i
399405
return resource.RetryableError(fmt.Errorf("cvm instance %s in tke status is %s, retry...",
400406
worker.InstanceId, worker.InstanceState))
401407
}
408+
_ = d.Set("unschedulable", worker.InstanceAdvancedSettings.Unschedulable)
402409
}
403410
}
404411

@@ -471,6 +478,10 @@ func resourceTencentCloudTkeClusterAttachmentCreate(d *schema.ResourceData, meta
471478
request.HostName = &hostNameStr
472479
}
473480

481+
if v, ok := d.GetOk("unschedulable"); ok {
482+
request.InstanceAdvancedSettings.Unschedulable = helper.Int64(v.(int64))
483+
}
484+
474485
/*cvm has been attached*/
475486
var err error
476487
_, workers, err := tkeService.DescribeClusterInstances(ctx, *request.ClusterId)

tencentcloud/resource_tc_kubernetes_cluster_attachment_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ func TestAccTencentCloudTkeAttachResource(t *testing.T) {
2222
testAccCheckTkeAttachExists("tencentcloud_kubernetes_cluster_attachment.test_attach"),
2323
resource.TestCheckResourceAttrSet("tencentcloud_kubernetes_cluster_attachment.test_attach", "cluster_id"),
2424
resource.TestCheckResourceAttrSet("tencentcloud_kubernetes_cluster_attachment.test_attach", "instance_id"),
25+
resource.TestCheckResourceAttrSet("tencentcloud_kubernetes_cluster_attachment.test_attach", "unschedulable"),
2526
resource.TestCheckResourceAttr("tencentcloud_kubernetes_cluster_attachment.test_attach", "labels.test1", "test1"),
2627
resource.TestCheckResourceAttr("tencentcloud_kubernetes_cluster_attachment.test_attach", "labels.test2", "test2"),
2728
),
@@ -209,15 +210,13 @@ resource "tencentcloud_kubernetes_cluster_attachment" "test_attach" {
209210
cluster_id = tencentcloud_kubernetes_cluster.managed_cluster.id
210211
instance_id = tencentcloud_instance.foo.id
211212
password = "Lo4wbdit"
213+
unschedulable = 0
212214
213215
labels = {
214216
"test1" = "test1",
215217
"test2" = "test2",
216218
}
217219
218-
extra_args = [
219-
"root-dir=/var/lib/kubelet"
220-
]
221220
}
222221
`
223222
}

tencentcloud/resource_tc_kubernetes_cluster_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ func TestAccTencentCloudTkeResource(t *testing.T) {
3838
resource.TestCheckResourceAttrSet(testTkeClusterResourceKey, "cluster_external_endpoint"),
3939
resource.TestCheckResourceAttr(testTkeClusterResourceKey, "labels.test1", "test1"),
4040
resource.TestCheckResourceAttr(testTkeClusterResourceKey, "labels.test2", "test2"),
41+
resource.TestCheckResourceAttr(testTkeClusterResourceKey, "unschedulable", "0"),
4142
),
4243
},
4344
{
@@ -191,6 +192,8 @@ resource "tencentcloud_kubernetes_cluster" "managed_cluster" {
191192
"%s" = "%s"
192193
}
193194
195+
unschedulable = 0
196+
194197
labels = {
195198
"test1" = "test1",
196199
"test2" = "test2",

tencentcloud/resource_tc_kubernetes_node_pool.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,12 @@ func ResourceTencentCloudKubernetesNodePool() *schema.Resource {
327327
Optional: true,
328328
Description: "Labels of kubernetes node pool created nodes. The label key name does not exceed 63 characters, only supports English, numbers,'/','-', and does not allow beginning with ('/').",
329329
},
330+
"unschedulable": {
331+
Type: schema.TypeInt,
332+
Optional: true,
333+
ForceNew: true,
334+
Description: "Sets whether the joining node participates in the schedule.",
335+
},
330336
"taints": {
331337
Type: schema.TypeList,
332338
Optional: true,
@@ -695,6 +701,9 @@ func resourceKubernetesNodePoolCreate(d *schema.ResourceData, meta interface{})
695701
iAdvanced.ExtraArgs.Kubelet = append(iAdvanced.ExtraArgs.Kubelet, &extraArg)
696702
}
697703
}
704+
if temp, ok := d.GetOk("unschedulable"); ok {
705+
iAdvanced.Unschedulable = helper.Int64(int64(temp.(int)))
706+
}
698707

699708
service := TkeService{client: meta.(*TencentCloudClient).apiV3Conn}
700709

tencentcloud/resource_tc_kubernetes_node_pool_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func TestAccTencentCloudTkeNodePoolResource(t *testing.T) {
3333
resource.TestCheckResourceAttr(testTkeClusterNodePoolResourceKey, "min_size", "1"),
3434
resource.TestCheckResourceAttr(testTkeClusterNodePoolResourceKey, "desired_capacity", "1"),
3535
resource.TestCheckResourceAttr(testTkeClusterNodePoolResourceKey, "name", "mynodepool"),
36+
resource.TestCheckResourceAttr(testTkeClusterNodePoolResourceKey, "unschedulable", "0"),
3637
),
3738
},
3839
{
@@ -48,6 +49,7 @@ func TestAccTencentCloudTkeNodePoolResource(t *testing.T) {
4849
resource.TestCheckResourceAttr(testTkeClusterNodePoolResourceKey, "desired_capacity", "2"),
4950
resource.TestCheckResourceAttr(testTkeClusterNodePoolResourceKey, "name", "mynodepoolupdate"),
5051
resource.TestCheckResourceAttr(testTkeClusterNodePoolResourceKey, "node_os", "ubuntu18.04.1x86_64"),
52+
resource.TestCheckResourceAttr(testTkeClusterNodePoolResourceKey, "unschedulable", "1"),
5153
),
5254
},
5355
},
@@ -207,7 +209,7 @@ resource "tencentcloud_kubernetes_node_pool" "np_test" {
207209
enhanced_monitor_service = false
208210
209211
}
210-
212+
unschedulable = 0
211213
labels = {
212214
"test1" = "test1",
213215
"test2" = "test2",
@@ -261,7 +263,7 @@ resource "tencentcloud_kubernetes_node_pool" "np_test" {
261263
enhanced_monitor_service = false
262264
263265
}
264-
266+
unschedulable = 1
265267
labels = {
266268
"test3" = "test3",
267269
"test2" = "test2",

tencentcloud/resource_tc_kubernetes_scale_worker.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ import (
109109
"strings"
110110
"time"
111111

112+
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
113+
112114
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
113115
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
114116
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
@@ -152,6 +154,12 @@ func resourceTencentCloudTkeScaleWorker() *schema.Resource {
152154
Elem: &schema.Schema{Type: schema.TypeString},
153155
Description: "Custom parameter information related to the node.",
154156
},
157+
"unschedulable": {
158+
Type: schema.TypeInt,
159+
Optional: true,
160+
ForceNew: true,
161+
Description: "Sets whether the joining node participates in the schedule.",
162+
},
155163
"docker_graph_path": {
156164
Type: schema.TypeString,
157165
Optional: true,
@@ -270,6 +278,9 @@ func resourceTencentCloudTkeScaleWorkerCreate(d *schema.ResourceData, meta inter
270278
iAdvanced = tkeGetInstanceAdvancedPara(dMap, meta)
271279

272280
iAdvanced.Labels = GetTkeLabels(d, "labels")
281+
if temp, ok := d.GetOk("unschedulable"); ok {
282+
iAdvanced.Unschedulable = helper.Int64(int64(temp.(int)))
283+
}
273284

274285
if workers, ok := d.GetOk("worker_config"); ok {
275286
workerList := workers.([]interface{})

tencentcloud/resource_tc_kubernetes_scale_worker_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ func TestAccTencentCloudTkeScaleWorkerResource(t *testing.T) {
2828
resource.TestCheckResourceAttrSet(testTkeScaleWorkerResourceKey, "worker_config.#"),
2929
resource.TestCheckResourceAttr(testTkeScaleWorkerResourceKey, "worker_instances_list.#", "1"),
3030
resource.TestCheckResourceAttrSet(testTkeScaleWorkerResourceKey, "worker_instances_list.0.instance_id"),
31-
resource.TestCheckResourceAttrSet(testTkeScaleWorkerResourceKey, "worker_instances_list.0.instance_role")),
31+
resource.TestCheckResourceAttrSet(testTkeScaleWorkerResourceKey, "worker_instances_list.0.instance_role"),
32+
resource.TestCheckResourceAttrSet(testTkeScaleWorkerResourceKey, "unschedulable"),
33+
),
3234
},
3335
},
3436
})
@@ -193,6 +195,7 @@ resource tencentcloud_kubernetes_scale_worker test_scale {
193195
"test1" = "test1",
194196
"test2" = "test2",
195197
}
198+
unschedulable = 0
196199
197200
worker_config {
198201
count = 1

website/docs/r/kubernetes_cluster.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ The following arguments are supported:
240240
* `project_id` - (Optional) Project ID, default value is 0.
241241
* `service_cidr` - (Optional, ForceNew) A network address block of the service. Different from vpc cidr and cidr of other clusters within this vpc. Must be in 10./192.168/172.[16-31] segments.
242242
* `tags` - (Optional) The tags of the cluster.
243+
* `unschedulable` - (Optional, ForceNew) Sets whether the joining node participates in the schedule.
243244
* `worker_config` - (Optional, ForceNew) Deploy the machine configuration information of the 'WORKER' service, and create <=20 units for common users. The other 'WORK' service are added by 'tencentcloud_kubernetes_worker'.
244245

245246
The `cluster_extra_args` object supports the following:

website/docs/r/kubernetes_cluster_attachment.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ The following arguments are supported:
110110
* `key_ids` - (Optional, ForceNew) The key pair to use for the instance, it looks like skey-16jig7tx, it should be set if `password` not set.
111111
* `labels` - (Optional, ForceNew) Labels of tke attachment exits CVM.
112112
* `password` - (Optional, ForceNew) Password to access, should be set if `key_ids` not set.
113+
* `unschedulable` - (Optional, ForceNew) Sets whether the joining node participates in the schedule.
113114
* `worker_config` - (Optional, ForceNew) Deploy the machine configuration information of the 'WORKER', commonly used to attach existing instances.
114115

115116
The `data_disk` object supports the following:

0 commit comments

Comments
 (0)