@@ -9,7 +9,6 @@ Provide a resource to create an auto scaling group for kubernetes cluster.
9
9
Example Usage
10
10
11
11
``` hcl
12
-
13
12
variable "availability_zone" {
14
13
default = "ap-guangzhou-3"
15
14
}
@@ -19,43 +18,44 @@ variable "cluster_cidr" {
19
18
}
20
19
21
20
data "tencentcloud_vpc_subnets" "vpc" {
22
- is_default = true
23
- availability_zone = var.availability_zone
21
+ is_default = true
22
+ availability_zone = var.availability_zone
24
23
}
25
24
26
25
variable "default_instance_type" {
27
26
default = "S1.SMALL1"
28
27
}
29
28
30
29
//this is the cluster with empty worker config
31
- resource "tencentcloud_kubernetes_cluster" "managed_cluster " {
30
+ resource "tencentcloud_kubernetes_cluster" "example " {
32
31
vpc_id = data.tencentcloud_vpc_subnets.vpc.instance_list.0.vpc_id
33
32
cluster_cidr = var.cluster_cidr
34
33
cluster_max_pod_num = 32
35
34
cluster_name = "tf-tke-unit-test"
36
35
cluster_desc = "test cluster desc"
37
36
cluster_max_service_num = 32
38
37
cluster_version = "1.18.4"
39
- cluster_deploy_type = "MANAGED_CLUSTER"
38
+ cluster_deploy_type = "MANAGED_CLUSTER"
40
39
}
41
40
42
41
//this is one example of managing node using node pool
43
- resource "tencentcloud_kubernetes_node_pool" "mynodepool " {
44
- name = "mynodepool "
45
- cluster_id = tencentcloud_kubernetes_cluster.managed_cluster .id
46
- max_size = 6
47
- min_size = 1
48
- vpc_id = data.tencentcloud_vpc_subnets.vpc.instance_list.0.vpc_id
49
- subnet_ids = [data.tencentcloud_vpc_subnets.vpc.instance_list.0.subnet_id]
50
- retry_policy = "INCREMENTAL_INTERVALS"
51
- desired_capacity = 4
52
- enable_auto_scale = true
42
+ resource "tencentcloud_kubernetes_node_pool" "example " {
43
+ name = "tf-example "
44
+ cluster_id = tencentcloud_kubernetes_cluster.example .id
45
+ max_size = 6
46
+ min_size = 1
47
+ vpc_id = data.tencentcloud_vpc_subnets.vpc.instance_list.0.vpc_id
48
+ subnet_ids = [data.tencentcloud_vpc_subnets.vpc.instance_list.0.subnet_id]
49
+ retry_policy = "INCREMENTAL_INTERVALS"
50
+ desired_capacity = 4
51
+ enable_auto_scale = true
53
52
multi_zone_subnet_policy = "EQUALITY"
53
+ node_os = "img-9qrfy1xt"
54
54
55
55
auto_scaling_config {
56
- instance_type = var.default_instance_type
57
- system_disk_type = "CLOUD_PREMIUM"
58
- system_disk_size = "50"
56
+ instance_type = var.default_instance_type
57
+ system_disk_type = "CLOUD_PREMIUM"
58
+ system_disk_size = "50"
59
59
orderly_security_group_ids = ["sg-24vswocp"]
60
60
61
61
data_disk {
@@ -69,8 +69,8 @@ resource "tencentcloud_kubernetes_node_pool" "mynodepool" {
69
69
password = "test123#"
70
70
enhanced_security_service = false
71
71
enhanced_monitor_service = false
72
- host_name = "12.123.0.0"
73
- host_name_style = "ORIGINAL"
72
+ host_name = "12.123.0.0"
73
+ host_name_style = "ORIGINAL"
74
74
}
75
75
76
76
labels = {
@@ -79,47 +79,49 @@ resource "tencentcloud_kubernetes_node_pool" "mynodepool" {
79
79
}
80
80
81
81
taints {
82
- key = "test_taint"
83
- value = "taint_value"
82
+ key = "test_taint"
83
+ value = "taint_value"
84
84
effect = "PreferNoSchedule"
85
85
}
86
86
87
87
taints {
88
- key = "test_taint2"
89
- value = "taint_value2"
88
+ key = "test_taint2"
89
+ value = "taint_value2"
90
90
effect = "PreferNoSchedule"
91
91
}
92
92
93
93
node_config {
94
- extra_args = [
95
- "root-dir=/var/lib/kubelet"
96
- ]
94
+ docker_graph_path = "/var/lib/docker"
95
+ extra_args = [
96
+ "root-dir=/var/lib/kubelet"
97
+ ]
97
98
}
98
99
}
99
100
```
100
101
101
102
Using Spot CVM Instance
103
+
102
104
``` hcl
103
- resource "tencentcloud_kubernetes_node_pool" "mynodepool " {
104
- name = "mynodepool "
105
- cluster_id = tencentcloud_kubernetes_cluster.managed_cluster.id
106
- max_size = 6
107
- min_size = 1
108
- vpc_id = data.tencentcloud_vpc_subnets.vpc.instance_list.0.vpc_id
109
- subnet_ids = [data.tencentcloud_vpc_subnets.vpc.instance_list.0.subnet_id]
110
- retry_policy = "INCREMENTAL_INTERVALS"
111
- desired_capacity = 4
112
- enable_auto_scale = true
105
+ resource "tencentcloud_kubernetes_node_pool" "example " {
106
+ name = "tf-example "
107
+ cluster_id = tencentcloud_kubernetes_cluster.managed_cluster.id
108
+ max_size = 6
109
+ min_size = 1
110
+ vpc_id = data.tencentcloud_vpc_subnets.vpc.instance_list.0.vpc_id
111
+ subnet_ids = [data.tencentcloud_vpc_subnets.vpc.instance_list.0.subnet_id]
112
+ retry_policy = "INCREMENTAL_INTERVALS"
113
+ desired_capacity = 4
114
+ enable_auto_scale = true
113
115
multi_zone_subnet_policy = "EQUALITY"
114
116
115
117
auto_scaling_config {
116
- instance_type = var.default_instance_type
117
- system_disk_type = "CLOUD_PREMIUM"
118
- system_disk_size = "50"
118
+ instance_type = var.default_instance_type
119
+ system_disk_type = "CLOUD_PREMIUM"
120
+ system_disk_size = "50"
119
121
orderly_security_group_ids = ["sg-24vswocp", "sg-3qntci2v", "sg-7y1t2wax"]
120
- instance_charge_type = "SPOTPAID"
121
- spot_instance_type = "one-time"
122
- spot_max_price = "1000"
122
+ instance_charge_type = "SPOTPAID"
123
+ spot_instance_type = "one-time"
124
+ spot_max_price = "1000"
123
125
124
126
data_disk {
125
127
disk_type = "CLOUD_PREMIUM"
@@ -136,17 +138,15 @@ resource "tencentcloud_kubernetes_node_pool" "mynodepool" {
136
138
137
139
labels = {
138
140
"test1" = "test1",
139
- "test2" = "test2",
141
+ "test2" = "test2"
140
142
}
141
-
142
143
}
143
-
144
144
```
145
145
146
146
Import
147
147
148
148
tke node pool can be imported, e.g.
149
149
150
150
```
151
- $ terraform import tencentcloud_kubernetes_node_pool.test cls-xxx #np-xxx
151
+ $ terraform import tencentcloud_kubernetes_node_pool.example cls-d2xdg3io #np-380ay1o8
152
152
```
0 commit comments