-
Notifications
You must be signed in to change notification settings - Fork 19
/
instances-worker.tf
48 lines (40 loc) · 1.48 KB
/
instances-worker.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
locals {
worker_prefix = "worker"
worker_labels = "project.io/node-pool=worker"
}
resource "scaleway_instance_ip" "worker_v6" {
count = lookup(try(var.instances[var.regions[0]], {}), "worker_count", 0)
type = "routed_ipv6"
}
resource "scaleway_instance_server" "worker" {
count = lookup(try(var.instances[var.regions[0]], {}), "worker_count", 0)
name = "${local.worker_prefix}-${count.index + 1}"
image = data.scaleway_instance_image.talos[length(regexall("^COPARM1", lookup(try(var.instances[var.regions[0]], {}), "worker_type", 0))) > 0 ? "arm64" : "amd64"].id
type = lookup(var.instances[var.regions[0]], "worker_type", "DEV1-M")
security_group_id = scaleway_instance_security_group.worker.id
tags = concat(var.tags, ["worker"])
routed_ip_enabled = true
ip_ids = [scaleway_instance_ip.worker_v6[count.index].id]
private_network {
pn_id = scaleway_vpc_private_network.main.id
}
root_volume {
size_in_gb = 20
}
user_data = {
cloud-init = templatefile("${path.module}/templates/worker.yaml.tpl",
merge(local.kubernetes, try(var.instances["all"], {}), {
ipv4_vip = local.ipv4_vip
nodeSubnets = [one(scaleway_vpc_private_network.main.ipv4_subnet).subnet, one(scaleway_vpc_private_network.main.ipv6_subnets).subnet]
labels = local.worker_labels
})
)
}
lifecycle {
ignore_changes = [
image,
type,
user_data,
]
}
}