Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tke): [121108945] tencentcloud_kubernetes_scale_worker support tags #3010

Merged
merged 3 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/3010.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/tencentcloud_kubernetes_scale_worker: support `tags`
```
Original file line number Diff line number Diff line change
Expand Up @@ -1981,6 +1981,26 @@ func tkeGetCvmRunInstancesPara(dMap map[string]interface{}, meta interface{},
request.HpcClusterId = helper.String(v.(string))
}

if v, ok := dMap["tags"].([]interface{}); ok && len(v) != 0 {
tmpTagSpec := cvm.TagSpecification{}
tmpTagSpec.ResourceType = helper.String("instance")
for _, item := range v {
value := item.(map[string]interface{})
tmpTag := cvm.Tag{}
if v, ok := value["key"].(string); ok && v != "" {
tmpTag.Key = &v
}

if v, ok := value["value"].(string); ok && v != "" {
tmpTag.Value = &v
}

tmpTagSpec.Tags = append(tmpTagSpec.Tags, &tmpTag)
}

request.TagSpecification = append(request.TagSpecification, &tmpTagSpec)
}

cvmJson = request.ToJsonString()

cvmJson = strings.Replace(cvmJson, `"Password":"",`, "", -1)
Expand Down
23 changes: 23 additions & 0 deletions tencentcloud/services/tke/resource_tc_kubernetes_scale_worker.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ resource "tencentcloud_kubernetes_scale_worker" "example" {
enhanced_security_service = false
enhanced_monitor_service = false
user_data = "dGVzdA=="
password = "AABBccdd1122"
password = "Password@123"

tags {
key = "createBy"
value = "Terraform"
}
}

create_result_output_file = "my_output_file_path"
Expand Down Expand Up @@ -102,7 +107,7 @@ resource "tencentcloud_kubernetes_scale_worker" "example" {
enhanced_security_service = false
enhanced_monitor_service = false
user_data = "dGVzdA=="
password = "AABBccdd1122"
password = "Password@123"
}
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,21 @@ func resourceTencentCloudKubernetesScaleWorkerReadPostRequest1(ctx context.Conte
}

mapping["data_disk"] = dataDisks // worker_config.data_disk

if instance.Tags != nil {
tmpList := make([]interface{}, 0, len(instance.Tags))
for _, item := range instance.Tags {
tmpTag := map[string]interface{}{
"key": item.Key,
"value": item.Value,
}

tmpList = append(tmpList, tmpTag)
}

mapping["tags"] = tmpList
}

instanceList = append(instanceList, mapping)
}
if importFlag1 {
Expand Down
15 changes: 13 additions & 2 deletions website/docs/r/kubernetes_scale_worker.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ resource "tencentcloud_kubernetes_scale_worker" "example" {
enhanced_security_service = false
enhanced_monitor_service = false
user_data = "dGVzdA=="
password = "AABBccdd1122"
password = "Password@123"

tags {
key = "createBy"
value = "Terraform"
}
}

create_result_output_file = "my_output_file_path"
Expand Down Expand Up @@ -113,7 +118,7 @@ resource "tencentcloud_kubernetes_scale_worker" "example" {
enhanced_security_service = false
enhanced_monitor_service = false
user_data = "dGVzdA=="
password = "AABBccdd1122"
password = "Password@123"
}
}
```
Expand Down Expand Up @@ -166,6 +171,11 @@ The `gpu_args` object supports the following:
* `driver` - (Optional, Map) GPU driver version. Format like: `{ version: String, name: String }`. `version`: Version of GPU driver or CUDA; `name`: Name of GPU driver or CUDA.
* `mig_enable` - (Optional, Bool) Whether to enable MIG.

The `tags` object of `worker_config` supports the following:

* `key` - (Required, String, ForceNew) Tag key.
* `value` - (Required, String, ForceNew) Tag value.

The `taints` object supports the following:

* `effect` - (Optional, String, ForceNew) Effect of the taint.
Expand Down Expand Up @@ -200,6 +210,7 @@ The `worker_config` object supports the following:
* `security_group_ids` - (Optional, List, ForceNew) Security groups to which a CVM instance belongs.
* `system_disk_size` - (Optional, Int, ForceNew) Volume of system disk in GB. Default is `50`.
* `system_disk_type` - (Optional, String, ForceNew) System disk type. For more information on limits of system disk types, see [Storage Overview](https://intl.cloud.tencent.com/document/product/213/4952). Valid values: `LOCAL_BASIC`: local disk, `LOCAL_SSD`: local SSD disk, `CLOUD_SSD`: SSD, `CLOUD_PREMIUM`: Premium Cloud Storage. NOTE: `CLOUD_BASIC`, `LOCAL_BASIC` and `LOCAL_SSD` are deprecated.
* `tags` - (Optional, List, ForceNew) Tag pairs.
* `user_data` - (Optional, String, ForceNew) User data provided to instances, needs to be encoded in base64, and the maximum supported data size is 16KB.

## Attributes Reference
Expand Down
Loading