typhoon/digital-ocean/container-linux/kubernetes/workers.tf

55 lines
1.3 KiB
Terraform
Raw Normal View History

# Worker DNS records
resource "digitalocean_record" "workers" {
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
value = "${element(digitalocean_droplet.workers.*.ipv4_address, count.index)}"
}
# 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}"
region = "${var.region}"
image = "${var.image}"
2017-08-13 03:25:05 +02:00
size = "${var.worker_type}"
# network
2017-08-13 03:25:05 +02:00
ipv6 = true
private_networking = true
2017-08-13 03:25:05 +02:00
user_data = "${data.ct_config.worker_ign.rendered}"
ssh_keys = ["${var.ssh_fingerprints}"]
tags = [
2017-08-13 03:25:05 +02:00
"${digitalocean_tag.workers.id}",
]
}
# Tag to label workers
resource "digitalocean_tag" "workers" {
name = "${var.cluster_name}-worker"
}
# Worker Container Linux Config
data "template_file" "worker_config" {
template = "${file("${path.module}/cl/worker.yaml.tmpl")}"
vars = {
k8s_dns_service_ip = "${cidrhost(var.service_cidr, 10)}"
cluster_domain_suffix = "${var.cluster_domain_suffix}"
}
}
data "ct_config" "worker_ign" {
content = "${data.template_file.worker_config.rendered}"
pretty_print = false
}