-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.tf
116 lines (93 loc) · 3.34 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
resource "flexibleengine_cce_cluster_v3" "cce_cluster" {
name = var.cluster_name
cluster_type = var.cluster_type
cluster_version = var.cluster_version
flavor_id = var.cluster_flavor
vpc_id = var.vpc_id
subnet_id = var.network_id
container_network_type = var.container_network_type
eip = var.cluster_eip
description = var.cluster_desc
annotations = var.annotations
extend_param = var.extend_param
}
locals {
nodes_list_keys = [for node in var.nodes_list : node.node_index]
nodes_list_values = [for node in var.nodes_list : node]
nodes_list_map = zipmap(local.nodes_list_keys, local.nodes_list_values)
node_pool_list_keys = [for node_pool in var.node_pool_list : node_pool.node_pool_index]
node_pool_list_values = [for node_pool in var.node_pool_list : node_pool]
node_pool_list_map = zipmap(local.node_pool_list_keys, local.node_pool_list_values)
}
resource "flexibleengine_cce_node_v3" "cce_cluster_node" {
for_each = local.nodes_list_map
cluster_id = flexibleengine_cce_cluster_v3.cce_cluster.id
name = each.value.node_name
flavor_id = each.value.node_flavor
os = var.node_os
runtime = var.node_runtime
availability_zone = each.value.availability_zone
key_pair = var.key_pair
postinstall = each.value.postinstall_script
preinstall = each.value.preinstall_script
labels = each.value.node_labels
tags = each.value.vm_tags
annotations = each.value.annotations
root_volume {
size = each.value.root_volume_size
volumetype = each.value.root_volume_type
}
data_volumes {
size = each.value.data_volume_size
volumetype = each.value.data_volume_type
}
dynamic "taints" {
for_each = each.value.taints
content {
key = taints.value.key
value = taints.value.value
effect = taints.value.effect
}
}
lifecycle {
create_before_destroy = true
ignore_changes = [annotations, labels]
}
}
resource "flexibleengine_cce_node_pool_v3" "cce_node_pool" {
for_each = local.node_pool_list_map
cluster_id = flexibleengine_cce_cluster_v3.cce_cluster.id
name = each.value.node_pool_name
os = var.node_os
runtime = var.node_runtime
flavor_id = each.value.node_flavor
availability_zone = each.value.availability_zone
key_pair = var.key_pair
initial_node_count = each.value.initial_node_count
scale_enable = each.value.scale_enable
min_node_count = each.value.min_node_count
max_node_count = each.value.max_node_count
scale_down_cooldown_time = each.value.scale_down_cooldown_time
priority = each.value.priority
type = each.value.type
postinstall = each.value.postinstall_script
preinstall = each.value.preinstall_script
labels = each.value.node_labels
tags = each.value.vm_tags
root_volume {
size = each.value.root_volume_size
volumetype = each.value.root_volume_type
}
data_volumes {
size = each.value.data_volume_size
volumetype = each.value.data_volume_type
}
dynamic "taints" {
for_each = each.value.taints
content {
key = taints.value.key
value = taints.value.value
effect = taints.value.effect
}
}
}