Skip to content

Commit ceb5bc0

Browse files
authored
Merge pull request #605 from junchuguo/master
add tke unschedulable
2 parents 0afb2a2 + d4bdba3 commit ceb5bc0

18 files changed

+112
-12
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ FEATURES:
66
* **New Resource**: `tencentcloud_kms_external_key`
77
* **New Data Source**: `tencentcloud_kms_keys`
88

9+
ENHANCEMENTS:
10+
11+
* Resource `tencentcloud_kubernetes_cluster_attachment` add `unschedulable` to sets whether the joining node participates in the schedule.
12+
* Resource `tencentcloud_kubernetes_cluster` add `unschedulable` to sets whether the joining node participates in the schedule.
13+
* Resource `tencentcloud_kubernetes_node_pool` add `unschedulable` to sets whether the joining node participates in the schedule.
14+
* Resource `tencentcloud_kubernetes_scale_worker` add `unschedulable` to sets whether the joining node participates in the schedule.
15+
916
## 1.53.9 (March 19, 2021)
1017

1118
ENHANCEMENTS:

tencentcloud/resource_tc_kubernetes_as_scaling_group.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,13 @@ func ResourceTencentCloudKubernetesAsScalingGroup() *schema.Resource {
186186
Elem: &schema.Schema{Type: schema.TypeString},
187187
Description: "Custom parameter information related to the node.",
188188
},
189+
"unschedulable": {
190+
Type: schema.TypeInt,
191+
Optional: true,
192+
ForceNew: true,
193+
Default: 0,
194+
Description: "Sets whether the joining node participates in the schedule. Default is '0'. Participate in scheduling.",
195+
},
189196
},
190197
}
191198
}
@@ -844,7 +851,9 @@ func resourceKubernetesAsScalingGroupCreate(d *schema.ResourceData, meta interfa
844851
}
845852

846853
labels := GetTkeLabels(d, "labels")
847-
854+
if temp, ok := d.GetOk("unschedulable"); ok {
855+
iAdvanced.Unschedulable = int64(temp.(int))
856+
}
848857
if temp, ok := d.GetOk("extra_args"); ok {
849858
extraArgs := helper.InterfacesStrings(temp.([]interface{}))
850859
for _, extraArg := range extraArgs {

tencentcloud/resource_tc_kubernetes_as_scaling_group_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ resource "tencentcloud_kubernetes_as_scaling_group" "as_test" {
212212
}
213213
214214
}
215-
215+
unschedulable = 0
216216
labels = {
217217
"test1" = "test1",
218218
"test2" = "test2",
@@ -271,7 +271,7 @@ resource "tencentcloud_kubernetes_as_scaling_group" "as_test" {
271271
}
272272
273273
}
274-
274+
unschedulable = 1
275275
labels = {
276276
"test1" = "test1",
277277
"test2" = "test2",

tencentcloud/resource_tc_kubernetes_cluster.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,13 @@ 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+
Default: 0,
838+
Description: "Sets whether the joining node participates in the schedule. Default is '0'. Participate in scheduling.",
839+
},
833840
"mount_target": {
834841
Type: schema.TypeString,
835842
Optional: true,
@@ -1290,7 +1297,9 @@ func resourceTencentCloudTkeClusterCreate(d *schema.ResourceData, meta interface
12901297
iAdvanced.ExtraArgs.Kubelet = append(iAdvanced.ExtraArgs.Kubelet, &extraArgs[i])
12911298
}
12921299
}
1293-
1300+
if temp, ok := d.GetOk("unschedulable"); ok {
1301+
iAdvanced.Unschedulable = int64(temp.(int))
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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,13 @@ 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+
Default: 0,
256+
Description: "Sets whether the joining node participates in the schedule. Default is '0'. Participate in scheduling.",
257+
},
251258
//compute
252259
"security_groups": {
253260
Type: schema.TypeSet,
@@ -399,6 +406,7 @@ func resourceTencentCloudTkeClusterAttachmentRead(d *schema.ResourceData, meta i
399406
return resource.RetryableError(fmt.Errorf("cvm instance %s in tke status is %s, retry...",
400407
worker.InstanceId, worker.InstanceState))
401408
}
409+
_ = d.Set("unschedulable", worker.InstanceAdvancedSettings.Unschedulable)
402410
}
403411
}
404412

@@ -471,6 +479,10 @@ func resourceTencentCloudTkeClusterAttachmentCreate(d *schema.ResourceData, meta
471479
request.HostName = &hostNameStr
472480
}
473481

482+
if v, ok := d.GetOk("unschedulable"); ok {
483+
request.InstanceAdvancedSettings.Unschedulable = helper.Int64(v.(int64))
484+
}
485+
474486
/*cvm has been attached*/
475487
var err error
476488
_, 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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,13 @@ 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+
Default: 0,
335+
Description: "Sets whether the joining node participates in the schedule. Default is '0'. Participate in scheduling.",
336+
},
330337
"taints": {
331338
Type: schema.TypeList,
332339
Optional: true,
@@ -695,6 +702,9 @@ func resourceKubernetesNodePoolCreate(d *schema.ResourceData, meta interface{})
695702
iAdvanced.ExtraArgs.Kubelet = append(iAdvanced.ExtraArgs.Kubelet, &extraArg)
696703
}
697704
}
705+
if temp, ok := d.GetOk("unschedulable"); ok {
706+
iAdvanced.Unschedulable = helper.Int64(int64(temp.(int)))
707+
}
698708

699709
service := TkeService{client: meta.(*TencentCloudClient).apiV3Conn}
700710

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: 12 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,13 @@ 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+
Default: 0,
162+
Description: "Sets whether the joining node participates in the schedule. Default is '0'. Participate in scheduling.",
163+
},
155164
"docker_graph_path": {
156165
Type: schema.TypeString,
157166
Optional: true,
@@ -270,6 +279,9 @@ func resourceTencentCloudTkeScaleWorkerCreate(d *schema.ResourceData, meta inter
270279
iAdvanced = tkeGetInstanceAdvancedPara(dMap, meta)
271280

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

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

0 commit comments

Comments
 (0)