From 806f5fac255ef3026f2b603eeff020608e6b8e60 Mon Sep 17 00:00:00 2001 From: SevenEarth <391613297@qq.com> Date: Fri, 16 May 2025 17:04:05 +0800 Subject: [PATCH 1/2] add --- .../tke/resource_tc_kubernetes_cluster.go | 277 +++++++++++++++--- ...esource_tc_kubernetes_cluster_extension.go | 2 +- .../services/tke/service_tencentcloud_tke.go | 27 ++ .../docs/r/kubernetes_cluster.html.markdown | 82 +++--- 4 files changed, 305 insertions(+), 83 deletions(-) diff --git a/tencentcloud/services/tke/resource_tc_kubernetes_cluster.go b/tencentcloud/services/tke/resource_tc_kubernetes_cluster.go index 06de30a294..9c06d0aaf3 100644 --- a/tencentcloud/services/tke/resource_tc_kubernetes_cluster.go +++ b/tencentcloud/services/tke/resource_tc_kubernetes_cluster.go @@ -5,9 +5,11 @@ import ( "context" "fmt" "log" + "strings" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors" tkev20180525 "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525" tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common" @@ -974,22 +976,19 @@ func ResourceTencentCloudKubernetesCluster() *schema.Resource { }, "exist_instance": { - Type: schema.TypeList, + Type: schema.TypeSet, Optional: true, - ForceNew: true, - Description: "create tke cluster by existed instances.", + Description: "Create tke cluster by existed instances.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "node_role": { Type: schema.TypeString, Optional: true, - ForceNew: true, - Description: "Role of existed node. value:MASTER_ETCD or WORKER.", + Description: "Role of existed node. Value: MASTER_ETCD or WORKER.", }, "instances_para": { Type: schema.TypeList, Optional: true, - ForceNew: true, MaxItems: 1, Description: "Reinstallation parameters of an existing instance.", Elem: &schema.Resource{ @@ -997,7 +996,6 @@ func ResourceTencentCloudKubernetesCluster() *schema.Resource { "instance_ids": { Type: schema.TypeList, Required: true, - ForceNew: true, Description: "Cluster IDs.", Elem: &schema.Schema{ Type: schema.TypeString, @@ -1006,7 +1004,6 @@ func ResourceTencentCloudKubernetesCluster() *schema.Resource { "security_group_ids": { Type: schema.TypeList, Optional: true, - ForceNew: true, Description: "Security groups to which a CVM instance belongs.", Elem: &schema.Schema{ Type: schema.TypeString, @@ -1015,7 +1012,6 @@ func ResourceTencentCloudKubernetesCluster() *schema.Resource { "password": { Type: schema.TypeString, Optional: true, - ForceNew: true, Sensitive: true, Description: "Password to access, should be set if `key_ids` not set.", ValidateFunc: tccommon.ValidateAsConfigPassword, @@ -1023,7 +1019,6 @@ func ResourceTencentCloudKubernetesCluster() *schema.Resource { "key_ids": { Type: schema.TypeList, Optional: true, - ForceNew: true, Description: "ID list of keys, should be set if `password` not set.", Elem: &schema.Schema{ Type: schema.TypeString, @@ -1032,21 +1027,18 @@ func ResourceTencentCloudKubernetesCluster() *schema.Resource { "enhanced_security_service": { Type: schema.TypeBool, Optional: true, - ForceNew: true, Default: true, Description: "To specify whether to enable cloud security service. Default is TRUE.", }, "enhanced_monitor_service": { Type: schema.TypeBool, Optional: true, - ForceNew: true, Default: true, Description: "To specify whether to enable cloud monitor service. Default is TRUE.", }, "master_config": { Type: schema.TypeList, Optional: true, - ForceNew: true, MaxItems: 1, Description: "Advanced Node Settings. commonly used to attach existing instances.", Elem: &schema.Resource{ @@ -1054,44 +1046,37 @@ func ResourceTencentCloudKubernetesCluster() *schema.Resource { "mount_target": { Type: schema.TypeString, Optional: true, - ForceNew: true, Description: "Mount target. Default is not mounting.", }, "docker_graph_path": { Type: schema.TypeString, Optional: true, - ForceNew: true, Description: "Docker graph path. Default is `/var/lib/docker`.", }, "user_script": { Type: schema.TypeString, Optional: true, - ForceNew: true, Description: "User script encoded in base64, which will be executed after the k8s component runs. The user needs to ensure the script's reentrant and retry logic. The script and its generated log files can be viewed in the node path /data/ccs_userscript/. If the node needs to be initialized before joining the schedule, it can be used in conjunction with the `unschedulable` parameter. After the final initialization of the userScript is completed, add the command \"kubectl uncordon nodename --kubeconfig=/root/.kube/config\" to add the node to the schedule.", }, "unschedulable": { Type: schema.TypeInt, Optional: true, - ForceNew: true, Description: "Set whether the joined nodes participate in scheduling, with a default value of 0, indicating participation in scheduling; Non 0 means not participating in scheduling.", }, "labels": { Type: schema.TypeList, Optional: true, - ForceNew: true, Description: "Node label list.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "name": { Type: schema.TypeString, Required: true, - ForceNew: true, Description: "Name of map.", }, "value": { Type: schema.TypeString, Required: true, - ForceNew: true, Description: "Value of map.", }, }, @@ -1100,7 +1085,6 @@ func ResourceTencentCloudKubernetesCluster() *schema.Resource { "data_disk": { Type: schema.TypeList, Optional: true, - ForceNew: true, MaxItems: 1, Description: "Configurations of data disk.", Elem: &schema.Resource{ @@ -1108,37 +1092,31 @@ func ResourceTencentCloudKubernetesCluster() *schema.Resource { "disk_type": { Type: schema.TypeString, Optional: true, - ForceNew: true, Description: "Types of disk. Valid value: `LOCAL_BASIC`, `LOCAL_SSD`, `CLOUD_BASIC`, `CLOUD_PREMIUM`, `CLOUD_SSD`, `CLOUD_HSSD`, `CLOUD_TSSD` and `CLOUD_BSSD`.", }, "file_system": { Type: schema.TypeString, Optional: true, - ForceNew: true, Description: "File system, e.g. `ext3/ext4/xfs`.", }, "disk_size": { Type: schema.TypeInt, Optional: true, - ForceNew: true, Description: "Volume of disk in GB. Default is `0`.", }, "auto_format_and_mount": { Type: schema.TypeBool, Optional: true, - ForceNew: true, Description: "Indicate whether to auto format and mount or not. Default is `false`.", }, "mount_target": { Type: schema.TypeString, Optional: true, - ForceNew: true, Description: "Mount target.", }, "disk_partition": { Type: schema.TypeString, Optional: true, - ForceNew: true, Description: "The name of the device or partition to mount. NOTE: this argument doesn't support setting in node pool, or will leads to mount error.", }, }, @@ -1147,7 +1125,6 @@ func ResourceTencentCloudKubernetesCluster() *schema.Resource { "extra_args": { Type: schema.TypeList, Optional: true, - ForceNew: true, MaxItems: 1, Description: "Custom parameter information related to the node. This is a white-list parameter.", Elem: &schema.Resource{ @@ -1155,7 +1132,6 @@ func ResourceTencentCloudKubernetesCluster() *schema.Resource { "kubelet": { Type: schema.TypeList, Optional: true, - ForceNew: true, Description: "Kubelet custom parameter. The parameter format is [\"k1=v1\", \"k1=v2\"].", Elem: &schema.Schema{ Type: schema.TypeString, @@ -1167,13 +1143,11 @@ func ResourceTencentCloudKubernetesCluster() *schema.Resource { "desired_pod_number": { Type: schema.TypeInt, Optional: true, - ForceNew: true, Description: "Indicate to set desired pod number in node. valid when the cluster is podCIDR.", }, "gpu_args": { Type: schema.TypeList, Optional: true, - ForceNew: true, MaxItems: 1, Description: "GPU driver parameters.", Elem: &schema.Resource{ @@ -1181,34 +1155,29 @@ func ResourceTencentCloudKubernetesCluster() *schema.Resource { "mig_enable": { Type: schema.TypeBool, Optional: true, - ForceNew: true, Description: "Whether to enable MIG.", }, "driver": { Type: schema.TypeMap, Optional: true, - ForceNew: true, Description: "GPU driver version. Format like: `{ version: String, name: String }`. `version`: Version of GPU driver or CUDA; `name`: Name of GPU driver or CUDA.", ValidateFunc: tccommon.ValidateTkeGpuDriverVersion, }, "cuda": { Type: schema.TypeMap, Optional: true, - ForceNew: true, Description: "CUDA version. Format like: `{ version: String, name: String }`. `version`: Version of GPU driver or CUDA; `name`: Name of GPU driver or CUDA.", ValidateFunc: tccommon.ValidateTkeGpuDriverVersion, }, "cudnn": { Type: schema.TypeMap, Optional: true, - ForceNew: true, Description: "cuDNN version. Format like: `{ version: String, name: String, doc_name: String, dev_name: String }`. `version`: cuDNN version; `name`: cuDNN name; `doc_name`: Doc name of cuDNN; `dev_name`: Dev name of cuDNN.", ValidateFunc: tccommon.ValidateTkeGpuDriverVersion, }, "custom_driver": { Type: schema.TypeMap, Optional: true, - ForceNew: true, Description: "Custom GPU driver. Format like: `{address: String}`. `address`: URL of custom GPU driver address.", }, }, @@ -1217,26 +1186,22 @@ func ResourceTencentCloudKubernetesCluster() *schema.Resource { "taints": { Type: schema.TypeList, Optional: true, - ForceNew: true, Description: "Node taint.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "key": { Type: schema.TypeString, Optional: true, - ForceNew: true, Description: "Key of the taint.", }, "value": { Type: schema.TypeString, Optional: true, - ForceNew: true, Description: "Value of the taint.", }, "effect": { Type: schema.TypeString, Optional: true, - ForceNew: true, Description: "Effect of the taint.", }, }, @@ -1251,7 +1216,6 @@ func ResourceTencentCloudKubernetesCluster() *schema.Resource { "desired_pod_numbers": { Type: schema.TypeList, Optional: true, - ForceNew: true, Description: "Custom mode cluster, you can specify the number of pods for each node. corresponding to the existed_instances_para.instance_ids parameter.", Elem: &schema.Schema{ Type: schema.TypeInt, @@ -2171,6 +2135,237 @@ func resourceTencentCloudKubernetesClusterUpdate(d *schema.ResourceData, meta in } } + if d.HasChange("exist_instance") { + tkeService := TkeService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()} + cvmService := svccvm.NewCvmService(meta.(tccommon.ProviderMeta).GetAPIV3Conn()) + + oldInterface, newInterface := d.GetChange("exist_instance") + oldInstances := oldInterface.(*schema.Set) + newInstances := newInterface.(*schema.Set) + + remove := oldInstances.Difference(newInstances).List() + add := newInstances.Difference(oldInstances).List() + + // scale out first + if len(add) > 0 { + tmpNew := make([]*tkev20180525.ExistedInstancesForNode, 0, len(add)) + instanceIds := make([]*string, 0) + instanceInfo := make([]map[string]interface{}, 0) + for index := range add { + if add[index] != nil { + instance := add[index].(map[string]interface{}) + existedInstance, _ := tkeGetCvmExistInstancesPara(instance) + tmpNew = append(tmpNew, &existedInstance) + + // get all new cvm IDs + if len(existedInstance.ExistedInstancesPara.InstanceIds) > 0 { + dMap := make(map[string]interface{}, 0) + instanceIds = append(instanceIds, existedInstance.ExistedInstancesPara.InstanceIds...) + dMap["instance_ids"] = instanceIds + dMap["node_role"] = existedInstance.NodeRole + instanceInfo = append(instanceInfo, dMap) + } + } + } + + if len(tmpNew) > 0 { + request := tkev20180525.NewScaleOutClusterMasterRequest() + request.ClusterId = &clusterId + request.ExistedInstancesForNode = tmpNew + err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError { + result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseTkeV20180525Client().ScaleOutClusterMasterWithContext(ctx, request) + if e != nil { + return tccommon.RetryError(e) + } else { + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString()) + } + + return nil + }) + + if err != nil { + log.Printf("[CRITAL]%s scale out cluster failed, reason:%+v", logId, err) + return err + } + + // wait for cvm status + err = resource.Retry(10*tccommon.ReadRetryTimeout, func() *resource.RetryError { + result, e := cvmService.DescribeInstanceByFilter(ctx, instanceIds, nil) + if e != nil { + return tccommon.RetryError(e, tccommon.InternalError) + } + + initFlag := true + if result != nil { + for _, item := range result { + if item.InstanceState != nil && *item.InstanceState != "RUNNING" { + initFlag = false + break + } + } + + if initFlag { + return nil + } + } + + return resource.RetryableError(fmt.Errorf("cvm instance status is not RUNNING, retry...")) + }) + + if err != nil { + return err + } + + // wait for tke node init + for _, item := range instanceInfo { + tmpInsIds := item["instance_ids"].([]*string) + nodeRole := item["node_role"].(*string) + err = resource.Retry(10*tccommon.ReadRetryTimeout, func() *resource.RetryError { + result, e := tkeService.DescribeKubernetesClusterMasterAttachmentByIds(ctx, clusterId, tmpInsIds, nodeRole) + if e != nil { + return tccommon.RetryError(e, tccommon.InternalError) + } + + initFlag := true + if result != nil && result.InstanceSet != nil { + for _, item := range result.InstanceSet { + if item.InstanceState != nil && *item.InstanceState != "running" { + initFlag = false + break + } + } + + if initFlag { + return nil + } + } + + return resource.RetryableError(fmt.Errorf("tke master node cvm instance status is not running, retry...")) + }) + + if err != nil { + return err + } + } + + // wait for tke cluster status + err = resource.Retry(10*tccommon.ReadRetryTimeout, func() *resource.RetryError { + result, e := tkeService.DescribeKubernetesClusterById(ctx, clusterId) + if e != nil { + return tccommon.RetryError(e, tccommon.InternalError) + } + + if result == nil { + + } + + if result.ClusterStatus != nil && *result.ClusterStatus == "Running" { + return nil + } + + return resource.RetryableError(fmt.Errorf("tke status is not RUNNING, retry...")) + }) + + if err != nil { + return err + } + + } + } + + // scale in + if len(remove) > 0 { + tmpOld := make([]map[string]interface{}, 0) + for index := range remove { + if remove[index] != nil { + instance := remove[index].(map[string]interface{}) + existedInstance, _ := tkeGetCvmExistInstancesPara(instance) + + insMap := make(map[string]interface{}) + if existedInstance.NodeRole != nil { + insMap["node_role"] = *existedInstance.NodeRole + } + + if len(existedInstance.ExistedInstancesPara.InstanceIds) > 0 { + for _, item := range existedInstance.ExistedInstancesPara.InstanceIds { + if item != nil { + insMap["instance_id"] = *item + } + + tmpOld = append(tmpOld, insMap) + } + } + } + } + + if len(tmpOld) > 0 { + request := tkev20180525.NewScaleInClusterMasterRequest() + request.ClusterId = &clusterId + for _, item := range tmpOld { + tmp := tkev20180525.ScaleInMaster{} + if v, ok := item["node_role"].(string); ok && v != "" { + tmp.NodeRole = &v + } + + if v, ok := item["instance_id"].(string); ok && v != "" { + tmp.InstanceId = &v + } + + tmp.InstanceDeleteMode = helper.String("retain") + request.ScaleInMasters = append(request.ScaleInMasters, &tmp) + } + + err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError { + result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseTkeV20180525Client().ScaleInClusterMasterWithContext(ctx, request) + if e != nil { + if sdkErr, ok := e.(*errors.TencentCloudSDKError); ok { + if sdkErr.GetCode() == "ResourceNotFound" { + return nil + } + + if sdkErr.GetCode() == "InvalidParameter" && strings.Contains(sdkErr.GetMessage(), `is not exist`) { + return nil + } + } + + return tccommon.RetryError(e, tccommon.InternalError) + } else { + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString()) + } + + return nil + }) + + if err != nil { + log.Printf("[CRITAL]%s scale in cluster failed, reason:%+v", logId, err) + return err + } + + // wait for tke cluster status + err = resource.Retry(10*tccommon.ReadRetryTimeout, func() *resource.RetryError { + result, e := tkeService.DescribeKubernetesClusterById(ctx, clusterId) + if e != nil { + return tccommon.RetryError(e, tccommon.InternalError) + } + + if result == nil { + + } + + if result.ClusterStatus != nil && *result.ClusterStatus == "Running" { + return nil + } + + return resource.RetryableError(fmt.Errorf("tke status is not RUNNING, retry...")) + }) + + if err != nil { + return err + } + } + } + } + if err := resourceTencentCloudKubernetesClusterUpdateOnExit(ctx); err != nil { return err } diff --git a/tencentcloud/services/tke/resource_tc_kubernetes_cluster_extension.go b/tencentcloud/services/tke/resource_tc_kubernetes_cluster_extension.go index c1347ead12..cfcdd02494 100644 --- a/tencentcloud/services/tke/resource_tc_kubernetes_cluster_extension.go +++ b/tencentcloud/services/tke/resource_tc_kubernetes_cluster_extension.go @@ -273,7 +273,7 @@ func resourceTencentCloudKubernetesClusterCreatePostFillRequest0(ctx context.Con // ExistedInstancesForNode existInstances := make([]*tke.ExistedInstancesForNode, 0) if instances, ok := d.GetOk("exist_instance"); ok { - instanceList := instances.([]interface{}) + instanceList := instances.(*schema.Set).List() for index := range instanceList { instance := instanceList[index].(map[string]interface{}) existedInstance, _ := tkeGetCvmExistInstancesPara(instance) diff --git a/tencentcloud/services/tke/service_tencentcloud_tke.go b/tencentcloud/services/tke/service_tencentcloud_tke.go index b25aece59c..ca9a9950a2 100644 --- a/tencentcloud/services/tke/service_tencentcloud_tke.go +++ b/tencentcloud/services/tke/service_tencentcloud_tke.go @@ -3761,3 +3761,30 @@ func (me *TkeService) DescribeKubernetesClusterMasterAttachmentById2(ctx context ret = response.Response return } + +func (me *TkeService) DescribeKubernetesClusterMasterAttachmentByIds(ctx context.Context, clusterId string, instanceIds []*string, nodeRole *string) (ret *tke.DescribeClusterInstancesResponseParams, errRet error) { + logId := tccommon.GetLogId(ctx) + + request := tke.NewDescribeClusterInstancesRequest() + request.ClusterId = helper.String(clusterId) + request.InstanceIds = instanceIds + request.InstanceRole = nodeRole + + defer func() { + if errRet != nil { + log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n", logId, request.GetAction(), request.ToJsonString(), errRet.Error()) + } + }() + + ratelimit.Check(request.GetAction()) + response, err := me.client.UseTkeV20180525Client().DescribeClusterInstances(request) + if err != nil { + errRet = err + return + } + + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString()) + + ret = response.Response + return +} diff --git a/website/docs/r/kubernetes_cluster.html.markdown b/website/docs/r/kubernetes_cluster.html.markdown index 2006b1eaa1..c515faef95 100644 --- a/website/docs/r/kubernetes_cluster.html.markdown +++ b/website/docs/r/kubernetes_cluster.html.markdown @@ -940,7 +940,7 @@ The following arguments are supported: * `enable_customized_pod_cidr` - (Optional, Bool) Whether to enable the custom mode of node podCIDR size. Default is false. * `eni_subnet_ids` - (Optional, List: [`String`]) Subnet Ids for cluster with VPC-CNI network mode. This field can only set when field `network_type` is 'VPC-CNI'. `eni_subnet_ids` can not empty once be set. * `event_persistence` - (Optional, List) Specify cluster Event Persistence config. NOTE: Please make sure your TKE CamRole have permission to access CLS service. -* `exist_instance` - (Optional, List, ForceNew) create tke cluster by existed instances. +* `exist_instance` - (Optional, Set) Create tke cluster by existed instances. * `extension_addon` - (Optional, List) Information of the add-on to be installed. * `extra_args` - (Optional, List: [`String`], ForceNew) Custom parameter information related to the node. * `globe_desired_pod_num` - (Optional, Int, ForceNew) Indicate to set desired pod number in node. valid when enable_customized_pod_cidr=true, and it takes effect for all nodes. @@ -990,6 +990,15 @@ The `cluster_extra_args` object supports the following: The `data_disk` object of `master_config` supports the following: +* `auto_format_and_mount` - (Optional, Bool) Indicate whether to auto format and mount or not. Default is `false`. +* `disk_partition` - (Optional, String) The name of the device or partition to mount. NOTE: this argument doesn't support setting in node pool, or will leads to mount error. +* `disk_size` - (Optional, Int) Volume of disk in GB. Default is `0`. +* `disk_type` - (Optional, String) Types of disk. Valid value: `LOCAL_BASIC`, `LOCAL_SSD`, `CLOUD_BASIC`, `CLOUD_PREMIUM`, `CLOUD_SSD`, `CLOUD_HSSD`, `CLOUD_TSSD` and `CLOUD_BSSD`. +* `file_system` - (Optional, String) File system, e.g. `ext3/ext4/xfs`. +* `mount_target` - (Optional, String) Mount target. + +The `data_disk` object of `master_config` supports the following: + * `auto_format_and_mount` - (Optional, Bool, ForceNew) Indicate whether to auto format and mount or not. Default is `false`. * `disk_partition` - (Optional, String, ForceNew) The name of the device or partition to mount. * `disk_size` - (Optional, Int, ForceNew) Volume of disk in GB. Default is `0`. @@ -1000,15 +1009,6 @@ The `data_disk` object of `master_config` supports the following: * `mount_target` - (Optional, String, ForceNew) Mount target. * `snapshot_id` - (Optional, String, ForceNew) Data disk snapshot ID. -The `data_disk` object of `master_config` supports the following: - -* `auto_format_and_mount` - (Optional, Bool, ForceNew) Indicate whether to auto format and mount or not. Default is `false`. -* `disk_partition` - (Optional, String, ForceNew) The name of the device or partition to mount. NOTE: this argument doesn't support setting in node pool, or will leads to mount error. -* `disk_size` - (Optional, Int, ForceNew) Volume of disk in GB. Default is `0`. -* `disk_type` - (Optional, String, ForceNew) Types of disk. Valid value: `LOCAL_BASIC`, `LOCAL_SSD`, `CLOUD_BASIC`, `CLOUD_PREMIUM`, `CLOUD_SSD`, `CLOUD_HSSD`, `CLOUD_TSSD` and `CLOUD_BSSD`. -* `file_system` - (Optional, String, ForceNew) File system, e.g. `ext3/ext4/xfs`. -* `mount_target` - (Optional, String, ForceNew) Mount target. - The `data_disk` object of `worker_config` supports the following: * `auto_format_and_mount` - (Optional, Bool, ForceNew) Indicate whether to auto format and mount or not. Default is `false`. @@ -1030,9 +1030,9 @@ The `event_persistence` object supports the following: The `exist_instance` object supports the following: -* `desired_pod_numbers` - (Optional, List, ForceNew) Custom mode cluster, you can specify the number of pods for each node. corresponding to the existed_instances_para.instance_ids parameter. -* `instances_para` - (Optional, List, ForceNew) Reinstallation parameters of an existing instance. -* `node_role` - (Optional, String, ForceNew) Role of existed node. value:MASTER_ETCD or WORKER. +* `desired_pod_numbers` - (Optional, List) Custom mode cluster, you can specify the number of pods for each node. corresponding to the existed_instances_para.instance_ids parameter. +* `instances_para` - (Optional, List) Reinstallation parameters of an existing instance. +* `node_role` - (Optional, String) Role of existed node. Value: MASTER_ETCD or WORKER. The `extension_addon` object supports the following: @@ -1041,30 +1041,30 @@ The `extension_addon` object supports the following: The `extra_args` object of `master_config` supports the following: -* `kubelet` - (Optional, List, ForceNew) Kubelet custom parameter. The parameter format is ["k1=v1", "k1=v2"]. +* `kubelet` - (Optional, List) Kubelet custom parameter. The parameter format is ["k1=v1", "k1=v2"]. The `gpu_args` object of `master_config` supports the following: -* `cuda` - (Optional, Map, ForceNew) CUDA version. Format like: `{ version: String, name: String }`. `version`: Version of GPU driver or CUDA; `name`: Name of GPU driver or CUDA. -* `cudnn` - (Optional, Map, ForceNew) cuDNN version. Format like: `{ version: String, name: String, doc_name: String, dev_name: String }`. `version`: cuDNN version; `name`: cuDNN name; `doc_name`: Doc name of cuDNN; `dev_name`: Dev name of cuDNN. -* `custom_driver` - (Optional, Map, ForceNew) Custom GPU driver. Format like: `{address: String}`. `address`: URL of custom GPU driver address. -* `driver` - (Optional, Map, ForceNew) 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, ForceNew) Whether to enable MIG. +* `cuda` - (Optional, Map) CUDA version. Format like: `{ version: String, name: String }`. `version`: Version of GPU driver or CUDA; `name`: Name of GPU driver or CUDA. +* `cudnn` - (Optional, Map) cuDNN version. Format like: `{ version: String, name: String, doc_name: String, dev_name: String }`. `version`: cuDNN version; `name`: cuDNN name; `doc_name`: Doc name of cuDNN; `dev_name`: Dev name of cuDNN. +* `custom_driver` - (Optional, Map) Custom GPU driver. Format like: `{address: String}`. `address`: URL of custom GPU driver address. +* `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 `instances_para` object of `exist_instance` supports the following: -* `instance_ids` - (Required, List, ForceNew) Cluster IDs. -* `enhanced_monitor_service` - (Optional, Bool, ForceNew) To specify whether to enable cloud monitor service. Default is TRUE. -* `enhanced_security_service` - (Optional, Bool, ForceNew) To specify whether to enable cloud security service. Default is TRUE. -* `key_ids` - (Optional, List, ForceNew) ID list of keys, should be set if `password` not set. -* `master_config` - (Optional, List, ForceNew) Advanced Node Settings. commonly used to attach existing instances. -* `password` - (Optional, String, ForceNew) Password to access, should be set if `key_ids` not set. -* `security_group_ids` - (Optional, List, ForceNew) Security groups to which a CVM instance belongs. +* `instance_ids` - (Required, List) Cluster IDs. +* `enhanced_monitor_service` - (Optional, Bool) To specify whether to enable cloud monitor service. Default is TRUE. +* `enhanced_security_service` - (Optional, Bool) To specify whether to enable cloud security service. Default is TRUE. +* `key_ids` - (Optional, List) ID list of keys, should be set if `password` not set. +* `master_config` - (Optional, List) Advanced Node Settings. commonly used to attach existing instances. +* `password` - (Optional, String) Password to access, should be set if `key_ids` not set. +* `security_group_ids` - (Optional, List) Security groups to which a CVM instance belongs. The `labels` object of `master_config` supports the following: -* `name` - (Required, String, ForceNew) Name of map. -* `value` - (Required, String, ForceNew) Value of map. +* `name` - (Required, String) Name of map. +* `value` - (Required, String) Value of map. The `log_agent` object supports the following: @@ -1073,16 +1073,16 @@ The `log_agent` object supports the following: The `master_config` object of `instances_para` supports the following: -* `data_disk` - (Optional, List, ForceNew) Configurations of data disk. -* `desired_pod_number` - (Optional, Int, ForceNew) Indicate to set desired pod number in node. valid when the cluster is podCIDR. -* `docker_graph_path` - (Optional, String, ForceNew) Docker graph path. Default is `/var/lib/docker`. -* `extra_args` - (Optional, List, ForceNew) Custom parameter information related to the node. This is a white-list parameter. -* `gpu_args` - (Optional, List, ForceNew) GPU driver parameters. -* `labels` - (Optional, List, ForceNew) Node label list. -* `mount_target` - (Optional, String, ForceNew) Mount target. Default is not mounting. -* `taints` - (Optional, List, ForceNew) Node taint. -* `unschedulable` - (Optional, Int, ForceNew) Set whether the joined nodes participate in scheduling, with a default value of 0, indicating participation in scheduling; Non 0 means not participating in scheduling. -* `user_script` - (Optional, String, ForceNew) User script encoded in base64, which will be executed after the k8s component runs. The user needs to ensure the script's reentrant and retry logic. The script and its generated log files can be viewed in the node path /data/ccs_userscript/. If the node needs to be initialized before joining the schedule, it can be used in conjunction with the `unschedulable` parameter. After the final initialization of the userScript is completed, add the command "kubectl uncordon nodename --kubeconfig=/root/.kube/config" to add the node to the schedule. +* `data_disk` - (Optional, List) Configurations of data disk. +* `desired_pod_number` - (Optional, Int) Indicate to set desired pod number in node. valid when the cluster is podCIDR. +* `docker_graph_path` - (Optional, String) Docker graph path. Default is `/var/lib/docker`. +* `extra_args` - (Optional, List) Custom parameter information related to the node. This is a white-list parameter. +* `gpu_args` - (Optional, List) GPU driver parameters. +* `labels` - (Optional, List) Node label list. +* `mount_target` - (Optional, String) Mount target. Default is not mounting. +* `taints` - (Optional, List) Node taint. +* `unschedulable` - (Optional, Int) Set whether the joined nodes participate in scheduling, with a default value of 0, indicating participation in scheduling; Non 0 means not participating in scheduling. +* `user_script` - (Optional, String) User script encoded in base64, which will be executed after the k8s component runs. The user needs to ensure the script's reentrant and retry logic. The script and its generated log files can be viewed in the node path /data/ccs_userscript/. If the node needs to be initialized before joining the schedule, it can be used in conjunction with the `unschedulable` parameter. After the final initialization of the userScript is completed, add the command "kubectl uncordon nodename --kubeconfig=/root/.kube/config" to add the node to the schedule. The `master_config` object supports the following: @@ -1134,9 +1134,9 @@ The `resource_delete_options` object supports the following: The `taints` object of `master_config` supports the following: -* `effect` - (Optional, String, ForceNew) Effect of the taint. -* `key` - (Optional, String, ForceNew) Key of the taint. -* `value` - (Optional, String, ForceNew) Value of the taint. +* `effect` - (Optional, String) Effect of the taint. +* `key` - (Optional, String) Key of the taint. +* `value` - (Optional, String) Value of the taint. The `worker_config` object supports the following: From 89c2be72e7e83ef704c010c53e17881455736de4 Mon Sep 17 00:00:00 2001 From: SevenEarth <391613297@qq.com> Date: Fri, 16 May 2025 17:06:22 +0800 Subject: [PATCH 2/2] add --- .changelog/3360.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/3360.txt diff --git a/.changelog/3360.txt b/.changelog/3360.txt new file mode 100644 index 0000000000..1d618b75be --- /dev/null +++ b/.changelog/3360.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/tencentcloud_kubernetes_cluster: `exist_instance` support update +``` \ No newline at end of file