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-05-28 00:37:36 +02:00
|
|
|
value = element(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" {
|
2019-05-28 00:37:36 +02:00
|
|
|
count = var.worker_count
|
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-05-28 00:37:36 +02:00
|
|
|
value = element(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
|
|
|
|
2019-05-28 00:37:36 +02:00
|
|
|
image = var.image
|
|
|
|
size = var.worker_type
|
2017-08-13 03:25:05 +02:00
|
|
|
|
2017-07-29 20:35:53 +02:00
|
|
|
# network
|
2017-08-13 03:25:05 +02:00
|
|
|
ipv6 = true
|
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-05-28 00:37:36 +02:00
|
|
|
template = file("${path.module}/cl/worker.yaml.tmpl")
|
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
|
|
|
|