2017-07-29 20:35:53 +02:00
|
|
|
# Worker DNS records
|
2018-10-28 07:01:50 +01:00
|
|
|
resource "digitalocean_record" "workers-record-a" {
|
2019-05-28 00:37:36 +02:00
|
|
|
count = var.worker_count
|
2017-07-29 20:35:53 +02:00
|
|
|
|
|
|
|
# DNS zone where record should be created
|
2019-05-28 00:37:36 +02:00
|
|
|
domain = var.dns_zone
|
2017-07-29 20:35:53 +02:00
|
|
|
|
2017-08-13 03:25:05 +02:00
|
|
|
name = "${var.cluster_name}-workers"
|
|
|
|
type = "A"
|
|
|
|
ttl = 300
|
2019-12-28 21:07:10 +01:00
|
|
|
value = digitalocean_droplet.workers.*.ipv4_address[count.index]
|
2017-07-29 20:35:53 +02:00
|
|
|
}
|
|
|
|
|
2018-10-28 07:01:50 +01:00
|
|
|
resource "digitalocean_record" "workers-record-aaaa" {
|
2020-02-13 23:18:41 +01:00
|
|
|
# only official DigitalOcean images support IPv6
|
|
|
|
count = local.is_official_image ? var.worker_count : 0
|
2018-10-28 07:01:50 +01:00
|
|
|
|
|
|
|
# DNS zone where record should be created
|
2019-05-28 00:37:36 +02:00
|
|
|
domain = var.dns_zone
|
2018-10-28 07:01:50 +01:00
|
|
|
|
|
|
|
name = "${var.cluster_name}-workers"
|
|
|
|
type = "AAAA"
|
|
|
|
ttl = 300
|
2019-12-28 21:07:10 +01:00
|
|
|
value = digitalocean_droplet.workers.*.ipv6_address[count.index]
|
2018-10-28 07:01:50 +01:00
|
|
|
}
|
|
|
|
|
2017-07-29 20:35:53 +02:00
|
|
|
# Worker droplet instances
|
|
|
|
resource "digitalocean_droplet" "workers" {
|
2019-05-28 00:37:36 +02:00
|
|
|
count = var.worker_count
|
2017-07-29 20:35:53 +02:00
|
|
|
|
2017-08-13 03:25:05 +02:00
|
|
|
name = "${var.cluster_name}-worker-${count.index}"
|
2019-05-28 00:37:36 +02:00
|
|
|
region = var.region
|
2017-07-29 20:35:53 +02:00
|
|
|
|
2020-03-25 07:45:31 +01:00
|
|
|
image = var.os_image
|
2019-05-28 00:37:36 +02:00
|
|
|
size = var.worker_type
|
2017-08-13 03:25:05 +02:00
|
|
|
|
2017-07-29 20:35:53 +02:00
|
|
|
# network
|
2022-08-03 03:15:03 +02:00
|
|
|
vpc_uuid = digitalocean_vpc.network.id
|
2020-06-29 08:12:54 +02:00
|
|
|
# only official DigitalOcean images support IPv6
|
|
|
|
ipv6 = local.is_official_image
|
2017-08-13 03:25:05 +02:00
|
|
|
|
2022-08-03 03:15:03 +02:00
|
|
|
user_data = data.ct_config.worker.rendered
|
2019-05-28 00:37:36 +02:00
|
|
|
ssh_keys = var.ssh_fingerprints
|
2017-07-29 20:35:53 +02:00
|
|
|
|
|
|
|
tags = [
|
2019-05-28 00:37:36 +02:00
|
|
|
digitalocean_tag.workers.id,
|
2017-07-29 20:35:53 +02:00
|
|
|
]
|
2018-10-28 23:11:47 +01:00
|
|
|
|
|
|
|
lifecycle {
|
|
|
|
create_before_destroy = true
|
|
|
|
}
|
2017-07-29 20:35:53 +02:00
|
|
|
}
|
|
|
|
|
2017-08-13 02:03:01 +02:00
|
|
|
# Tag to label workers
|
2017-07-29 20:35:53 +02:00
|
|
|
resource "digitalocean_tag" "workers" {
|
|
|
|
name = "${var.cluster_name}-worker"
|
|
|
|
}
|
|
|
|
|
2022-08-03 03:15:03 +02:00
|
|
|
# Flatcar Linux worker
|
|
|
|
data "ct_config" "worker" {
|
2022-08-03 03:12:37 +02:00
|
|
|
content = templatefile("${path.module}/butane/worker.yaml", {
|
2019-05-28 00:37:36 +02:00
|
|
|
cluster_dns_service_ip = cidrhost(var.service_cidr, 10)
|
2022-08-03 03:15:03 +02:00
|
|
|
})
|
|
|
|
strict = true
|
|
|
|
snippets = var.worker_snippets
|
2017-07-29 20:35:53 +02:00
|
|
|
}
|