From 4cf378f2d6c72df205dcb0a32476ca41009cd1bc Mon Sep 17 00:00:00 2001 From: SevenEarth <391613297@qq.com> Date: Wed, 13 Nov 2024 19:21:39 +0800 Subject: [PATCH 1/3] add --- .../tke/resource_tc_kubernetes_cluster.go | 242 ++++++++++++++++++ ...esource_tc_kubernetes_cluster_extension.go | 217 +++++++++++++++- ...tes_cluster_master_attachment_extension.go | 2 +- 3 files changed, 451 insertions(+), 10 deletions(-) diff --git a/tencentcloud/services/tke/resource_tc_kubernetes_cluster.go b/tencentcloud/services/tke/resource_tc_kubernetes_cluster.go index 054f958e8d..e52b3975eb 100644 --- a/tencentcloud/services/tke/resource_tc_kubernetes_cluster.go +++ b/tencentcloud/services/tke/resource_tc_kubernetes_cluster.go @@ -1003,6 +1003,248 @@ func ResourceTencentCloudKubernetesCluster() *schema.Resource { Type: schema.TypeString, }, }, + "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, + }, + }, + "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, + }, + "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, + }, + }, + "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{ + Schema: map[string]*schema.Schema{ + "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.", + }, + }, + }, + }, + "data_disk": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + MaxItems: 1, + Description: "Configurations of data disk.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "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.", + }, + }, + }, + }, + "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{ + Schema: map[string]*schema.Schema{ + "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, + }, + }, + }, + }, + }, + "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{ + Schema: map[string]*schema.Schema{ + "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.", + }, + }, + }, + }, + "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.", + }, + }, + }, + }, + }, + }, + }, }, }, }, diff --git a/tencentcloud/services/tke/resource_tc_kubernetes_cluster_extension.go b/tencentcloud/services/tke/resource_tc_kubernetes_cluster_extension.go index 238bf9f8f0..6b170d2301 100644 --- a/tencentcloud/services/tke/resource_tc_kubernetes_cluster_extension.go +++ b/tencentcloud/services/tke/resource_tc_kubernetes_cluster_extension.go @@ -1989,21 +1989,224 @@ func tkeGetCvmRunInstancesPara(dMap map[string]interface{}, meta interface{}, } func tkeGetCvmExistInstancesPara(dMap map[string]interface{}) (tke.ExistedInstancesForNode, error) { - inst := tke.ExistedInstancesForNode{} + if temp, ok := dMap["node_role"]; ok { + nodeRole := temp.(string) + inst.NodeRole = &nodeRole + } if temp, ok := dMap["instances_para"]; ok { paras := temp.([]interface{}) if len(paras) > 0 { paraMap := paras[0].(map[string]interface{}) - instanceIds := paraMap["instance_ids"].([]interface{}) inst.ExistedInstancesPara = &tke.ExistedInstancesPara{} - inst.ExistedInstancesPara.InstanceIds = make([]*string, 0) - for _, v := range instanceIds { - inst.ExistedInstancesPara.InstanceIds = append(inst.ExistedInstancesPara.InstanceIds, helper.String(v.(string))) + loginSettings := &tke.LoginSettings{} + enhancedService := &tke.EnhancedService{} + + if v, ok := paraMap["instance_ids"]; ok && len(v.([]interface{})) > 0 { + insIDs := v.([]interface{}) + inst.ExistedInstancesPara.InstanceIds = make([]*string, 0, len(insIDs)) + for _, v := range insIDs { + inst.ExistedInstancesPara.InstanceIds = append(inst.ExistedInstancesPara.InstanceIds, helper.String(v.(string))) + } + } + + if v, ok := paraMap["security_group_ids"]; ok && len(v.([]interface{})) > 0 { + sgIds := v.([]interface{}) + inst.ExistedInstancesPara.SecurityGroupIds = make([]*string, 0, len(sgIds)) + for i := range sgIds { + sgId := sgIds[i].(string) + inst.ExistedInstancesPara.SecurityGroupIds = append(inst.ExistedInstancesPara.SecurityGroupIds, &sgId) + } + } + + if v, ok := paraMap["password"]; ok { + loginSettings.Password = helper.String(v.(string)) + inst.ExistedInstancesPara.LoginSettings = loginSettings + } + + if v, ok := paraMap["key_ids"]; ok && len(v.([]interface{})) > 0 { + keyIds := v.([]interface{}) + loginSettings.KeyIds = make([]*string, 0, len(keyIds)) + for i := range keyIds { + keyId := keyIds[i].(string) + loginSettings.KeyIds = append(loginSettings.KeyIds, &keyId) + } + + inst.ExistedInstancesPara.LoginSettings = loginSettings + } + + if v, ok := paraMap["enhanced_security_service"]; ok { + enhancedService.SecurityService = &tke.RunSecurityServiceEnabled{Enabled: helper.Bool(v.(bool))} + inst.ExistedInstancesPara.EnhancedService = enhancedService + } + + if v, ok := paraMap["enhanced_monitor_service"]; ok { + enhancedService.MonitorService = &tke.RunMonitorServiceEnabled{Enabled: helper.Bool(v.(bool))} + inst.ExistedInstancesPara.EnhancedService = enhancedService + } + + if v, ok := paraMap["master_config"]; ok && len(v.([]interface{})) > 0 { + for _, item := range v.([]interface{}) { + instanceAdvancedSettingsOverridesMap := item.(map[string]interface{}) + instanceAdvancedSettings := tke.InstanceAdvancedSettings{} + if v, ok := instanceAdvancedSettingsOverridesMap["mount_target"]; ok { + instanceAdvancedSettings.MountTarget = helper.String(v.(string)) + } + + if v, ok := instanceAdvancedSettingsOverridesMap["docker_graph_path"]; ok { + instanceAdvancedSettings.DockerGraphPath = helper.String(v.(string)) + } + + if v, ok := instanceAdvancedSettingsOverridesMap["user_script"]; ok { + instanceAdvancedSettings.UserScript = helper.String(v.(string)) + } + + if v, ok := instanceAdvancedSettingsOverridesMap["unschedulable"]; ok { + instanceAdvancedSettings.Unschedulable = helper.IntInt64(v.(int)) + } + + if v, ok := instanceAdvancedSettingsOverridesMap["labels"]; ok && len(v.([]interface{})) > 0 { + for _, item := range v.([]interface{}) { + labelsMap := item.(map[string]interface{}) + labels := tke.Label{} + if v, ok := labelsMap["name"]; ok { + labels.Name = helper.String(v.(string)) + } + + if v, ok := labelsMap["value"]; ok { + labels.Value = helper.String(v.(string)) + } + + instanceAdvancedSettings.Labels = append(instanceAdvancedSettings.Labels, &labels) + } + } + + if v, ok := instanceAdvancedSettingsOverridesMap["data_disk"]; ok && len(v.([]interface{})) > 0 { + for _, item := range v.([]interface{}) { + dataDisksMap := item.(map[string]interface{}) + dataDisk := tke.DataDisk{} + if v, ok := dataDisksMap["disk_type"]; ok { + dataDisk.DiskType = helper.String(v.(string)) + } + + if v, ok := dataDisksMap["file_system"]; ok { + dataDisk.FileSystem = helper.String(v.(string)) + } + + if v, ok := dataDisksMap["disk_size"]; ok { + dataDisk.DiskSize = helper.IntInt64(v.(int)) + } + + if v, ok := dataDisksMap["auto_format_and_mount"]; ok { + dataDisk.AutoFormatAndMount = helper.Bool(v.(bool)) + } + + if v, ok := dataDisksMap["mount_target"]; ok { + dataDisk.MountTarget = helper.String(v.(string)) + } + + if v, ok := dataDisksMap["disk_partition"]; ok { + dataDisk.DiskPartition = helper.String(v.(string)) + } + + instanceAdvancedSettings.DataDisks = append(instanceAdvancedSettings.DataDisks, &dataDisk) + } + } + + if v, ok := instanceAdvancedSettingsOverridesMap["extra_args"]; ok && len(v.([]interface{})) > 0 { + for _, item := range v.([]interface{}) { + extraArgsMap := item.(map[string]interface{}) + args := tke.InstanceExtraArgs{} + if v, ok := extraArgsMap["kubelet"]; ok { + args.Kubelet = helper.InterfacesStringsPoint(v.([]interface{})) + } + + instanceAdvancedSettings.ExtraArgs = &args + } + } + + if v, ok := instanceAdvancedSettingsOverridesMap["desired_pod_number"]; ok { + instanceAdvancedSettings.DesiredPodNumber = helper.IntInt64(v.(int)) + } + + if v, ok := instanceAdvancedSettingsOverridesMap["gpu_args"]; ok && len(v.([]interface{})) > 0 { + gpuArgs := v.([]interface{})[0].(map[string]interface{}) + + var ( + migEnable = gpuArgs["mig_enable"].(bool) + driver = gpuArgs["driver"].(map[string]interface{}) + cuda = gpuArgs["cuda"].(map[string]interface{}) + cudnn = gpuArgs["cudnn"].(map[string]interface{}) + customDriver = gpuArgs["custom_driver"].(map[string]interface{}) + ) + + tkeGpuArgs := tke.GPUArgs{} + tkeGpuArgs.MIGEnable = &migEnable + if len(driver) > 0 { + tkeGpuArgs.Driver = &tke.DriverVersion{ + Version: helper.String(driver["version"].(string)), + Name: helper.String(driver["name"].(string)), + } + } + + if len(cuda) > 0 { + tkeGpuArgs.CUDA = &tke.DriverVersion{ + Version: helper.String(cuda["version"].(string)), + Name: helper.String(cuda["name"].(string)), + } + } + + if len(cudnn) > 0 { + tkeGpuArgs.CUDNN = &tke.CUDNN{ + Version: helper.String(cudnn["version"].(string)), + Name: helper.String(cudnn["name"].(string)), + } + + if cudnn["doc_name"] != nil { + tkeGpuArgs.CUDNN.DocName = helper.String(cudnn["doc_name"].(string)) + } + + if cudnn["dev_name"] != nil { + tkeGpuArgs.CUDNN.DevName = helper.String(cudnn["dev_name"].(string)) + } + } + + if len(customDriver) > 0 { + tkeGpuArgs.CustomDriver = &tke.CustomDriver{ + Address: helper.String(customDriver["address"].(string)), + } + } + + instanceAdvancedSettings.GPUArgs = &tkeGpuArgs + } + + if v, ok := instanceAdvancedSettingsOverridesMap["taints"]; ok && len(v.([]interface{})) > 0 { + for _, item := range v.([]interface{}) { + taintsMap := item.(map[string]interface{}) + taint := tke.Taint{} + if v, ok := taintsMap["key"]; ok { + taint.Key = helper.String(v.(string)) + } + + if v, ok := taintsMap["value"]; ok { + taint.Value = helper.String(v.(string)) + } + + if v, ok := taintsMap["effect"]; ok { + taint.Effect = helper.String(v.(string)) + } + + instanceAdvancedSettings.Taints = append(instanceAdvancedSettings.Taints, &taint) + } + } + + inst.InstanceAdvancedSettingsOverride = &instanceAdvancedSettings + } } } } + if temp, ok := dMap["desired_pod_numbers"]; ok { inst.DesiredPodNumbers = make([]*int64, 0) podNums := temp.([]interface{}) @@ -2011,10 +2214,6 @@ func tkeGetCvmExistInstancesPara(dMap map[string]interface{}) (tke.ExistedInstan inst.DesiredPodNumbers = append(inst.DesiredPodNumbers, helper.Int64(int64(v.(int)))) } } - if temp, ok := dMap["node_role"]; ok { - nodeRole := temp.(string) - inst.NodeRole = &nodeRole - } return inst, nil } diff --git a/tencentcloud/services/tke/resource_tc_kubernetes_cluster_master_attachment_extension.go b/tencentcloud/services/tke/resource_tc_kubernetes_cluster_master_attachment_extension.go index 3507107643..a958a0356f 100644 --- a/tencentcloud/services/tke/resource_tc_kubernetes_cluster_master_attachment_extension.go +++ b/tencentcloud/services/tke/resource_tc_kubernetes_cluster_master_attachment_extension.go @@ -165,7 +165,7 @@ func resourceTencentCloudKubernetesClusterMasterAttachmentCreatePostFillRequest0 } } - if v, ok := d.GetOkExists("desired_pod_number"); ok { + if v, ok := instanceAdvancedSettingsOverridesMap["desired_pod_number"]; ok { instanceAdvancedSettings.DesiredPodNumber = helper.IntInt64(v.(int)) } From 1d7c7b4e6ef62a1a1c3249dfa31e5df87e69a491 Mon Sep 17 00:00:00 2001 From: SevenEarth <391613297@qq.com> Date: Thu, 14 Nov 2024 11:03:07 +0800 Subject: [PATCH 2/3] add --- .../tke/resource_tc_kubernetes_cluster.md | 92 +++++++++------ .../docs/r/kubernetes_cluster.html.markdown | 110 +++++++++++++++--- 2 files changed, 151 insertions(+), 51 deletions(-) diff --git a/tencentcloud/services/tke/resource_tc_kubernetes_cluster.md b/tencentcloud/services/tke/resource_tc_kubernetes_cluster.md index d6e43ee1e1..e2e7983d61 100644 --- a/tencentcloud/services/tke/resource_tc_kubernetes_cluster.md +++ b/tencentcloud/services/tke/resource_tc_kubernetes_cluster.md @@ -135,7 +135,6 @@ resource "tencentcloud_kubernetes_cluster" "example" { "test2" = "test2", } } - ``` Create an empty cluster with a node pool @@ -261,7 +260,6 @@ resource "tencentcloud_kubernetes_node_pool" "example" { ] } } - ```` Create a cluster with a node pool and open the network access with cluster endpoint @@ -715,17 +713,16 @@ variable "default_instance_type" { } resource "tencentcloud_kubernetes_cluster" "managed_cluster" { - vpc_id = var.vpc - cluster_max_pod_num = 32 - cluster_name = "test" - cluster_desc = "test cluster desc" - cluster_max_service_num = 256 - cluster_internet = true - # managed_cluster_internet_security_policies = ["3.3.3.3", "1.1.1.1"] - cluster_deploy_type = "MANAGED_CLUSTER" - network_type = "VPC-CNI" - eni_subnet_ids = ["subnet-bk1etlyu"] - service_cidr = "10.1.0.0/24" + vpc_id = var.vpc + cluster_max_pod_num = 32 + cluster_name = "test" + cluster_desc = "test cluster desc" + cluster_max_service_num = 256 + cluster_internet = true + cluster_deploy_type = "MANAGED_CLUSTER" + network_type = "VPC-CNI" + eni_subnet_ids = ["subnet-bk1etlyu"] + service_cidr = "10.1.0.0/24" worker_config { count = 1 @@ -746,8 +743,8 @@ resource "tencentcloud_kubernetes_cluster" "managed_cluster" { 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" + # password = "ZZXXccvv1212" // Optional, should be set if key_ids not set. } labels = { @@ -783,30 +780,57 @@ resource "tencentcloud_kubernetes_cluster" "managed_cluster" { ``` Create a CDC scenario cluster + ``` resource "tencentcloud_kubernetes_cluster" "cdc_cluster" { - cdc_id = "cluster-xxxxx" - vpc_id = "vpc-xxxxx" - cluster_cidr = "192.168.0.0/16" - cluster_max_pod_num = 64 - cluster_name = "test-cdc" - cluster_desc = "test cluster desc" - cluster_max_service_num = 1024 - cluster_version = "1.30.0" - - cluster_os = "tlinux3.1x86_64" - cluster_level = "L20" - cluster_deploy_type = "INDEPENDENT_CLUSTER" - - container_runtime = "containerd" - runtime_version = "1.6.9" - pre_start_user_script = "aXB0YWJsZXMgLUEgSU5QVVQgLXAgdGNwIC1zIDE2OS4yNTQuMC4wLzE5IC0tdGNwLWZsYWdzIFNZTixSU1QgU1lOIC1qIFRDUE1TUyAtLXNldC1tc3MgMTE2MAppcHRhYmxlcyAtQSBPVVRQVVQgLXAgdGNwIC1kIDE2OS4yNTQuMC4wLzE5IC0tdGNwLWZsYWdzIFNZTixSU1QgU1lOIC1qIFRDUE1TUyAtLXNldC1tc3MgMTE2MAoKZWNobyAnCmlwdGFibGVzIC1BIElOUFVUIC1wIHRjcCAtcyAxNjkuMjU0LjAuMC8xOSAtLXRjcC1mbGFncyBTWU4sUlNUIFNZTiAtaiBUQ1BNU1MgLS1zZXQtbXNzIDExNjAKaXB0YWJsZXMgLUEgT1VUUFVUIC1wIHRjcCAtZCAxNjkuMjU0LjAuMC8xOSAtLXRjcC1mbGFncyBTWU4sUlNUIFNZTiAtaiBUQ1BNU1MgLS1zZXQtbXNzIDExNjAKJyA+PiAvZXRjL3JjLmQvcmMubG9jYWw=" - exist_instance { - node_role = "MASTER_ETCD" - instances_para { - instance_ids = ["ins-eeijdk16", "ins-84ku5rba", "ins-8oa3im2s"] + cdc_id = "cluster-262n63e8" + vpc_id = "vpc-0m6078eb" + cluster_cidr = "192.168.0.0/16" + cluster_max_pod_num = 64 + cluster_name = "test-cdc" + cluster_desc = "test cluster desc" + cluster_max_service_num = 1024 + cluster_version = "1.30.0" + cluster_os = "tlinux3.1x86_64" + cluster_level = "L20" + cluster_deploy_type = "INDEPENDENT_CLUSTER" + container_runtime = "containerd" + runtime_version = "1.6.9" + pre_start_user_script = "aXB0YWJsZXMgLUEgSU5QVVQgLXAgdGNwIC1zIDE2OS4yNTQuMC4wLzE5IC0tdGNwLWZsYWdzIFNZTixSU1QgU1lOIC1qIFRDUE1TUyAtLXNldC1tc3MgMTE2MAppcHRhYmxlcyAtQSBPVVRQVVQgLXAgdGNwIC1kIDE2OS4yNTQuMC4wLzE5IC0tdGNwLWZsYWdzIFNZTixSU1QgU1lOIC1qIFRDUE1TUyAtLXNldC1tc3MgMTE2MAoKZWNobyAnCmlwdGFibGVzIC1BIElOUFVUIC1wIHRjcCAtcyAxNjkuMjU0LjAuMC8xOSAtLXRjcC1mbGFncyBTWU4sUlNUIFNZTiAtaiBUQ1BNU1MgLS1zZXQtbXNzIDExNjAKaXB0YWJsZXMgLUEgT1VUUFVUIC1wIHRjcCAtZCAxNjkuMjU0LjAuMC8xOSAtLXRjcC1mbGFncyBTWU4sUlNUIFNZTiAtaiBUQ1BNU1MgLS1zZXQtbXNzIDExNjAKJyA+PiAvZXRjL3JjLmQvcmMubG9jYWw=" + instance_delete_mode = "retain" + exist_instance { + node_role = "MASTER_ETCD" + instances_para { + instance_ids = ["ins-mam0c7lw", "ins-quvwayve", "ins-qbffk8iw"] + enhanced_security_service = true + enhanced_monitor_service = true + password = "Password@123" + security_group_ids = ["sg-hjs685q9"] + master_config { + mount_target = "/var/data" + docker_graph_path = "/var/lib/containerd" + unschedulable = 0 + labels { + name = "key" + value = "value" + } + data_disk { + file_system = "ext4" + auto_format_and_mount = true + mount_target = "/var/data" + disk_partition = "/dev/vdb" } + extra_args { + kubelet = ["root-dir=/root"] + } + taints { + key = "key" + value = "value" + effect = "NoSchedule" + } + } } + } } ``` diff --git a/website/docs/r/kubernetes_cluster.html.markdown b/website/docs/r/kubernetes_cluster.html.markdown index 07edbc6348..521619cc18 100644 --- a/website/docs/r/kubernetes_cluster.html.markdown +++ b/website/docs/r/kubernetes_cluster.html.markdown @@ -730,11 +730,10 @@ resource "tencentcloud_kubernetes_cluster" "managed_cluster" { cluster_desc = "test cluster desc" cluster_max_service_num = 256 cluster_internet = true - # managed_cluster_internet_security_policies = ["3.3.3.3", "1.1.1.1"] - cluster_deploy_type = "MANAGED_CLUSTER" - network_type = "VPC-CNI" - eni_subnet_ids = ["subnet-bk1etlyu"] - service_cidr = "10.1.0.0/24" + cluster_deploy_type = "MANAGED_CLUSTER" + network_type = "VPC-CNI" + eni_subnet_ids = ["subnet-bk1etlyu"] + service_cidr = "10.1.0.0/24" worker_config { count = 1 @@ -755,8 +754,8 @@ resource "tencentcloud_kubernetes_cluster" "managed_cluster" { enhanced_security_service = false enhanced_monitor_service = false user_data = "dGVzdA==" + key_ids = "skey-11112222" # password = "ZZXXccvv1212" // Optional, should be set if key_ids not set. - key_ids = "skey-11112222" } labels = { @@ -795,26 +794,52 @@ resource "tencentcloud_kubernetes_cluster" "managed_cluster" { ```hcl resource "tencentcloud_kubernetes_cluster" "cdc_cluster" { - cdc_id = "cluster-xxxxx" - vpc_id = "vpc-xxxxx" + cdc_id = "cluster-262n63e8" + vpc_id = "vpc-0m6078eb" cluster_cidr = "192.168.0.0/16" cluster_max_pod_num = 64 cluster_name = "test-cdc" cluster_desc = "test cluster desc" cluster_max_service_num = 1024 cluster_version = "1.30.0" - - cluster_os = "tlinux3.1x86_64" - cluster_level = "L20" - cluster_deploy_type = "INDEPENDENT_CLUSTER" - - container_runtime = "containerd" - runtime_version = "1.6.9" - pre_start_user_script = "aXB0YWJsZXMgLUEgSU5QVVQgLXAgdGNwIC1zIDE2OS4yNTQuMC4wLzE5IC0tdGNwLWZsYWdzIFNZTixSU1QgU1lOIC1qIFRDUE1TUyAtLXNldC1tc3MgMTE2MAppcHRhYmxlcyAtQSBPVVRQVVQgLXAgdGNwIC1kIDE2OS4yNTQuMC4wLzE5IC0tdGNwLWZsYWdzIFNZTixSU1QgU1lOIC1qIFRDUE1TUyAtLXNldC1tc3MgMTE2MAoKZWNobyAnCmlwdGFibGVzIC1BIElOUFVUIC1wIHRjcCAtcyAxNjkuMjU0LjAuMC8xOSAtLXRjcC1mbGFncyBTWU4sUlNUIFNZTiAtaiBUQ1BNU1MgLS1zZXQtbXNzIDExNjAKaXB0YWJsZXMgLUEgT1VUUFVUIC1wIHRjcCAtZCAxNjkuMjU0LjAuMC8xOSAtLXRjcC1mbGFncyBTWU4sUlNUIFNZTiAtaiBUQ1BNU1MgLS1zZXQtbXNzIDExNjAKJyA+PiAvZXRjL3JjLmQvcmMubG9jYWw=" + cluster_os = "tlinux3.1x86_64" + cluster_level = "L20" + cluster_deploy_type = "INDEPENDENT_CLUSTER" + container_runtime = "containerd" + runtime_version = "1.6.9" + pre_start_user_script = "aXB0YWJsZXMgLUEgSU5QVVQgLXAgdGNwIC1zIDE2OS4yNTQuMC4wLzE5IC0tdGNwLWZsYWdzIFNZTixSU1QgU1lOIC1qIFRDUE1TUyAtLXNldC1tc3MgMTE2MAppcHRhYmxlcyAtQSBPVVRQVVQgLXAgdGNwIC1kIDE2OS4yNTQuMC4wLzE5IC0tdGNwLWZsYWdzIFNZTixSU1QgU1lOIC1qIFRDUE1TUyAtLXNldC1tc3MgMTE2MAoKZWNobyAnCmlwdGFibGVzIC1BIElOUFVUIC1wIHRjcCAtcyAxNjkuMjU0LjAuMC8xOSAtLXRjcC1mbGFncyBTWU4sUlNUIFNZTiAtaiBUQ1BNU1MgLS1zZXQtbXNzIDExNjAKaXB0YWJsZXMgLUEgT1VUUFVUIC1wIHRjcCAtZCAxNjkuMjU0LjAuMC8xOSAtLXRjcC1mbGFncyBTWU4sUlNUIFNZTiAtaiBUQ1BNU1MgLS1zZXQtbXNzIDExNjAKJyA+PiAvZXRjL3JjLmQvcmMubG9jYWw=" + instance_delete_mode = "retain" exist_instance { node_role = "MASTER_ETCD" instances_para { - instance_ids = ["ins-eeijdk16", "ins-84ku5rba", "ins-8oa3im2s"] + instance_ids = ["ins-mam0c7lw", "ins-quvwayve", "ins-qbffk8iw"] + enhanced_security_service = true + enhanced_monitor_service = true + password = "Password@123" + security_group_ids = ["sg-hjs685q9"] + master_config { + mount_target = "/var/data" + docker_graph_path = "/var/lib/containerd" + unschedulable = 0 + labels { + name = "key" + value = "value" + } + data_disk { + file_system = "ext4" + auto_format_and_mount = true + mount_target = "/var/data" + disk_partition = "/dev/vdb" + } + extra_args { + kubelet = ["root-dir=/root"] + } + taints { + key = "key" + value = "value" + effect = "NoSchedule" + } + } } } } @@ -973,6 +998,15 @@ 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`. @@ -1003,15 +1037,51 @@ The `extension_addon` object supports the following: * `name` - (Required, String) Add-on name. * `param` - (Required, String) Parameter of the add-on resource object in JSON string format, please check the example at the top of page for reference. +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"]. + +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. + 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. + +The `labels` object of `master_config` supports the following: + +* `name` - (Required, String, ForceNew) Name of map. +* `value` - (Required, String, ForceNew) Value of map. The `log_agent` object supports the following: * `enabled` - (Required, Bool) Whether the log agent enabled. * `kubelet_root_dir` - (Optional, String) Kubelet root directory as the literal. +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. + The `master_config` object supports the following: * `instance_type` - (Required, String, ForceNew) Specified types of CVM instance. @@ -1060,6 +1130,12 @@ The `resource_delete_options` object supports the following: * `resource_type` - (Required, String) Resource type, valid values are `CBS`, `CLB`, and `CVM`. * `skip_deletion_protection` - (Optional, Bool) Whether to skip resources with deletion protection enabled, the default is false. +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. + The `worker_config` object supports the following: * `instance_type` - (Required, String, ForceNew) Specified types of CVM instance. From 2d22ca6a4409fee45a82575e8345d4eedd6fa700 Mon Sep 17 00:00:00 2001 From: SevenEarth <391613297@qq.com> Date: Thu, 14 Nov 2024 11:08:34 +0800 Subject: [PATCH 3/3] add --- .changelog/2958.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/2958.txt diff --git a/.changelog/2958.txt b/.changelog/2958.txt new file mode 100644 index 0000000000..0cd1dc7cc5 --- /dev/null +++ b/.changelog/2958.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/tencentcloud_kubernetes_cluster: update `exist_instance` params +``` \ No newline at end of file