diff --git a/tencentcloud/services/tke/resource_tc_kubernetes_auth_attachment.md b/tencentcloud/services/tke/resource_tc_kubernetes_auth_attachment.md index 889bb104a3..7d7a5ac551 100644 --- a/tencentcloud/services/tke/resource_tc_kubernetes_auth_attachment.md +++ b/tencentcloud/services/tke/resource_tc_kubernetes_auth_attachment.md @@ -161,4 +161,12 @@ output "identity_url" { value = data.tencentcloud_cam_oidc_config.oidc_config.identity_url } +``` + +Import + +tke cluster authentication can be imported, e.g. + +``` +$ terraform import tencentcloud_kubernetes_auth_attachment.test cls-xxx ``` \ No newline at end of file diff --git a/tencentcloud/services/tke/resource_tc_kubernetes_cluster.go b/tencentcloud/services/tke/resource_tc_kubernetes_cluster.go index b8b3c2ca24..e5b70bd859 100644 --- a/tencentcloud/services/tke/resource_tc_kubernetes_cluster.go +++ b/tencentcloud/services/tke/resource_tc_kubernetes_cluster.go @@ -42,7 +42,7 @@ func ResourceTencentCloudKubernetesCluster() *schema.Resource { Optional: true, ForceNew: true, Default: "tlinux2.4x86_64", - Description: "Operating system of the cluster, the available values include: 'centos7.6.0_x64','ubuntu18.04.1x86_64','tlinux2.4x86_64'. Default is 'tlinux2.4x86_64'.", + Description: "Cluster operating system, supports setting public images (the field passes the corresponding image Name) and custom images (the field passes the corresponding image ID). For details, please refer to: https://cloud.tencent.com/document/product/457/68289.", }, "cluster_subnet_id": { @@ -658,7 +658,7 @@ func ResourceTencentCloudKubernetesCluster() *schema.Resource { "img_id": { Type: schema.TypeString, Optional: true, - Description: "The valid image id, format of img-xxx.", + Description: "The valid image id, format of img-xxx. Note: `img_id` will be replaced with the image corresponding to TKE `cluster_os`.", ValidateFunc: tccommon.ValidateImageID, }, "desired_pod_num": { @@ -681,7 +681,7 @@ func ResourceTencentCloudKubernetesCluster() *schema.Resource { Type: schema.TypeList, Optional: true, ForceNew: true, - Description: "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'.", + Description: "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_scale_worker'.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "count": { @@ -921,7 +921,7 @@ func ResourceTencentCloudKubernetesCluster() *schema.Resource { "img_id": { Type: schema.TypeString, Optional: true, - Description: "The valid image id, format of img-xxx.", + Description: "The valid image id, format of img-xxx. Note: `img_id` will be replaced with the image corresponding to TKE `cluster_os`.", ValidateFunc: tccommon.ValidateImageID, }, "desired_pod_num": { @@ -1552,12 +1552,8 @@ func resourceTencentCloudKubernetesClusterRead(d *schema.ResourceData, meta inte return err } - respData1, err := service.DescribeKubernetesClusterById1(ctx, clusterId) - if err != nil { - return err - } - - err = resource.Retry(tccommon.ReadRetryTimeout, func() *resource.RetryError { + var respData1 *tke.DescribeClusterInstancesResponseParams + reqErr1 := resource.Retry(tccommon.ReadRetryTimeout, func() *resource.RetryError { result, e := service.DescribeKubernetesClusterById1(ctx, clusterId) if e != nil { if err := resourceTencentCloudKubernetesClusterReadRequestOnError1(ctx, result, e); err != nil { @@ -1568,9 +1564,9 @@ func resourceTencentCloudKubernetesClusterRead(d *schema.ResourceData, meta inte respData1 = result return nil }) - if err != nil { - log.Printf("[CRITAL]%s read kubernetes cluster failed, reason:%+v", logId, err) - return err + if reqErr1 != nil { + log.Printf("[CRITAL]%s read kubernetes cluster failed, reason:%+v", logId, reqErr1) + return reqErr1 } if respData1 == nil { @@ -1609,12 +1605,8 @@ func resourceTencentCloudKubernetesClusterRead(d *schema.ResourceData, meta inte _ = d.Set("worker_instances_list", instanceSetList) } - respData2, err := service.DescribeKubernetesClusterById2(ctx, clusterId) - if err != nil { - return err - } - - err = resource.Retry(tccommon.ReadRetryTimeout, func() *resource.RetryError { + var respData2 *tke.DescribeClusterSecurityResponseParams + reqErr2 := resource.Retry(tccommon.ReadRetryTimeout, func() *resource.RetryError { result, e := service.DescribeKubernetesClusterById2(ctx, clusterId) if e != nil { if err := resourceTencentCloudKubernetesClusterReadRequestOnError2(ctx, result, e); err != nil { @@ -1625,9 +1617,9 @@ func resourceTencentCloudKubernetesClusterRead(d *schema.ResourceData, meta inte respData2 = result return nil }) - if err != nil { - log.Printf("[CRITAL]%s read kubernetes cluster failed, reason:%+v", logId, err) - return err + if reqErr2 != nil { + log.Printf("[CRITAL]%s read kubernetes cluster failed, reason:%+v", logId, reqErr2) + return reqErr2 } if respData2 == nil { @@ -1692,7 +1684,7 @@ func resourceTencentCloudKubernetesClusterUpdate(d *schema.ResourceData, meta in if needChange { request := tke.NewModifyClusterAttributeRequest() - request.ClusterId = &clusterId + request.ClusterId = helper.String(clusterId) if v, ok := d.GetOkExists("project_id"); ok { request.ProjectId = helper.IntInt64(v.(int)) @@ -1739,7 +1731,7 @@ func resourceTencentCloudKubernetesClusterUpdate(d *schema.ResourceData, meta in response1 := tke.NewUpdateClusterVersionResponse() - request1.ClusterId = &clusterId + request1.ClusterId = helper.String(clusterId) if v, ok := d.GetOk("cluster_version"); ok { request1.DstVersion = helper.String(v.(string)) @@ -1780,7 +1772,7 @@ func resourceTencentCloudKubernetesClusterUpdate(d *schema.ResourceData, meta in if needChange2 { request2 := tke.NewModifyClusterAsGroupOptionAttributeRequest() - request2.ClusterId = &clusterId + request2.ClusterId = helper.String(clusterId) if clusterAsGroupOptionMap, ok := helper.InterfacesHeadMap(d, "node_pool_global_config"); ok { clusterAsGroupOption := tke.ClusterAsGroupOption{} @@ -1850,7 +1842,7 @@ func resourceTencentCloudKubernetesClusterDelete(d *schema.ResourceData, meta in response = tke.NewDeleteClusterResponse() ) - request.ClusterId = &clusterId + request.ClusterId = helper.String(clusterId) instanceDeleteMode := "terminate" request.InstanceDeleteMode = &instanceDeleteMode @@ -1873,7 +1865,7 @@ func resourceTencentCloudKubernetesClusterDelete(d *schema.ResourceData, meta in return nil }) if err != nil { - log.Printf("[CRITAL]%s create kubernetes cluster failed, reason:%+v", logId, err) + log.Printf("[CRITAL]%s delete kubernetes cluster failed, reason:%+v", logId, err) return err } diff --git a/tencentcloud/services/tke/resource_tc_kubernetes_cluster.md b/tencentcloud/services/tke/resource_tc_kubernetes_cluster.md index a8a962b37b..42c803a191 100644 --- a/tencentcloud/services/tke/resource_tc_kubernetes_cluster.md +++ b/tencentcloud/services/tke/resource_tc_kubernetes_cluster.md @@ -90,7 +90,7 @@ resource "tencentcloud_kubernetes_cluster" "example" { internet_max_bandwidth_out = 100 public_ip_assigned = true subnet_id = local.first_subnet_id - img_id = local.image_id + # img_id = local.image_id data_disk { disk_type = "CLOUD_PREMIUM" @@ -484,7 +484,7 @@ resource "tencentcloud_kubernetes_cluster" "example" { internet_max_bandwidth_out = 100 public_ip_assigned = true subnet_id = local.first_subnet_id - img_id = local.image_id + # img_id = local.image_id data_disk { disk_type = "CLOUD_PREMIUM" @@ -588,7 +588,7 @@ resource "tencentcloud_kubernetes_cluster" "cluster_with_addon" { internet_max_bandwidth_out = 100 public_ip_assigned = true subnet_id = data.tencentcloud_vpc_subnets.vpc_first.instance_list.0.subnet_id - img_id = "img-rkiynh11" + # img_id = "img-rkiynh11" enhanced_security_service = false enhanced_monitor_service = false user_data = "dGVzdA==" @@ -777,4 +777,12 @@ resource "tencentcloud_kubernetes_cluster" "managed_cluster" { topic_id = "" # optional } } +``` + +Import + +tke cluster can be imported, e.g. + +``` +$ terraform import tencentcloud_kubernetes_cluster.test cls-xxx ``` \ No newline at end of file diff --git a/tencentcloud/services/tke/resource_tc_kubernetes_scale_worker.md b/tencentcloud/services/tke/resource_tc_kubernetes_scale_worker.md index 4c74d3c2cd..cd050faaf1 100644 --- a/tencentcloud/services/tke/resource_tc_kubernetes_scale_worker.md +++ b/tencentcloud/services/tke/resource_tc_kubernetes_scale_worker.md @@ -99,4 +99,12 @@ resource tencentcloud_kubernetes_scale_worker test_scale { password = "AABBccdd1122" } } +``` + +Import + +tke scale worker can be imported, e.g. + +``` +$ terraform import tencentcloud_kubernetes_scale_worker.test cls-xxx#ins-xxx ``` \ No newline at end of file diff --git a/tencentcloud/services/tke/service_tencentcloud_tke.go b/tencentcloud/services/tke/service_tencentcloud_tke.go index d0134397e4..0260515abf 100644 --- a/tencentcloud/services/tke/service_tencentcloud_tke.go +++ b/tencentcloud/services/tke/service_tencentcloud_tke.go @@ -3162,7 +3162,7 @@ func (me *TkeService) DescribeKubernetesClusterById(ctx context.Context, cluster logId := tccommon.GetLogId(ctx) request := tke.NewDescribeClustersRequest() - request.ClusterIds = []*string{&clusterId} + request.ClusterIds = []*string{helper.String(clusterId)} defer func() { if errRet != nil { @@ -3179,7 +3179,7 @@ func (me *TkeService) DescribeKubernetesClusterById(ctx context.Context, cluster } log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString()) - if response == nil || len(response.Response.Clusters) < 1 { + if len(response.Response.Clusters) < 1 { return } @@ -3191,7 +3191,7 @@ func (me *TkeService) DescribeKubernetesClusterById1(ctx context.Context, cluste logId := tccommon.GetLogId(ctx) request := tke.NewDescribeClusterInstancesRequest() - request.ClusterId = &clusterId + request.ClusterId = helper.String(clusterId) defer func() { if errRet != nil { @@ -3216,7 +3216,7 @@ func (me *TkeService) DescribeKubernetesClusterById2(ctx context.Context, cluste logId := tccommon.GetLogId(ctx) request := tke.NewDescribeClusterSecurityRequest() - request.ClusterId = &clusterId + request.ClusterId = helper.String(clusterId) defer func() { if errRet != nil { diff --git a/website/docs/r/kubernetes_auth_attachment.html.markdown b/website/docs/r/kubernetes_auth_attachment.html.markdown index f9c73f4ef4..d49c805804 100644 --- a/website/docs/r/kubernetes_auth_attachment.html.markdown +++ b/website/docs/r/kubernetes_auth_attachment.html.markdown @@ -196,3 +196,11 @@ In addition to all arguments above, the following attributes are exported: * `tke_default_jwks_uri` - The default jwks_uri of tke. If use_tke_default is set to `true`, this parameter will be set to the default value. +## Import + +tke cluster authentication can be imported, e.g. + +``` +$ terraform import tencentcloud_kubernetes_auth_attachment.test cls-xxx +``` + diff --git a/website/docs/r/kubernetes_cluster.html.markdown b/website/docs/r/kubernetes_cluster.html.markdown index 4ade5b8748..1e747a2a32 100644 --- a/website/docs/r/kubernetes_cluster.html.markdown +++ b/website/docs/r/kubernetes_cluster.html.markdown @@ -101,7 +101,7 @@ resource "tencentcloud_kubernetes_cluster" "example" { internet_max_bandwidth_out = 100 public_ip_assigned = true subnet_id = local.first_subnet_id - img_id = local.image_id + # img_id = local.image_id data_disk { disk_type = "CLOUD_PREMIUM" @@ -492,7 +492,7 @@ resource "tencentcloud_kubernetes_cluster" "example" { internet_max_bandwidth_out = 100 public_ip_assigned = true subnet_id = local.first_subnet_id - img_id = local.image_id + # img_id = local.image_id data_disk { disk_type = "CLOUD_PREMIUM" @@ -596,10 +596,10 @@ resource "tencentcloud_kubernetes_cluster" "cluster_with_addon" { internet_max_bandwidth_out = 100 public_ip_assigned = true subnet_id = data.tencentcloud_vpc_subnets.vpc_first.instance_list.0.subnet_id - img_id = "img-rkiynh11" - enhanced_security_service = false - enhanced_monitor_service = false - user_data = "dGVzdA==" + # img_id = "img-rkiynh11" + enhanced_security_service = false + enhanced_monitor_service = false + user_data = "dGVzdA==" # password = "ZZXXccvv1212" // Optional, should be set if key_ids not set. key_ids = "skey-11112222" } @@ -816,7 +816,7 @@ The following arguments are supported: * `cluster_max_service_num` - (Optional, Int, ForceNew) The maximum number of services in the cluster. Default is 256. The range is from 32 to 32768. When its power unequal to 2, it will round upward to the closest power of 2. * `cluster_name` - (Optional, String) Name of the cluster. * `cluster_os_type` - (Optional, String, ForceNew) Image type of the cluster os, the available values include: 'GENERAL'. Default is 'GENERAL'. -* `cluster_os` - (Optional, String, ForceNew) Operating system of the cluster, the available values include: 'centos7.6.0_x64','ubuntu18.04.1x86_64','tlinux2.4x86_64'. Default is 'tlinux2.4x86_64'. +* `cluster_os` - (Optional, String, ForceNew) Cluster operating system, supports setting public images (the field passes the corresponding image Name) and custom images (the field passes the corresponding image ID). For details, please refer to: https://cloud.tencent.com/document/product/457/68289. * `cluster_subnet_id` - (Optional, String, ForceNew) Subnet ID of the cluster, such as: subnet-b3p7d7q5. * `cluster_version` - (Optional, String) Version of the cluster. Use `tencentcloud_kubernetes_available_cluster_versions` to get the upgradable cluster version. * `container_runtime` - (Optional, String, ForceNew) Runtime type of the cluster, the available values include: 'docker' and 'containerd'.The Kubernetes v1.24 has removed dockershim, so please use containerd in v1.24 or higher.Default is 'docker'. @@ -847,7 +847,7 @@ The following arguments are supported: * `unschedulable` - (Optional, Int, ForceNew) Sets whether the joining node participates in the schedule. Default is '0'. Participate in scheduling. * `upgrade_instances_follow_cluster` - (Optional, Bool) Indicates whether upgrade all instances when cluster_version change. Default is false. * `vpc_cni_type` - (Optional, String) Distinguish between shared network card multi-IP mode and independent network card mode. Fill in `tke-route-eni` for shared network card multi-IP mode and `tke-direct-eni` for independent network card mode. The default is shared network card mode. When it is necessary to turn off the vpc-cni container network capability, both `eni_subnet_ids` and `vpc_cni_type` must be set to empty. -* `worker_config` - (Optional, List, 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'. +* `worker_config` - (Optional, List, 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_scale_worker'. The `auth_options` object supports the following: @@ -935,7 +935,7 @@ The `master_config` object supports the following: * `enhanced_security_service` - (Optional, Bool, ForceNew) To specify whether to enable cloud security service. Default is TRUE. * `hostname` - (Optional, String, ForceNew) The host name of the attached instance. Dot (.) and dash (-) cannot be used as the first and last characters of HostName and cannot be used consecutively. Windows example: The length of the name character is [2, 15], letters (capitalization is not restricted), numbers and dashes (-) are allowed, dots (.) are not supported, and not all numbers are allowed. Examples of other types (Linux, etc.): The character length is [2, 60], and multiple dots are allowed. There is a segment between the dots. Each segment allows letters (with no limitation on capitalization), numbers and dashes (-). * `hpc_cluster_id` - (Optional, String) Id of cvm hpc cluster. -* `img_id` - (Optional, String) The valid image id, format of img-xxx. +* `img_id` - (Optional, String) The valid image id, format of img-xxx. Note: `img_id` will be replaced with the image corresponding to TKE `cluster_os`. * `instance_charge_type_prepaid_period` - (Optional, Int, ForceNew) The tenancy (time unit is month) of the prepaid instance. NOTE: it only works when instance_charge_type is set to `PREPAID`. Valid values are `1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`, `9`, `10`, `11`, `12`, `24`, `36`. * `instance_charge_type_prepaid_renew_flag` - (Optional, String, ForceNew) Auto renewal flag. Valid values: `NOTIFY_AND_AUTO_RENEW`: notify upon expiration and renew automatically, `NOTIFY_AND_MANUAL_RENEW`: notify upon expiration but do not renew automatically, `DISABLE_NOTIFY_AND_MANUAL_RENEW`: neither notify upon expiration nor renew automatically. Default value: `NOTIFY_AND_MANUAL_RENEW`. If this parameter is specified as `NOTIFY_AND_AUTO_RENEW`, the instance will be automatically renewed on a monthly basis if the account balance is sufficient. NOTE: it only works when instance_charge_type is set to `PREPAID`. * `instance_charge_type` - (Optional, String, ForceNew) The charge type of instance. Valid values are `PREPAID` and `POSTPAID_BY_HOUR`. The default is `POSTPAID_BY_HOUR`. Note: TencentCloud International only supports `POSTPAID_BY_HOUR`, `PREPAID` instance will not terminated after cluster deleted, and may not allow to delete before expired. @@ -977,7 +977,7 @@ The `worker_config` object supports the following: * `enhanced_security_service` - (Optional, Bool, ForceNew) To specify whether to enable cloud security service. Default is TRUE. * `hostname` - (Optional, String, ForceNew) The host name of the attached instance. Dot (.) and dash (-) cannot be used as the first and last characters of HostName and cannot be used consecutively. Windows example: The length of the name character is [2, 15], letters (capitalization is not restricted), numbers and dashes (-) are allowed, dots (.) are not supported, and not all numbers are allowed. Examples of other types (Linux, etc.): The character length is [2, 60], and multiple dots are allowed. There is a segment between the dots. Each segment allows letters (with no limitation on capitalization), numbers and dashes (-). * `hpc_cluster_id` - (Optional, String) Id of cvm hpc cluster. -* `img_id` - (Optional, String) The valid image id, format of img-xxx. +* `img_id` - (Optional, String) The valid image id, format of img-xxx. Note: `img_id` will be replaced with the image corresponding to TKE `cluster_os`. * `instance_charge_type_prepaid_period` - (Optional, Int, ForceNew) The tenancy (time unit is month) of the prepaid instance. NOTE: it only works when instance_charge_type is set to `PREPAID`. Valid values are `1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`, `9`, `10`, `11`, `12`, `24`, `36`. * `instance_charge_type_prepaid_renew_flag` - (Optional, String, ForceNew) Auto renewal flag. Valid values: `NOTIFY_AND_AUTO_RENEW`: notify upon expiration and renew automatically, `NOTIFY_AND_MANUAL_RENEW`: notify upon expiration but do not renew automatically, `DISABLE_NOTIFY_AND_MANUAL_RENEW`: neither notify upon expiration nor renew automatically. Default value: `NOTIFY_AND_MANUAL_RENEW`. If this parameter is specified as `NOTIFY_AND_AUTO_RENEW`, the instance will be automatically renewed on a monthly basis if the account balance is sufficient. NOTE: it only works when instance_charge_type is set to `PREPAID`. * `instance_charge_type` - (Optional, String, ForceNew) The charge type of instance. Valid values are `PREPAID` and `POSTPAID_BY_HOUR`. The default is `POSTPAID_BY_HOUR`. Note: TencentCloud International only supports `POSTPAID_BY_HOUR`, `PREPAID` instance will not terminated after cluster deleted, and may not allow to delete before expired. @@ -1016,3 +1016,11 @@ In addition to all arguments above, the following attributes are exported: * `lan_ip` - LAN IP of the cvm. +## Import + +tke cluster can be imported, e.g. + +``` +$ terraform import tencentcloud_kubernetes_cluster.test cls-xxx +``` + diff --git a/website/docs/r/kubernetes_scale_worker.html.markdown b/website/docs/r/kubernetes_scale_worker.html.markdown index f554d222b8..ec537f6041 100644 --- a/website/docs/r/kubernetes_scale_worker.html.markdown +++ b/website/docs/r/kubernetes_scale_worker.html.markdown @@ -200,3 +200,11 @@ In addition to all arguments above, the following attributes are exported: * `lan_ip` - LAN IP of the cvm. +## Import + +tke scale worker can be imported, e.g. + +``` +$ terraform import tencentcloud_kubernetes_scale_worker.test cls-xxx#ins-xxx +``` +