Skip to content

Commit 52ce1d6

Browse files
authored
fix(tke): [123456789] tencentcloud_kubernetes_cluster support set instance_delete_mode (#2949)
* add * add * add
1 parent c83d1a7 commit 52ce1d6

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

.changelog/2949.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 set `instance_delete_mode`
3+
```

tencentcloud/services/tke/resource_tc_kubernetes_cluster.go

Lines changed: 10 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: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Provide a resource to create a kubernetes cluster.
55
~> **NOTE:** We recommend this usage that uses the `tencentcloud_kubernetes_cluster` resource to create a cluster without any `worker_config`, then adds nodes by the `tencentcloud_kubernetes_node_pool` resource.
66
It's more flexible than managing worker config directly with `tencentcloud_kubernetes_cluster`, `tencentcloud_kubernetes_scale_worker`, or existing node management of `tencentcloud_kubernetes_attachment`. The reason is that `worker_config` is unchangeable and may cause the whole cluster resource to `ForceNew`.
77

8+
~> **NOTE:** Executing `terraform destroy` to destroy the resource will default to deleting the node resource, If it is necessary to preserve node instance resources, Please set `instance_delete_mode` to `retain`.
9+
810
Example Usage
911

1012
Create a basic cluster with two worker nodes
@@ -397,7 +399,6 @@ resource "tencentcloud_kubernetes_cluster_endpoint" "example" {
397399
tencentcloud_kubernetes_node_pool.example
398400
]
399401
}
400-
401402
````
402403
403404
Use Kubelet
@@ -699,6 +700,7 @@ resource "tencentcloud_kubernetes_cluster" "test_node_pool_global_config" {
699700
```
700701

701702
Using VPC-CNI network type
703+
702704
```hcl
703705
variable "availability_zone" {
704706
default = "ap-guangzhou-1"
@@ -756,6 +758,7 @@ resource "tencentcloud_kubernetes_cluster" "managed_cluster" {
756758
```
757759

758760
Using ops options
761+
759762
```
760763
resource "tencentcloud_kubernetes_cluster" "managed_cluster" {
761764
# ...your basic fields
@@ -868,5 +871,5 @@ Import
868871
tke cluster can be imported, e.g.
869872

870873
```
871-
$ terraform import tencentcloud_kubernetes_cluster.test cls-xxx
874+
$ terraform import tencentcloud_kubernetes_cluster.example cls-n2h4jbtk
872875
```

website/docs/r/kubernetes_cluster.html.markdown

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ Provide a resource to create a kubernetes cluster.
1616
~> **NOTE:** We recommend this usage that uses the `tencentcloud_kubernetes_cluster` resource to create a cluster without any `worker_config`, then adds nodes by the `tencentcloud_kubernetes_node_pool` resource.
1717
It's more flexible than managing worker config directly with `tencentcloud_kubernetes_cluster`, `tencentcloud_kubernetes_scale_worker`, or existing node management of `tencentcloud_kubernetes_attachment`. The reason is that `worker_config` is unchangeable and may cause the whole cluster resource to `ForceNew`.
1818

19+
~> **NOTE:** Executing `terraform destroy` to destroy the resource will default to deleting the node resource, If it is necessary to preserve node instance resources, Please set `instance_delete_mode` to `retain`.
20+
1921
## Example Usage
2022

2123
### Create a basic cluster with two worker nodes
@@ -917,6 +919,7 @@ The following arguments are supported:
917919
* `globe_desired_pod_num` - (Optional, Int, ForceNew) Indicate to set desired pod number in node. valid when enable_customized_pod_cidr=true, and it takes effect for all nodes.
918920
* `ignore_cluster_cidr_conflict` - (Optional, Bool, ForceNew) Indicates whether to ignore the cluster cidr conflict error. Default is false.
919921
* `ignore_service_cidr_conflict` - (Optional, Bool, ForceNew) Indicates whether to ignore the service cidr conflict error. Only valid in `VPC-CNI` mode.
922+
* `instance_delete_mode` - (Optional, String) The strategy for deleting cluster instances: terminate (destroy instances, only support pay as you go cloud host instances) retain (remove only, keep instances), Default is terminate.
920923
* `is_non_static_ip_mode` - (Optional, Bool, ForceNew) Indicates whether non-static ip mode is enabled. Default is false.
921924
* `kube_proxy_mode` - (Optional, String) Cluster kube-proxy mode, the available values include: 'kube-proxy-bpf'. Default is not set.When set to kube-proxy-bpf, cluster version greater than 1.14 and with Tencent Linux 2.4 is required.
922925
* `labels` - (Optional, Map, ForceNew) Labels of tke cluster nodes.
@@ -1116,6 +1119,6 @@ In addition to all arguments above, the following attributes are exported:
11161119
tke cluster can be imported, e.g.
11171120

11181121
```
1119-
$ terraform import tencentcloud_kubernetes_cluster.test cls-xxx
1122+
$ terraform import tencentcloud_kubernetes_cluster.example cls-n2h4jbtk
11201123
```
11211124

0 commit comments

Comments
 (0)