Skip to content

Commit 2378b87

Browse files
committed
tke support TKE-Optimized cluster os type.
1 parent 31e5eff commit 2378b87

File tree

13 files changed

+517
-38
lines changed

13 files changed

+517
-38
lines changed

tencentcloud/extension_tke.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,10 @@ const (
4444
)
4545

4646
var TKE_INSTANCE_CHARGE_TYPE = []string{CVM_CHARGE_TYPE_PREPAID, CVM_CHARGE_TYPE_POSTPAID}
47+
48+
const (
49+
TKE_CLUSTER_OS_TYPE_DOCKER_CUSTOMIZE = "DOCKER_CUSTOMIZE"
50+
TKE_CLUSTER_OS_TYPE_GENERAL = "GENERAL"
51+
)
52+
var TKE_CLUSTER_OS_TYPES = []string{TKE_CLUSTER_OS_TYPE_DOCKER_CUSTOMIZE,TKE_CLUSTER_OS_TYPE_GENERAL}
53+

tencentcloud/resource_tc_kubernetes_cluster.go

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,18 @@ func resourceTencentCloudTkeCluster() *schema.Resource {
391391
Optional: true,
392392
Default: TKE_CLUSTER_OS_UBUNTU16,
393393
ValidateFunc: validateAllowedStringValue(TKE_CLUSTER_OS),
394-
Description: "Operating system of the cluster, the available values include: 'centos7.2x86_64','centos7.6x86_64','ubuntu16.04.1 LTSx86_64','ubuntu18.04.1 LTSx86_64'. Default is 'ubuntu16.04.1 LTSx86_64'.",
394+
Description: "Operating system of the cluster, the available values include: '" + strings.Join(TKE_CLUSTER_OS, "','") +
395+
"'. Default is '" + TKE_CLUSTER_OS_UBUNTU16 + "'.",
396+
},
397+
"cluster_os_type": {
398+
Type: schema.TypeString,
399+
ForceNew: true,
400+
Optional: true,
401+
Default: TKE_CLUSTER_OS_TYPE_GENERAL,
402+
ValidateFunc: validateAllowedStringValue(TKE_CLUSTER_OS_TYPES),
403+
Description: "Image type of the cluster os, the available values include: '" + strings.Join(TKE_CLUSTER_OS_TYPES, "','") +
404+
"'. Default is '" + TKE_CLUSTER_OS_TYPE_GENERAL + "'. 'DOCKER_CUSTOMIZE' means 'TKE-Optimized'. " +
405+
"Only 'centos7.6x86_64' or 'ubuntu18.04.1 LTSx86_64' support 'DOCKER_CUSTOMIZE' now.",
395406
},
396407
"container_runtime": {
397408
Type: schema.TypeString,
@@ -797,7 +808,18 @@ func resourceTencentCloudTkeClusterCreate(d *schema.ResourceData, meta interface
797808
}
798809

799810
basic.ProjectId = int64(d.Get("project_id").(int))
800-
basic.ClusterOs = tkeClusterOsMap[d.Get("cluster_os").(string)]
811+
812+
cluster_os := d.Get("cluster_os").(string)
813+
814+
basic.ClusterOs = tkeClusterOsMap[cluster_os]
815+
basic.ClusterOsType = d.Get("cluster_os_type").(string)
816+
817+
if basic.ClusterOsType == TKE_CLUSTER_OS_TYPE_DOCKER_CUSTOMIZE {
818+
if cluster_os != TKE_CLUSTER_OS_UBUNTU18 && cluster_os != TKE_CLUSTER_OS_CENTOS76 {
819+
return fmt.Errorf("Only 'centos7.6x86_64' or 'ubuntu18.04.1 LTSx86_64' support 'DOCKER_CUSTOMIZE' now,can not be " + basic.ClusterOs)
820+
}
821+
}
822+
801823
basic.ClusterVersion = d.Get("cluster_version").(string)
802824
if v, ok := d.GetOk("cluster_name"); ok {
803825
basic.ClusterName = v.(string)

tencentcloud/service_tencentcloud_tke.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
type ClusterBasicSetting struct {
1616
ClusterId string
1717
ClusterOs string
18+
ClusterOsType string
1819
ClusterVersion string
1920
ClusterName string
2021
ClusterDescription string
@@ -297,6 +298,7 @@ func (me *TkeService) CreateCluster(ctx context.Context,
297298
request.ClusterBasicSettings.VpcId = &basic.VpcId
298299
request.ClusterBasicSettings.ClusterDescription = &basic.ClusterDescription
299300
request.ClusterBasicSettings.ClusterName = &basic.ClusterName
301+
request.ClusterBasicSettings.OsCustomizeType = &basic.ClusterOsType
300302
for k, v := range tags {
301303
if len(request.ClusterBasicSettings.TagSpecification) == 0 {
302304
request.ClusterBasicSettings.TagSpecification = []*tke.TagSpecification{{

vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http/request.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm/v20170312/client.go

Lines changed: 19 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm/v20170312/models.go

Lines changed: 18 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/gaap/v20180529/client.go

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/gaap/v20180529/models.go

Lines changed: 38 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525/client.go

Lines changed: 75 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)