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
|
2020-02-13 23:18:41 +01:00
|
|
|
# only official DigitalOcean images support IPv6
|
|
|
|
ipv6 = local.is_official_image
|
2017-07-29 20:35:53 +02:00
|
|
|
private_networking = true
|
2017-08-13 03:25:05 +02:00
|
|
|
|
2019-05-28 00:37:36 +02:00
|
|
|
user_data = data.ct_config.worker-ignition.rendered
|
|
|
|
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"
|
|
|
|
}
|
|
|
|
|
2018-10-28 01:24:59 +02:00
|
|
|
# Worker Ignition config
|
|
|
|
data "ct_config" "worker-ignition" {
|
2019-05-28 00:37:36 +02:00
|
|
|
content = data.template_file.worker-config.rendered
|
2018-10-28 01:24:59 +02:00
|
|
|
pretty_print = false
|
2019-05-28 00:37:36 +02:00
|
|
|
snippets = var.worker_clc_snippets
|
2018-10-28 01:24:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Worker Container Linux config
|
|
|
|
data "template_file" "worker-config" {
|
2019-12-28 21:07:10 +01:00
|
|
|
template = file("${path.module}/cl/worker.yaml")
|
2017-07-29 20:35:53 +02:00
|
|
|
|
|
|
|
vars = {
|
2019-05-28 00:37:36 +02:00
|
|
|
cluster_dns_service_ip = cidrhost(var.service_cidr, 10)
|
|
|
|
cluster_domain_suffix = var.cluster_domain_suffix
|
2017-07-29 20:35:53 +02:00
|
|
|
}
|
|
|
|
}
|
2019-05-28 00:37:36 +02:00
|
|
|
|