Skip to content

Commit eda6dd6

Browse files
authored
feat(tke): [115617024]add pre_start_user_script field (#2543)
* add pre_start_user_script field * add changelog 2543.txt
1 parent 793c2de commit eda6dd6

File tree

7 files changed

+31
-7
lines changed

7 files changed

+31
-7
lines changed

.changelog/2543.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_kubernetes_node_pool: add `pre_start_user_script` field
3+
```

tencentcloud/acctest/basic.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ const (
101101

102102
DefaultSecurityGroup = "sg-ijato2x1"
103103

104-
DefaultProjectId = "1250480"
104+
DefaultProjectId = "0"
105105

106106
DefaultTkeOSImageId = "img-2lr9q49h"
107107
DefaultTkeOSImageName = "tlinux2.2(tkernel3)x86_64"

tencentcloud/services/tke/resource_tc_kubernetes_cluster_attachment.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ func TkeInstanceAdvancedSetting() map[string]*schema.Schema {
135135
Optional: true,
136136
Description: "Base64-encoded User Data text, the length limit is 16KB.",
137137
},
138+
"pre_start_user_script": {
139+
Type: schema.TypeString,
140+
ForceNew: true,
141+
Optional: true,
142+
Description: "Base64-encoded user script, executed before initializing the node, currently only effective for adding existing nodes.",
143+
},
138144
"is_schedule": {
139145
Type: schema.TypeBool,
140146
ForceNew: true,
@@ -303,6 +309,10 @@ func tkeGetInstanceAdvancedPara(dMap map[string]interface{}, meta interface{}) (
303309
setting.UserScript = helper.String(v.(string))
304310
}
305311

312+
if v, ok := dMap["pre_start_user_script"]; ok {
313+
setting.PreStartUserScript = helper.String(v.(string))
314+
}
315+
306316
if v, ok := dMap["docker_graph_path"]; ok {
307317
setting.DockerGraphPath = helper.String(v.(string))
308318
}

tencentcloud/services/tke/resource_tc_kubernetes_node_pool.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,6 +1173,10 @@ func resourceKubernetesNodePoolRead(d *schema.ResourceData, meta interface{}) er
11731173
nodeConfig["docker_graph_path"] = "/var/lib/docker"
11741174
}
11751175

1176+
if helper.PString(nodePool.PreStartUserScript) != "" {
1177+
nodeConfig["pre_start_user_script"] = helper.PString(nodePool.PreStartUserScript)
1178+
}
1179+
11761180
if importFlag {
11771181
if nodePool.ExtraArgs != nil && len(nodePool.ExtraArgs.Kubelet) > 0 {
11781182
extraArgs := make([]string, 0)

tencentcloud/services/tke/resource_tc_kubernetes_node_pool_test.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ func TestAccTencentCloudKubernetesNodePoolResource_basic(t *testing.T) {
112112
testAccCheckTkeNodePoolExists,
113113
resource.TestCheckResourceAttrSet(testTkeClusterNodePoolResourceKey, "cluster_id"),
114114
resource.TestCheckResourceAttr(testTkeClusterNodePoolResourceKey, "node_config.#", "1"),
115+
resource.TestCheckResourceAttr(testTkeClusterNodePoolResourceKey, "node_config.0.pre_start_user_script", "IyEvYmluL3NoIGVjaG8gImhlbGxvIHdvcmxkIg=="),
115116
resource.TestCheckResourceAttr(testTkeClusterNodePoolResourceKey, "auto_scaling_config.#", "1"),
116117
resource.TestCheckResourceAttr(testTkeClusterNodePoolResourceKey, "auto_scaling_config.0.system_disk_size", "50"),
117118
resource.TestCheckResourceAttr(testTkeClusterNodePoolResourceKey, "auto_scaling_config.0.data_disk.#", "1"),
@@ -180,8 +181,8 @@ func TestAccTencentCloudKubernetesNodePoolResource_basic(t *testing.T) {
180181
resource.TestCheckResourceAttr(testTkeClusterNodePoolResourceKey, "default_cooldown", "350"),
181182
resource.TestCheckResourceAttr(testTkeClusterNodePoolResourceKey, "termination_policies.#", "1"),
182183
resource.TestCheckResourceAttr(testTkeClusterNodePoolResourceKey, "termination_policies.0", "NEWEST_INSTANCE"),
183-
resource.TestCheckResourceAttr(testTkeClusterNodePoolResourceKey, "tags.keep-test-np1", "testI"),
184-
resource.TestCheckResourceAttr(testTkeClusterNodePoolResourceKey, "tags.keep-test-np3", "testIII"),
184+
resource.TestCheckResourceAttr(testTkeClusterNodePoolResourceKey, "tags.keep-test-np1", "test1"),
185+
resource.TestCheckResourceAttr(testTkeClusterNodePoolResourceKey, "tags.keep-test-np3", "test3"),
185186
resource.TestCheckResourceAttr(testTkeClusterNodePoolResourceKey, "auto_scaling_config.0.orderly_security_group_ids.#", "4"),
186187
resource.TestCheckResourceAttr(testTkeClusterNodePoolResourceKey, "auto_scaling_config.0.host_name", "12.123.1.1"),
187188
resource.TestCheckResourceAttr(testTkeClusterNodePoolResourceKey, "auto_scaling_config.0.host_name_style", "UNIQUE"),
@@ -382,6 +383,7 @@ resource "tencentcloud_kubernetes_node_pool" "np_test" {
382383
extra_args = [
383384
"root-dir=/var/lib/kubelet"
384385
]
386+
pre_start_user_script = "IyEvYmluL3NoIGVjaG8gImhlbGxvIHdvcmxkIg=="
385387
}
386388
}
387389
`
@@ -446,6 +448,7 @@ resource "tencentcloud_kubernetes_node_pool" "np_test" {
446448
extra_args = [
447449
"root-dir=/var/lib/kubelet"
448450
]
451+
pre_start_user_script = "IyEvYmluL3NoIGVjaG8gImhlbGxvIHdvcmxkIg=="
449452
}
450453
}
451454
`
@@ -514,14 +517,15 @@ resource "tencentcloud_kubernetes_node_pool" "np_test" {
514517
}
515518
516519
tags = {
517-
keep-test-np1 = "testI"
518-
keep-test-np3 = "testIII"
520+
keep-test-np1 = "test1"
521+
keep-test-np3 = "test3"
519522
}
520523
521524
node_config {
522525
extra_args = [
523526
"root-dir=/var/lib/kubelet"
524527
]
528+
pre_start_user_script = "IyEvYmluL3NoIGVjaG8gImhlbGxvIHdvcmxkIg=="
525529
}
526530
}
527531
`
@@ -627,8 +631,8 @@ resource "tencentcloud_kubernetes_node_pool" "np_test" {
627631
}
628632
629633
tags = {
630-
keep-test-np1 = "testI"
631-
keep-test-np3 = "testIII"
634+
keep-test-np1 = "test1"
635+
keep-test-np3 = "test3"
632636
}
633637
634638
node_config {

website/docs/r/kubernetes_cluster_attachment.html.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ The `worker_config_overrides` object supports the following:
161161
* `gpu_args` - (Optional, List, ForceNew) GPU driver parameters.
162162
* `is_schedule` - (Optional, Bool, ForceNew) Indicate to schedule the adding node or not. Default is true.
163163
* `mount_target` - (Optional, String, ForceNew) Mount target. Default is not mounting.
164+
* `pre_start_user_script` - (Optional, String, ForceNew) Base64-encoded user script, executed before initializing the node, currently only effective for adding existing nodes.
164165
* `user_data` - (Optional, String, ForceNew) Base64-encoded User Data text, the length limit is 16KB.
165166

166167
The `worker_config` object supports the following:
@@ -172,6 +173,7 @@ The `worker_config` object supports the following:
172173
* `gpu_args` - (Optional, List, ForceNew) GPU driver parameters.
173174
* `is_schedule` - (Optional, Bool, ForceNew) Indicate to schedule the adding node or not. Default is true.
174175
* `mount_target` - (Optional, String, ForceNew) Mount target. Default is not mounting.
176+
* `pre_start_user_script` - (Optional, String, ForceNew) Base64-encoded user script, executed before initializing the node, currently only effective for adding existing nodes.
175177
* `user_data` - (Optional, String, ForceNew) Base64-encoded User Data text, the length limit is 16KB.
176178

177179
## Attributes Reference

website/docs/r/kubernetes_node_pool.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ The `node_config` object supports the following:
246246
* `gpu_args` - (Optional, List, ForceNew) GPU driver parameters.
247247
* `is_schedule` - (Optional, Bool, ForceNew) Indicate to schedule the adding node or not. Default is true.
248248
* `mount_target` - (Optional, String, ForceNew) Mount target. Default is not mounting.
249+
* `pre_start_user_script` - (Optional, String, ForceNew) Base64-encoded user script, executed before initializing the node, currently only effective for adding existing nodes.
249250
* `user_data` - (Optional, String, ForceNew) Base64-encoded User Data text, the length limit is 16KB.
250251

251252
The `taints` object supports the following:

0 commit comments

Comments
 (0)