Skip to content

Commit 1e76485

Browse files
author
ivan
committed
merge the upstream and solve the conflicts
2 parents bcadc56 + bd00ea6 commit 1e76485

32 files changed

+1533
-72
lines changed

CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
## 1.56.8 (Unreleased)
1+
## 1.56.9 (Unreleased)
2+
## 1.56.8 (May 26, 2021)
3+
4+
ENHANCEMENTS:
5+
6+
* Resource `tencentcloud_kubernetes_cluster_attachment.worker_config` add `desired_pod_num`.
7+
* Resource `tencentcloud_kubernetes_cluster_attachment` add `worker_config_overrides`.
8+
* Resource `tencentcloud_kubernetes_scale_worker` add `desired_pod_num`.
9+
* Resource `tencentcloud_kubernetes_cluster` add `enable_customized_pod_cidr`, `base_pod_num`, `globe_desired_pod_num`, and `exist_instance`.
10+
* Resource `tencentcloud_kubernetes_cluster` update available value of `cluster_os`.
11+
* Resource `tencentcloud_as_lifecycle_hook` update `heartbeat_timeout` value ranges.
12+
213
## 1.56.7 (May 12, 2021)
314

415
ENHANCEMENTS:

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ require (
1515
github.com/mattn/go-colorable v0.1.6 // indirect
1616
github.com/mitchellh/go-homedir v1.1.0
1717
github.com/pkg/errors v0.9.1
18-
github.com/tencentcloud/tencentcloud-sdk-go v1.0.155
18+
github.com/tencentcloud/tencentcloud-sdk-go v1.0.165
1919
github.com/yangwenmai/ratelimit v0.0.0-20180104140304-44221c2292e1
2020
github.com/zclconf/go-cty v1.4.2 // indirect
2121
golang.org/x/sys v0.0.0-20200523222454-059865788121 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,8 @@ github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s
441441
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
442442
github.com/tdakkota/asciicheck v0.0.0-20200416190851-d7f85be797a2 h1:Xr9gkxfOP0KQWXKNqmwe8vEeSUiUj4Rlee9CMVX2ZUQ=
443443
github.com/tdakkota/asciicheck v0.0.0-20200416190851-d7f85be797a2/go.mod h1:yHp0ai0Z9gUljN3o0xMhYJnH/IcvkdTBOX2fmJ93JEM=
444-
github.com/tencentcloud/tencentcloud-sdk-go v1.0.155 h1:jFyQ7gV9e3HD4yRqTpN6P3+bZwqlYaAhkb87gTc2zT4=
445-
github.com/tencentcloud/tencentcloud-sdk-go v1.0.155/go.mod h1:asUz5BPXxgoPGaRgZaVm1iGcUAuHyYUo1nXqKa83cvI=
444+
github.com/tencentcloud/tencentcloud-sdk-go v1.0.165 h1:d9L8aoQ781XBO8pnE9EvFm64ptfBVMqVNcKQ2MS+TUM=
445+
github.com/tencentcloud/tencentcloud-sdk-go v1.0.165/go.mod h1:asUz5BPXxgoPGaRgZaVm1iGcUAuHyYUo1nXqKa83cvI=
446446
github.com/tetafro/godot v0.3.7 h1:+mecr7RKrUKB5UQ1gwqEMn13sDKTyDR8KNIquB9mm+8=
447447
github.com/tetafro/godot v0.3.7/go.mod h1:/7NLHhv08H1+8DNj0MElpAACw1ajsCuf3TKNQxA5S+0=
448448
github.com/timakin/bodyclose v0.0.0-20190930140734-f7f2e9bca95e h1:RumXZ56IrCj4CL+g1b9OL/oH0QnsF976bC8xQFYUD5Q=

tencentcloud/extension_tke.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,19 @@ package tencentcloud
22

33
const (
44
TKE_CLUSTER_OS_CENTOS72 = "centos7.2x86_64"
5-
TKE_CLUSTER_OS_CENTOS76 = "centos7.6x86_64"
6-
TKE_CLUSTER_OS_UBUNTU16 = "ubuntu16.04.1 LTSx86_64"
7-
TKE_CLUSTER_OS_UBUNTU18 = "ubuntu18.04.1 LTSx86_64"
5+
TKE_CLUSTER_OS_CENTOS76 = "centos7.6.0_x64"
6+
TKE_CLUSTER_OS_UBUNTU18 = "ubuntu18.04.1x86_64"
87
TKE_CLUSTER_OS_LINUX24 = "tlinux2.4x86_64"
98
TKE_CLUSTER_OS_LINUX22 = "tlinux2.2(tkernel3)x86_64"
109
TKE_CLUSTER_OS_LINUXF22 = "Tencent tlinux release 2.2 (Final)"
1110
)
1211

13-
var TKE_CLUSTER_OS = []string{TKE_CLUSTER_OS_CENTOS72, TKE_CLUSTER_OS_CENTOS76, TKE_CLUSTER_OS_UBUNTU16, TKE_CLUSTER_OS_UBUNTU18, TKE_CLUSTER_OS_LINUX24}
12+
var TKE_CLUSTER_OS = []string{TKE_CLUSTER_OS_CENTOS76, TKE_CLUSTER_OS_UBUNTU18, TKE_CLUSTER_OS_LINUX24}
1413

1514
var tkeClusterOsMap = map[string]string{TKE_CLUSTER_OS_CENTOS72: TKE_CLUSTER_OS_CENTOS72,
16-
TKE_CLUSTER_OS_CENTOS76: "centos7.6.0_x64",
17-
TKE_CLUSTER_OS_UBUNTU16: TKE_CLUSTER_OS_UBUNTU16,
18-
TKE_CLUSTER_OS_UBUNTU18: "ubuntu18.04.1x86_64",
19-
TKE_CLUSTER_OS_LINUX24: "tlinux2.4x86_64",
15+
TKE_CLUSTER_OS_CENTOS76: TKE_CLUSTER_OS_CENTOS76,
16+
TKE_CLUSTER_OS_UBUNTU18: TKE_CLUSTER_OS_UBUNTU18,
17+
TKE_CLUSTER_OS_LINUX24: TKE_CLUSTER_OS_LINUX24,
2018
TKE_CLUSTER_OS_LINUX22: TKE_CLUSTER_OS_LINUX22,
2119
TKE_CLUSTER_OS_LINUXF22: TKE_CLUSTER_OS_LINUXF22,
2220
}

tencentcloud/resource_tc_as_lifecycle_hook.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ func resourceTencentCloudAsLifecycleHook() *schema.Resource {
6565
Type: schema.TypeInt,
6666
Optional: true,
6767
Default: 300,
68-
ValidateFunc: validateIntegerInRange(30, 3600),
69-
Description: "Defines the amount of time, in seconds, that can elapse before the lifecycle hook times out. Valid value ranges: (30~3600). and default value is `300`.",
68+
ValidateFunc: validateIntegerInRange(30, 7200),
69+
Description: "Defines the amount of time, in seconds, that can elapse before the lifecycle hook times out. Valid value ranges: (30~7200). and default value is `300`.",
7070
},
7171
"notification_metadata": {
7272
Type: schema.TypeString,

tencentcloud/resource_tc_container_cluster.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ func resourceTencentCloudContainerClusterCreate(d *schema.ResourceData, meta int
449449
runInstancesParas := runInstancesPara.ToJsonString()
450450
cvms.Work = []string{runInstancesParas}
451451

452-
id, err := service.CreateCluster(ctx, basic, cAdvanced, cvms, iAdvanced, cidrSet, map[string]string{})
452+
id, err := service.CreateCluster(ctx, basic, cAdvanced, cvms, iAdvanced, cidrSet, map[string]string{}, nil, nil)
453453
if err != nil {
454454
return err
455455
}

tencentcloud/resource_tc_kubernetes_cluster.go

Lines changed: 146 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,52 @@ func TkeCvmCreateInfo() map[string]*schema.Schema {
556556
ValidateFunc: validateImageID,
557557
Description: "The valid image id, format of img-xxx.",
558558
},
559+
// InstanceAdvancedSettingsOverrides
560+
"desired_pod_num": {
561+
Type: schema.TypeInt,
562+
ForceNew: true,
563+
Optional: true,
564+
Default: -1,
565+
Description: "Indicate to set desired pod number in node. valid when enable_customized_pod_cidr=true, " +
566+
"and it override `[globe_]desired_pod_num` for current node. Either all the fields `desired_pod_num` or none.",
567+
},
568+
}
569+
}
570+
571+
func TkeExistCvmCreateInfo() map[string]*schema.Schema {
572+
return map[string]*schema.Schema{
573+
"node_role": {
574+
Type: schema.TypeString,
575+
ForceNew: true,
576+
Optional: true,
577+
ValidateFunc: validateAllowedStringValue([]string{TKE_ROLE_WORKER, TKE_ROLE_MASTER_ETCD}),
578+
Description: "Role of existed node. value:MASTER_ETCD or WORKER.",
579+
},
580+
"instances_para": {
581+
Type: schema.TypeList,
582+
ForceNew: true,
583+
Optional: true,
584+
MaxItems: 1,
585+
Elem: &schema.Resource{
586+
Schema: map[string]*schema.Schema{
587+
"instance_ids": {
588+
Type: schema.TypeList,
589+
ForceNew: true,
590+
Required: true,
591+
Elem: &schema.Schema{Type: schema.TypeString},
592+
Description: "Cluster IDs.",
593+
},
594+
},
595+
},
596+
Description: "Reinstallation parameters of an existing instance.",
597+
},
598+
"desired_pod_numbers": {
599+
Type: schema.TypeList,
600+
Optional: true,
601+
ForceNew: true,
602+
Elem: &schema.Schema{Type: schema.TypeInt},
603+
Description: "Custom mode cluster, you can specify the number of pods for each node. corresponding to the existed_instances_para.instance_ids parameter.",
604+
},
559605
}
560606
}
561607

@@ -634,9 +680,9 @@ func resourceTencentCloudTkeCluster() *schema.Resource {
634680
Type: schema.TypeString,
635681
ForceNew: true,
636682
Optional: true,
637-
Default: TKE_CLUSTER_OS_UBUNTU16,
683+
Default: TKE_CLUSTER_OS_LINUX24,
638684
Description: "Operating system of the cluster, the available values include: '" + strings.Join(TKE_CLUSTER_OS, "','") +
639-
"'. Default is '" + TKE_CLUSTER_OS_UBUNTU16 + "'.",
685+
"'. Default is '" + TKE_CLUSTER_OS_LINUX24 + "'.",
640686
},
641687
"cluster_os_type": {
642688
Type: schema.TypeString,
@@ -746,6 +792,19 @@ func resourceTencentCloudTkeCluster() *schema.Resource {
746792
ValidateFunc: validateAllowedStringValue(TKE_CLUSTER_NETWORK_TYPE),
747793
Description: "Cluster network type, GR or VPC-CNI. Default is GR.",
748794
},
795+
"enable_customized_pod_cidr": {
796+
Type: schema.TypeBool,
797+
ForceNew: true,
798+
Optional: true,
799+
Default: false,
800+
Description: "Whether to enable the custom mode of node podCIDR size. Default is false.",
801+
},
802+
"base_pod_num": {
803+
Type: schema.TypeInt,
804+
ForceNew: true,
805+
Optional: true,
806+
Description: "The number of basic pods. valid when enable_customized_pod_cidr=true.",
807+
},
749808
"is_non_static_ip_mode": {
750809
Type: schema.TypeBool,
751810
ForceNew: true,
@@ -965,6 +1024,15 @@ func resourceTencentCloudTkeCluster() *schema.Resource {
9651024
},
9661025
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'.",
9671026
},
1027+
"exist_instance": {
1028+
Type: schema.TypeList,
1029+
ForceNew: true,
1030+
Optional: true,
1031+
Elem: &schema.Resource{
1032+
Schema: TkeExistCvmCreateInfo(),
1033+
},
1034+
Description: "create tke cluster by existed instances.",
1035+
},
9681036
"tags": {
9691037
Type: schema.TypeMap,
9701038
Optional: true,
@@ -1012,6 +1080,12 @@ func resourceTencentCloudTkeCluster() *schema.Resource {
10121080
ForceNew: true,
10131081
Description: "Mount target. Default is not mounting.",
10141082
},
1083+
"globe_desired_pod_num": {
1084+
Type: schema.TypeInt,
1085+
ForceNew: true,
1086+
Optional: true,
1087+
Description: "Indicate to set desired pod number in node. valid when enable_customized_pod_cidr=true, and it takes effect for all nodes.",
1088+
},
10151089
"docker_graph_path": {
10161090
Type: schema.TypeString,
10171091
Optional: true,
@@ -1280,6 +1354,37 @@ func tkeGetCvmRunInstancesPara(dMap map[string]interface{}, meta interface{},
12801354
return
12811355
}
12821356

1357+
func tkeGetCvmExistInstancesPara(dMap map[string]interface{}) (tke.ExistedInstancesForNode, error) {
1358+
1359+
inst := tke.ExistedInstancesForNode{}
1360+
1361+
if temp, ok := dMap["instances_para"]; ok {
1362+
paras := temp.([]interface{})
1363+
if len(paras) > 0 {
1364+
paraMap := paras[0].(map[string]interface{})
1365+
instanceIds := paraMap["instance_ids"].([]interface{})
1366+
inst.ExistedInstancesPara = &tke.ExistedInstancesPara{}
1367+
inst.ExistedInstancesPara.InstanceIds = make([]*string, 0)
1368+
for _, v := range instanceIds {
1369+
inst.ExistedInstancesPara.InstanceIds = append(inst.ExistedInstancesPara.InstanceIds, helper.String(v.(string)))
1370+
}
1371+
}
1372+
}
1373+
if temp, ok := dMap["desired_pod_numbers"]; ok {
1374+
inst.DesiredPodNumbers = make([]*int64, 0)
1375+
podNums := temp.([]interface{})
1376+
for _, v := range podNums {
1377+
inst.DesiredPodNumbers = append(inst.DesiredPodNumbers, helper.Int64(int64(v.(int))))
1378+
}
1379+
}
1380+
if temp, ok := dMap["node_role"]; ok {
1381+
nodeRole := temp.(string)
1382+
inst.NodeRole = &nodeRole
1383+
}
1384+
1385+
return inst, nil
1386+
}
1387+
12831388
func tkeGetNodePoolGlobalConfig(d *schema.ResourceData) *tke.ModifyClusterAsGroupOptionAttributeRequest {
12841389
request := tke.NewModifyClusterAsGroupOptionAttributeRequest()
12851390
request.ClusterId = helper.String(d.Id())
@@ -1435,12 +1540,6 @@ func resourceTencentCloudTkeClusterCreate(d *schema.ResourceData, meta interface
14351540

14361541
basic.ClusterOsType = d.Get("cluster_os_type").(string)
14371542

1438-
if basic.ClusterOsType == TKE_CLUSTER_OS_TYPE_DOCKER_CUSTOMIZE {
1439-
if cluster_os != TKE_CLUSTER_OS_UBUNTU18 && cluster_os != TKE_CLUSTER_OS_CENTOS76 {
1440-
return fmt.Errorf("Only 'centos7.6x86_64' or 'ubuntu18.04.1 LTSx86_64' support 'DOCKER_CUSTOMIZE' now, can not be " + basic.ClusterOs)
1441-
}
1442-
}
1443-
14441543
basic.ClusterVersion = d.Get("cluster_version").(string)
14451544
if v, ok := d.GetOk("cluster_name"); ok {
14461545
basic.ClusterName = v.(string)
@@ -1457,6 +1556,10 @@ func resourceTencentCloudTkeClusterCreate(d *schema.ResourceData, meta interface
14571556
advanced.IsNonStaticIpMode = d.Get("is_non_static_ip_mode").(bool)
14581557
advanced.DeletionProtection = d.Get("deletion_protection").(bool)
14591558
advanced.KubeProxyMode = d.Get("kube_proxy_mode").(string)
1559+
advanced.EnableCustomizedPodCIDR = d.Get("enable_customized_pod_cidr").(bool)
1560+
if v, ok := d.GetOk("base_pod_num"); ok {
1561+
advanced.BasePodNumber = int64(v.(int))
1562+
}
14601563

14611564
if extraArgs, ok := d.GetOk("cluster_extra_args"); ok {
14621565
extraArgList := extraArgs.([]interface{})
@@ -1520,6 +1623,7 @@ func resourceTencentCloudTkeClusterCreate(d *schema.ResourceData, meta interface
15201623
}
15211624
}
15221625

1626+
overrideSettings := make([]tke.InstanceAdvancedSettings, 0)
15231627
if masters, ok := d.GetOk("master_config"); ok {
15241628
if clusterDeployType == TKE_DEPLOY_TYPE_MANAGED {
15251629
return fmt.Errorf("if `cluster_deploy_type` is `MANAGED_CLUSTER` , You don't need define the master yourself")
@@ -1535,6 +1639,13 @@ func resourceTencentCloudTkeClusterCreate(d *schema.ResourceData, meta interface
15351639

15361640
cvms.Master = append(cvms.Master, paraJson)
15371641
masterCount += count
1642+
1643+
if v, ok := master["desired_pod_num"]; ok {
1644+
dpNum := int64(v.(int))
1645+
if dpNum != -1 {
1646+
overrideSettings = append(overrideSettings, tke.InstanceAdvancedSettings{DesiredPodNumber: helper.Int64(dpNum)})
1647+
}
1648+
}
15381649
}
15391650
if masterCount < 3 {
15401651
return fmt.Errorf("if `cluster_deploy_type` is `TKE_DEPLOY_TYPE_INDEPENDENT` len(master_config) should >=3")
@@ -1551,11 +1662,17 @@ func resourceTencentCloudTkeClusterCreate(d *schema.ResourceData, meta interface
15511662
for index := range workerList {
15521663
worker := workerList[index].(map[string]interface{})
15531664
paraJson, _, err := tkeGetCvmRunInstancesPara(worker, meta, vpcId, basic.ProjectId)
1554-
15551665
if err != nil {
15561666
return err
15571667
}
15581668
cvms.Work = append(cvms.Work, paraJson)
1669+
1670+
if v, ok := worker["desired_pod_num"]; ok {
1671+
dpNum := int64(v.(int))
1672+
if dpNum != -1 {
1673+
overrideSettings = append(overrideSettings, tke.InstanceAdvancedSettings{DesiredPodNumber: helper.Int64(dpNum)})
1674+
}
1675+
}
15591676
}
15601677
}
15611678

@@ -1578,10 +1695,28 @@ func resourceTencentCloudTkeClusterCreate(d *schema.ResourceData, meta interface
15781695
if temp, ok := d.GetOk("mount_target"); ok {
15791696
iAdvanced.MountTarget = temp.(string)
15801697
}
1698+
if temp, ok := d.GetOk("globe_desired_pod_num"); ok {
1699+
iAdvanced.DesiredPodNum = int64(temp.(int))
1700+
}
15811701

1582-
service := TkeService{client: meta.(*TencentCloudClient).apiV3Conn}
1702+
// ExistedInstancesForNode
1703+
existIntances := make([]*tke.ExistedInstancesForNode, 0)
1704+
if instances, ok := d.GetOk("exist_instance"); ok {
1705+
instanceList := instances.([]interface{})
1706+
for index := range instanceList {
1707+
instance := instanceList[index].(map[string]interface{})
1708+
existedInstance, _ := tkeGetCvmExistInstancesPara(instance)
1709+
existIntances = append(existIntances, &existedInstance)
1710+
}
1711+
}
1712+
1713+
// RunInstancesForNode(master_config+worker_config) 和 ExistedInstancesForNode 不能同时存在
1714+
if len(cvms.Master)+len(cvms.Work) > 0 && len(existIntances) > 0 {
1715+
return fmt.Errorf("master_config+worker_config and exist_instance can not exist at the same time")
1716+
}
15831717

1584-
id, err := service.CreateCluster(ctx, basic, advanced, cvms, iAdvanced, cidrSet, tags)
1718+
service := TkeService{client: meta.(*TencentCloudClient).apiV3Conn}
1719+
id, err := service.CreateCluster(ctx, basic, advanced, cvms, iAdvanced, cidrSet, tags, existIntances, overrideSettings)
15851720
if err != nil {
15861721
return err
15871722
}

0 commit comments

Comments
 (0)