Skip to content

Commit 3949000

Browse files
authored
Merge pull request #2099 from xiaokouliu/feat/dev
support for cluster configuration of CiliumOverlay network
2 parents e79e5cc + 330e338 commit 3949000

File tree

5 files changed

+29
-6
lines changed

5 files changed

+29
-6
lines changed

.changelog/2099.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_kubernetes_cluster: support for cluster configuration of CiliumOverlay network
3+
```

tencentcloud/extension_tke.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,12 @@ const (
7676
)
7777

7878
const (
79-
TKE_CLUSTER_NETWORK_TYPE_GR = "GR"
80-
TKE_CLUSTER_NETWORK_TYPE_VPC_CNI = "VPC-CNI"
79+
TKE_CLUSTER_NETWORK_TYPE_GR = "GR"
80+
TKE_CLUSTER_NETWORK_TYPE_VPC_CNI = "VPC-CNI"
81+
TKE_CLUSTER_NETWORK_TYPE_CILIUM_OVERLAY = "CiliumOverlay"
8182
)
8283

83-
var TKE_CLUSTER_NETWORK_TYPE = []string{TKE_CLUSTER_NETWORK_TYPE_GR, TKE_CLUSTER_NETWORK_TYPE_VPC_CNI}
84+
var TKE_CLUSTER_NETWORK_TYPE = []string{TKE_CLUSTER_NETWORK_TYPE_GR, TKE_CLUSTER_NETWORK_TYPE_VPC_CNI, TKE_CLUSTER_NETWORK_TYPE_CILIUM_OVERLAY}
8485

8586
const (
8687
TKE_CLUSTER_NODE_NAME_TYPE_LAN_IP = "lan-ip"

tencentcloud/resource_tc_kubernetes_cluster.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,12 @@ func resourceTencentCloudTkeCluster() *schema.Resource {
12481248
Description: "Operating system of the cluster, the available values include: '" + strings.Join(TKE_CLUSTER_OS, "','") +
12491249
"'. Default is '" + TKE_CLUSTER_OS_LINUX24 + "'.",
12501250
},
1251+
"cluster_subnet_id": {
1252+
Type: schema.TypeString,
1253+
Optional: true,
1254+
Description: "Subnet ID of the cluster, such as: subnet-b3p7d7q5.",
1255+
},
1256+
12511257
"cluster_os_type": {
12521258
Type: schema.TypeString,
12531259
ForceNew: true,
@@ -1373,7 +1379,7 @@ func resourceTencentCloudTkeCluster() *schema.Resource {
13731379
Optional: true,
13741380
Default: "GR",
13751381
ValidateFunc: validateAllowedStringValue(TKE_CLUSTER_NETWORK_TYPE),
1376-
Description: "Cluster network type, GR or VPC-CNI. Default is GR.",
1382+
Description: "Cluster network type, the available values include: 'GR' and 'VPC-CNI' and 'CiliumOverlay'. Default is GR.",
13771383
},
13781384
"enable_customized_pod_cidr": {
13791385
Type: schema.TypeBool,
@@ -2312,7 +2318,7 @@ func resourceTencentCloudTkeClusterCreate(d *schema.ResourceData, meta interface
23122318
}
23132319

23142320
basic.ClusterOsType = d.Get("cluster_os_type").(string)
2315-
2321+
basic.SubnetId = d.Get("cluster_subnet_id").(string)
23162322
basic.ClusterVersion = d.Get("cluster_version").(string)
23172323
if v, ok := d.GetOk("cluster_name"); ok {
23182324
basic.ClusterName = v.(string)
@@ -2402,6 +2408,10 @@ func resourceTencentCloudTkeClusterCreate(d *schema.ResourceData, meta interface
24022408
if math.Pow(2, float64(32-bitNumber)) <= float64(cidrSet.MaxNodePodNum) {
24032409
return fmt.Errorf("`cluster_cidr` Network segment range is too small, can not cover cluster_max_service_num")
24042410
}
2411+
2412+
if advanced.NetworkType == TKE_CLUSTER_NETWORK_TYPE_CILIUM_OVERLAY && d.Get("cluster_subnet_id").(string) == "" {
2413+
return fmt.Errorf("`cluster_subnet_id` must be set ")
2414+
}
24052415
}
24062416

24072417
if version, ok := d.GetOk("runtime_version"); ok {
@@ -2962,6 +2972,10 @@ func resourceTencentCloudTkeClusterUpdate(d *schema.ResourceData, meta interface
29622972
region := client.Region
29632973
d.Partial(true)
29642974

2975+
if d.HasChange("cluster_subnet_id") {
2976+
return fmt.Errorf("argument cluster_subnet_id cannot be changed")
2977+
}
2978+
29652979
if d.HasChange("tags") {
29662980
oldTags, newTags := d.GetChange("tags")
29672981
replaceTags, deleteTags := diffTags(oldTags.(map[string]interface{}), newTags.(map[string]interface{}))

tencentcloud/service_tencentcloud_tke.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ type ClusterBasicSetting struct {
3333
ProjectId int64
3434
ClusterNodeNum int64
3535
ClusterStatus string
36+
SubnetId string
3637
Tags map[string]string
3738
}
3839

@@ -511,6 +512,9 @@ func (me *TkeService) CreateCluster(ctx context.Context,
511512
IsAutoUpgrade: basic.AutoUpgradeClusterLevel,
512513
}
513514
}
515+
if basic.SubnetId != "" {
516+
request.ClusterBasicSettings.SubnetId = &basic.SubnetId
517+
}
514518
for k, v := range tags {
515519
if len(request.ClusterBasicSettings.TagSpecification) == 0 {
516520
request.ClusterBasicSettings.TagSpecification = []*tke.TagSpecification{{

website/docs/r/kubernetes_cluster.html.markdown

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,7 @@ The following arguments are supported:
818818
* `cluster_name` - (Optional, String) Name of the cluster.
819819
* `cluster_os_type` - (Optional, String, ForceNew) Image type of the cluster os, the available values include: 'GENERAL'. Default is 'GENERAL'.
820820
* `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'.
821+
* `cluster_subnet_id` - (Optional, String) Subnet ID of the cluster, such as: subnet-b3p7d7q5.
821822
* `cluster_version` - (Optional, String) Version of the cluster. Use `tencentcloud_kubernetes_available_cluster_versions` to get the upgradable cluster version.
822823
* `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'.
823824
* `deletion_protection` - (Optional, Bool) Indicates whether cluster deletion protection is enabled. Default is false.
@@ -837,7 +838,7 @@ The following arguments are supported:
837838
* `managed_cluster_internet_security_policies` - (Optional, List: [`String`], **Deprecated**) this argument was deprecated, use `cluster_internet_security_group` instead. Security policies for managed cluster internet, like:'192.168.1.0/24' or '113.116.51.27', '0.0.0.0/0' means all. This field can only set when field `cluster_deploy_type` is 'MANAGED_CLUSTER' and `cluster_internet` is true. `managed_cluster_internet_security_policies` can not delete or empty once be set.
838839
* `master_config` - (Optional, List, ForceNew) Deploy the machine configuration information of the 'MASTER_ETCD' service, and create <=7 units for common users.
839840
* `mount_target` - (Optional, String, ForceNew) Mount target. Default is not mounting.
840-
* `network_type` - (Optional, String, ForceNew) Cluster network type, GR or VPC-CNI. Default is GR.
841+
* `network_type` - (Optional, String, ForceNew) Cluster network type, the available values include: 'GR' and 'VPC-CNI' and 'CiliumOverlay'. Default is GR.
841842
* `node_name_type` - (Optional, String, ForceNew) Node name type of Cluster, the available values include: 'lan-ip' and 'hostname', Default is 'lan-ip'.
842843
* `node_pool_global_config` - (Optional, List) Global config effective for all node pools.
843844
* `project_id` - (Optional, Int) Project ID, default value is 0.

0 commit comments

Comments
 (0)