2017-08-13 22:02:52 +02:00
|
|
|
# Controller Instance DNS records
|
2017-07-29 20:35:53 +02:00
|
|
|
resource "digitalocean_record" "controllers" {
|
|
|
|
count = "${var.controller_count}"
|
|
|
|
|
|
|
|
# DNS zone where record should be created
|
|
|
|
domain = "${var.dns_zone}"
|
2017-08-13 03:25:05 +02:00
|
|
|
|
2017-08-13 22:02:52 +02:00
|
|
|
# DNS record (will be prepended to domain)
|
|
|
|
name = "${var.cluster_name}"
|
|
|
|
type = "A"
|
|
|
|
ttl = 300
|
|
|
|
|
|
|
|
# IPv4 addresses of controllers
|
2017-07-29 20:35:53 +02:00
|
|
|
value = "${element(digitalocean_droplet.controllers.*.ipv4_address, count.index)}"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Controller droplet instances
|
|
|
|
resource "digitalocean_droplet" "controllers" {
|
|
|
|
count = "${var.controller_count}"
|
|
|
|
|
2017-08-13 03:25:05 +02:00
|
|
|
name = "${var.cluster_name}-controller-${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.controller_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
|
|
|
|
2017-07-29 20:35:53 +02:00
|
|
|
user_data = "${data.ct_config.controller_ign.rendered}"
|
2017-08-13 03:25:05 +02: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.controllers.id}",
|
2017-07-29 20:35:53 +02:00
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2017-08-13 02:03:01 +02:00
|
|
|
# Tag to label controllers
|
2017-07-29 20:35:53 +02:00
|
|
|
resource "digitalocean_tag" "controllers" {
|
|
|
|
name = "${var.cluster_name}-controller"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Controller Container Linux Config
|
|
|
|
data "template_file" "controller_config" {
|
|
|
|
template = "${file("${path.module}/cl/controller.yaml.tmpl")}"
|
|
|
|
|
|
|
|
vars = {
|
|
|
|
k8s_dns_service_ip = "${cidrhost(var.service_cidr, 10)}"
|
|
|
|
k8s_etcd_service_ip = "${cidrhost(var.service_cidr, 15)}"
|
|
|
|
kubeconfig_ca_cert = "${module.bootkube.ca_cert}"
|
|
|
|
kubeconfig_kubelet_cert = "${module.bootkube.kubelet_cert}"
|
|
|
|
kubeconfig_kubelet_key = "${module.bootkube.kubelet_key}"
|
|
|
|
kubeconfig_server = "${module.bootkube.server}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
data "ct_config" "controller_ign" {
|
|
|
|
content = "${data.template_file.controller_config.rendered}"
|
|
|
|
pretty_print = false
|
|
|
|
}
|