Skip to content

Commit 85d059a

Browse files
authored
feat(tke): [120225433]: support resource_delete_options (#2916)
* feat(tke): [120225433]: support resource_delete_options * add changelog and doc * update resource_delete_options desc
1 parent 0971067 commit 85d059a

File tree

4 files changed

+164
-0
lines changed

4 files changed

+164
-0
lines changed

.changelog/2916.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 field `resource_delete_options` for deleting CBS
3+
```

tencentcloud/services/tke/resource_tc_kubernetes_cluster.go

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

tencentcloud/services/tke/resource_tc_kubernetes_cluster.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,62 @@ resource "tencentcloud_kubernetes_cluster" "cdc_cluster" {
807807
}
808808
```
809809

810+
Use delete options to delete CBS when deleting the Cluster
811+
812+
```hcl
813+
resource "tencentcloud_kubernetes_cluster" "example" {
814+
vpc_id = local.first_vpc_id
815+
cluster_cidr = var.example_cluster_cidr
816+
cluster_max_pod_num = 32
817+
cluster_name = "example"
818+
cluster_desc = "example for tke cluster"
819+
cluster_max_service_num = 32
820+
cluster_level = "L50"
821+
auto_upgrade_cluster_level = true
822+
cluster_internet = false # (can be ignored) open it after the nodes added
823+
cluster_version = "1.30.0"
824+
cluster_os = "tlinux2.2(tkernel3)x86_64"
825+
cluster_deploy_type = "MANAGED_CLUSTER"
826+
container_runtime = "containerd"
827+
docker_graph_path = "/var/lib/containerd"
828+
# without any worker config
829+
tags = {
830+
"demo" = "test"
831+
}
832+
833+
worker_config {
834+
count = 1
835+
availability_zone = var.availability_zone_first
836+
instance_type = "SA2.MEDIUM2"
837+
system_disk_type = "CLOUD_SSD"
838+
system_disk_size = 60
839+
internet_charge_type = "TRAFFIC_POSTPAID_BY_HOUR"
840+
internet_max_bandwidth_out = 100
841+
public_ip_assigned = true
842+
subnet_id = local.first_subnet_id
843+
844+
data_disk {
845+
disk_type = "CLOUD_PREMIUM"
846+
disk_size = 50
847+
}
848+
849+
enhanced_security_service = false
850+
enhanced_monitor_service = false
851+
user_data = "dGVzdA=="
852+
disaster_recover_group_ids = []
853+
security_group_ids = []
854+
key_ids = []
855+
cam_role_name = "CVM_QcsRole"
856+
password = "ZZXXccvv1212" // Optional, should be set if key_ids not set.
857+
}
858+
859+
resource_delete_options {
860+
resource_type = "CBS"
861+
delete_mode = "terminate"
862+
}
863+
}
864+
```
865+
810866
Import
811867

812868
tke cluster can be imported, e.g.

website/docs/r/kubernetes_cluster.html.markdown

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,62 @@ resource "tencentcloud_kubernetes_cluster" "cdc_cluster" {
818818
}
819819
```
820820

821+
### Use delete options to delete CBS when deleting the Cluster
822+
823+
```hcl
824+
resource "tencentcloud_kubernetes_cluster" "example" {
825+
vpc_id = local.first_vpc_id
826+
cluster_cidr = var.example_cluster_cidr
827+
cluster_max_pod_num = 32
828+
cluster_name = "example"
829+
cluster_desc = "example for tke cluster"
830+
cluster_max_service_num = 32
831+
cluster_level = "L50"
832+
auto_upgrade_cluster_level = true
833+
cluster_internet = false # (can be ignored) open it after the nodes added
834+
cluster_version = "1.30.0"
835+
cluster_os = "tlinux2.2(tkernel3)x86_64"
836+
cluster_deploy_type = "MANAGED_CLUSTER"
837+
container_runtime = "containerd"
838+
docker_graph_path = "/var/lib/containerd"
839+
# without any worker config
840+
tags = {
841+
"demo" = "test"
842+
}
843+
844+
worker_config {
845+
count = 1
846+
availability_zone = var.availability_zone_first
847+
instance_type = "SA2.MEDIUM2"
848+
system_disk_type = "CLOUD_SSD"
849+
system_disk_size = 60
850+
internet_charge_type = "TRAFFIC_POSTPAID_BY_HOUR"
851+
internet_max_bandwidth_out = 100
852+
public_ip_assigned = true
853+
subnet_id = local.first_subnet_id
854+
855+
data_disk {
856+
disk_type = "CLOUD_PREMIUM"
857+
disk_size = 50
858+
}
859+
860+
enhanced_security_service = false
861+
enhanced_monitor_service = false
862+
user_data = "dGVzdA=="
863+
disaster_recover_group_ids = []
864+
security_group_ids = []
865+
key_ids = []
866+
cam_role_name = "CVM_QcsRole"
867+
password = "ZZXXccvv1212" // Optional, should be set if key_ids not set.
868+
}
869+
870+
resource_delete_options {
871+
resource_type = "CBS"
872+
delete_mode = "terminate"
873+
}
874+
}
875+
```
876+
821877
## Argument Reference
822878

823879
The following arguments are supported:
@@ -873,6 +929,7 @@ The following arguments are supported:
873929
* `node_pool_global_config` - (Optional, List) Global config effective for all node pools.
874930
* `pre_start_user_script` - (Optional, String, ForceNew) Base64-encoded user script, executed before initializing the node, currently only effective for adding existing nodes.
875931
* `project_id` - (Optional, Int) Project ID, default value is 0.
932+
* `resource_delete_options` - (Optional, Set) The resource deletion policy when the cluster is deleted. Currently, CBS is supported (CBS is retained by default). Only valid when deleting cluster.
876933
* `runtime_version` - (Optional, String) Container Runtime version.
877934
* `service_cidr` - (Optional, String, ForceNew) A network address block of the service. Different from vpc cidr and cidr of other clusters within this vpc. Must be in 10./192.168/172.[16-31] segments.
878935
* `tags` - (Optional, Map) The tags of the cluster.
@@ -994,6 +1051,12 @@ The `node_pool_global_config` object supports the following:
9941051
* `skip_nodes_with_local_storage` - (Optional, Bool) During scale-in, ignore nodes with local storage pods.
9951052
* `skip_nodes_with_system_pods` - (Optional, Bool) During scale-in, ignore nodes with pods in the kube-system namespace that are not managed by DaemonSet.
9961053

1054+
The `resource_delete_options` object supports the following:
1055+
1056+
* `delete_mode` - (Required, String) The deletion mode of CBS resources when the cluster is deleted, `terminate` (destroy), `retain` (retain). Other resources are deleted by default.
1057+
* `resource_type` - (Required, String) Resource type, valid values are `CBS`, `CLB`, and `CVM`.
1058+
* `skip_deletion_protection` - (Optional, Bool) Whether to skip resources with deletion protection enabled, the default is false.
1059+
9971060
The `worker_config` object supports the following:
9981061

9991062
* `instance_type` - (Required, String, ForceNew) Specified types of CVM instance.

0 commit comments

Comments
 (0)