@@ -11,18 +11,18 @@ data "alicloud_zones" "default" {
11
11
12
12
// If there is not specifying vpc_id, the module will launch a new vpc
13
13
resource "alicloud_vpc" "vpc" {
14
- count = var. vpc_id == " " ? 1 : 0
14
+ count = var. create_vpc ? 1 : 0
15
15
cidr_block = var. vpc_cidr
16
- name = var. vpc_name == " " ? var. example_name : var. vpc_name
16
+ vpc_name = var. vpc_name == " " ? var. example_name : var. vpc_name
17
17
}
18
18
19
19
// According to the vswitch cidr blocks to launch several vswitches
20
20
resource "alicloud_vswitch" "vswitches" {
21
- count = length (var. vswitch_ids ) > 0 ? 0 : length (var. vswitch_cidrs )
22
- vpc_id = var. vpc_id == " " ? join (" " , alicloud_vpc. vpc . * . id ) : var. vpc_id
23
- cidr_block = var. vswitch_cidrs [count . index ]
24
- availability_zone = data. alicloud_zones . default . zones [count . index % length (data. alicloud_zones . default . zones )][" id" ]
25
- name = var. vswitch_name_prefix == " " ? format (
21
+ count = length (var. vswitch_ids ) > 0 ? 0 : length (var. vswitch_cidrs )
22
+ vpc_id = var. vpc_id == " " ? join (" " , alicloud_vpc. vpc . * . id ) : var. vpc_id
23
+ cidr_block = var. vswitch_cidrs [count . index ]
24
+ zone_id = data. alicloud_zones . default . zones [count . index % length (data. alicloud_zones . default . zones )][" id" ]
25
+ vswitch_name = var. vswitch_name_prefix == " " ? format (
26
26
" %s-%s" ,
27
27
var. example_name ,
28
28
format (var. number_format , count. index + 1 ),
@@ -71,16 +71,12 @@ resource "alicloud_cs_kubernetes" "k8s" {
71
71
format (var. number_format , count. index + 1 ),
72
72
)
73
73
master_vswitch_ids = length (var. vswitch_ids ) > 0 ? split (" ," , join (" ," , var. vswitch_ids )) : length (var. vswitch_cidrs ) < 1 ? [] : split (" ," , join (" ," , alicloud_vswitch. vswitches . * . id ))
74
- worker_vswitch_ids = length (var. vswitch_ids ) > 0 ? split (" ," , join (" ," , var. vswitch_ids )) : length (var. vswitch_cidrs ) < 1 ? [] : split (" ," , join (" ," , alicloud_vswitch. vswitches . * . id ))
75
74
master_instance_types = var. master_instance_types
76
- worker_instance_types = var. worker_instance_types
77
- worker_number = var. k8s_worker_number
78
75
node_cidr_mask = var. node_cidr_mask
79
76
enable_ssh = var. enable_ssh
80
77
install_cloud_monitor = var. install_cloud_monitor
81
- cpu_policy = var. cpu_policy
82
78
proxy_mode = var. proxy_mode
83
- password = var. password
79
+ password = var. master_password
84
80
pod_cidr = var. k8s_pod_cidr
85
81
service_cidr = var. k8s_service_cidr
86
82
version = var. k8s_version
@@ -92,4 +88,43 @@ resource "alicloud_cs_kubernetes" "k8s" {
92
88
}
93
89
}
94
90
depends_on = [alicloud_snat_entry . default ]
95
- }
91
+ }
92
+
93
+ resource "alicloud_cs_kubernetes_node_pool" "default" {
94
+ count = var. k8s_number
95
+
96
+ name = alicloud_cs_kubernetes. k8s [count . index ]. name
97
+ cluster_id = alicloud_cs_kubernetes. k8s [count . index ]. id
98
+ vswitch_ids = length (var. vswitch_ids ) > 0 ? split (" ," , join (" ," , var. vswitch_ids )) : length (var. vswitch_cidrs ) < 1 ? [] : split (" ," , join (" ," , alicloud_vswitch. vswitches . * . id ))
99
+ password = var. worker_password [count . index ]
100
+
101
+ desired_size = var. k8s_worker_number
102
+ install_cloud_monitor = var. install_cloud_monitor
103
+ instance_types = var. worker_instance_types
104
+
105
+ instance_charge_type = var. instance_charge_type
106
+ period = lookup (local. subscription , " period" , null )
107
+ period_unit = lookup (local. subscription , " period_unit" , null )
108
+ auto_renew = lookup (local. subscription , " auto_renew" , null )
109
+ auto_renew_period = lookup (local. subscription , " auto_renew_period" , null )
110
+
111
+ cpu_policy = var. cpu_policy
112
+ system_disk_category = var. system_disk_category
113
+ system_disk_size = var. system_disk_size
114
+
115
+ dynamic "data_disks" {
116
+ for_each = var. data_disks
117
+ content {
118
+ name = lookup (data_disks. value , " name" , null )
119
+ size = lookup (data_disks. value , " size" , null )
120
+ category = lookup (data_disks. value , " category" , null )
121
+ encrypted = lookup (data_disks. value , " encrypted" , null )
122
+ performance_level = lookup (data_disks. value , " encperformance_levelrypted" , null )
123
+ snapshot_id = lookup (data_disks. value , " snapshot_id" , null )
124
+ device = lookup (data_disks. value , " device" , null )
125
+ kms_key_id = lookup (data_disks. value , " kms_key_id" , null )
126
+ auto_snapshot_policy_id = lookup (data_disks. value , " auto_snapshot_policy_id" , null )
127
+
128
+ }
129
+ }
130
+ }
0 commit comments