-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkubernetes.tf
65 lines (54 loc) · 1.5 KB
/
kubernetes.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
resource "digitalocean_kubernetes_cluster" "k8s" {
for_each = var.k8s_clusters
name = each.key
region = each.value.region
version = each.value.version
auto_upgrade = each.value.auto_upgrade
surge_upgrade = each.value.surge_upgrade
ha = each.value.high_availability
maintenance_policy {
start_time = each.value.maintenance_start_time
day = each.value.maintenance_day
}
node_pool {
name = "${each.key}-pool"
size = each.value.size
node_count = each.value.node_count
auto_scale = each.value.auto_scale
min_nodes = each.value.min_nodes
max_nodes = each.value.max_nodes
}
lifecycle {
ignore_changes = [
node_pool
]
}
}
resource "local_file" "kubeconfig" {
for_each = data.digitalocean_kubernetes_cluster.k8s
filename = "${var.kubeconfig_path}/${each.key}-kubeconfig.yaml"
content = each.value.kube_config[0].raw_config
depends_on = [
digitalocean_kubernetes_cluster.k8s
]
lifecycle {
ignore_changes = [
content
]
}
}
resource "digitalocean_kubernetes_node_pool" "k8sNodePool" {
for_each = var.k8s_clusters_node_pool
cluster_id = digitalocean_kubernetes_cluster.k8s[each.value.k8s_name].id
name = "${each.key}-pool"
size = each.value.size
node_count = each.value.node_count
auto_scale = each.value.auto_scale
min_nodes = each.value.min_nodes
max_nodes = each.value.max_nodes
lifecycle {
ignore_changes = [
node_count
]
}
}