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" {
|
2017-07-29 20:35:53 +02:00
|
|
|
count = "${var.worker_count}"
|
|
|
|
|
|
|
|
# DNS zone where record should be created
|
|
|
|
domain = "${var.dns_zone}"
|
|
|
|
|
2017-08-13 03:25:05 +02:00
|
|
|
name = "${var.cluster_name}-workers"
|
|
|
|
type = "A"
|
|
|
|
ttl = 300
|
2017-07-29 20:35:53 +02:00
|
|
|
value = "${element(digitalocean_droplet.workers.*.ipv4_address, count.index)}"
|
|
|
|
}
|
|
|
|
|
2018-10-28 07:01:50 +01:00
|
|
|
resource "digitalocean_record" "workers-record-aaaa" {
|
|
|
|
count = "${var.worker_count}"
|
|
|
|
|
|
|
|
# DNS zone where record should be created
|
|
|
|
domain = "${var.dns_zone}"
|
|
|
|
|
|
|
|
name = "${var.cluster_name}-workers"
|
|
|
|
type = "AAAA"
|
|
|
|
ttl = 300
|
|
|
|
value = "${element(digitalocean_droplet.workers.*.ipv6_address, count.index)}"
|
|
|
|
}
|
|
|
|
|
2017-07-29 20:35:53 +02:00
|
|
|
# Worker droplet instances
|
|
|
|
resource "digitalocean_droplet" "workers" {
|
|
|
|
count = "${var.worker_count}"
|
|
|
|
|
2017-08-13 03:25:05 +02:00
|
|
|
name = "${var.cluster_name}-worker-${count.index}"
|
2017-07-29 20:35:53 +02:00
|
|
|
region = "${var.region}"
|
|
|
|
|
|
|
|
image = "${var.image}"
|
2017-08-13 03:25:05 +02:00
|
|
|
size = "${var.worker_type}"
|
|
|
|
|
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
|
|
|
|
2018-10-19 19:11:49 +02:00
|
|
|
user_data = "${data.ct_config.worker-ignition.rendered}"
|
2018-02-25 01:22:57 +01:00
|
|
|
ssh_keys = ["${var.ssh_fingerprints}"]
|
2017-07-29 20:35:53 +02:00
|
|
|
|
|
|
|
tags = [
|
2017-08-13 03:25:05 +02:00
|
|
|
"${digitalocean_tag.workers.id}",
|
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" {
|
|
|
|
content = "${data.template_file.worker-config.rendered}"
|
|
|
|
pretty_print = false
|
|
|
|
snippets = ["${var.worker_clc_snippets}"]
|
|
|
|
}
|
|
|
|
|
|
|
|
# Worker Container Linux config
|
|
|
|
data "template_file" "worker-config" {
|
2017-07-29 20:35:53 +02:00
|
|
|
template = "${file("${path.module}/cl/worker.yaml.tmpl")}"
|
|
|
|
|
|
|
|
vars = {
|
2017-12-09 22:36:59 +01:00
|
|
|
k8s_dns_service_ip = "${cidrhost(var.service_cidr, 10)}"
|
|
|
|
cluster_domain_suffix = "${var.cluster_domain_suffix}"
|
2017-07-29 20:35:53 +02:00
|
|
|
}
|
|
|
|
}
|