diff --git a/digital-ocean/container-linux/kubernetes/controllers.tf b/digital-ocean/container-linux/kubernetes/controllers.tf index 096bd774..d1d3fbc2 100644 --- a/digital-ocean/container-linux/kubernetes/controllers.tf +++ b/digital-ocean/container-linux/kubernetes/controllers.tf @@ -1,13 +1,16 @@ -# Controller DNS records +# Controller Instance DNS records resource "digitalocean_record" "controllers" { count = "${var.controller_count}" # DNS zone where record should be created domain = "${var.dns_zone}" - name = "${var.cluster_name}" - type = "A" - ttl = 300 + # DNS record (will be prepended to domain) + name = "${var.cluster_name}" + type = "A" + ttl = 300 + + # IPv4 addresses of controllers value = "${element(digitalocean_droplet.controllers.*.ipv4_address, count.index)}" } diff --git a/digital-ocean/container-linux/kubernetes/variables.tf b/digital-ocean/container-linux/kubernetes/variables.tf index 5fae73a5..cb72a2e7 100644 --- a/digital-ocean/container-linux/kubernetes/variables.tf +++ b/digital-ocean/container-linux/kubernetes/variables.tf @@ -44,7 +44,7 @@ variable "worker_count" { variable "ssh_fingerprints" { type = "list" - description = "SSH public key fingerprints. Use ssh-add -l -E md5." + description = "SSH public key fingerprints. (e.g. see `ssh-add -l -E md5`)" } # bootkube assets diff --git a/google-cloud/container-linux/controllers/network.tf b/google-cloud/container-linux/controllers/network.tf index 292645a6..0dbd5d17 100644 --- a/google-cloud/container-linux/controllers/network.tf +++ b/google-cloud/container-linux/controllers/network.tf @@ -1,16 +1,14 @@ -# DNS record set to the network load balancer over controllers -resource "google_dns_record_set" "k8s_dns" { - # Managed DNS Zone name - managed_zone = "${var.dns_base_zone_name}" - - # Name of the DNS record - #name = "${format("%s.%s.", var.cluster_name, var.dns_base_zone)}" - name = "${var.k8s_domain_name}." +# Controller Network Load balancer DNS record +resource "google_dns_record_set" "controllers" { + # DNS Zone name where record should be created + managed_zone = "${var.dns_zone_name}" + # DNS record + name = "${format("%s.%s.", var.cluster_name, var.dns_zone)}" type = "A" ttl = 300 - # compute instance public IP + # IPv4 address of controllers' network load balancer rrdatas = ["${google_compute_address.controllers-ip.address}"] } diff --git a/google-cloud/container-linux/controllers/variables.tf b/google-cloud/container-linux/controllers/variables.tf index ce8af7cd..7d37d144 100644 --- a/google-cloud/container-linux/controllers/variables.tf +++ b/google-cloud/container-linux/controllers/variables.tf @@ -13,21 +13,16 @@ variable "network" { description = "Name of the network to attach to the compute instance interfaces" } -variable "dns_base_zone" { +variable "dns_zone" { type = "string" description = "Google Cloud DNS Zone value to create etcd/k8s subdomains (e.g. dghubble.io)" } -variable "dns_base_zone_name" { +variable "dns_zone_name" { type = "string" description = "Google Cloud DNS Zone name to create etcd/k8s subdomains (e.g. dghubble-io)" } -variable "k8s_domain_name" { - type = "string" - description = "Controller DNS name which resolves to the controller instance. Kubectl and workers use TLS client credentials to communicate via this endpoint." -} - # instances variable "count" { diff --git a/google-cloud/container-linux/kubernetes/bootkube.tf b/google-cloud/container-linux/kubernetes/bootkube.tf index 3f9fbb82..5f94ab94 100644 --- a/google-cloud/container-linux/kubernetes/bootkube.tf +++ b/google-cloud/container-linux/kubernetes/bootkube.tf @@ -3,7 +3,7 @@ module "bootkube" { source = "git::https://github.com/purenetes/bootkube-terraform.git?ref=v0.6.0" cluster_name = "${var.cluster_name}" - api_servers = ["${var.k8s_domain_name}"] + api_servers = ["${format("%s.%s", var.cluster_name, var.dns_zone)}"] etcd_servers = ["http://127.0.0.1:2379"] asset_dir = "${var.asset_dir}" pod_cidr = "${var.pod_cidr}" diff --git a/google-cloud/container-linux/kubernetes/cluster.tf b/google-cloud/container-linux/kubernetes/cluster.tf index d709bba8..d0f4feaf 100644 --- a/google-cloud/container-linux/kubernetes/cluster.tf +++ b/google-cloud/container-linux/kubernetes/cluster.tf @@ -4,15 +4,14 @@ module "controllers" { ssh_authorized_key = "${var.ssh_authorized_key}" # GCE - network = "${google_compute_network.network.name}" - count = "${var.controller_count}" - dns_base_zone = "${var.dns_base_zone}" - dns_base_zone_name = "${var.dns_base_zone_name}" - k8s_domain_name = "${var.k8s_domain_name}" - zone = "${var.zone}" - machine_type = "${var.machine_type}" - os_image = "${var.os_image}" - preemptible = "${var.controller_preemptible}" + network = "${google_compute_network.network.name}" + count = "${var.controller_count}" + zone = "${var.zone}" + dns_zone = "${var.dns_zone}" + dns_zone_name = "${var.dns_zone_name}" + machine_type = "${var.machine_type}" + os_image = "${var.os_image}" + preemptible = "${var.controller_preemptible}" # configuration service_cidr = "${var.service_cidr}" diff --git a/google-cloud/container-linux/kubernetes/ssh.tf b/google-cloud/container-linux/kubernetes/ssh.tf index 8661116a..652c493a 100644 --- a/google-cloud/container-linux/kubernetes/ssh.tf +++ b/google-cloud/container-linux/kubernetes/ssh.tf @@ -6,7 +6,7 @@ resource "null_resource" "bootkube-start" { # TODO: SSH to a controller's IP instead of waiting on DNS resolution connection { type = "ssh" - host = "${var.k8s_domain_name}" + host = "${format("%s.%s", var.cluster_name, var.dns_zone)}" user = "core" timeout = "15m" } diff --git a/google-cloud/container-linux/kubernetes/variables.tf b/google-cloud/container-linux/kubernetes/variables.tf index 0ab0cfdd..25f16408 100644 --- a/google-cloud/container-linux/kubernetes/variables.tf +++ b/google-cloud/container-linux/kubernetes/variables.tf @@ -3,40 +3,35 @@ variable "cluster_name" { description = "Cluster name" } -variable "ssh_authorized_key" { - type = "string" - description = "SSH public key for logging in as user 'core'" -} - -variable "dns_base_zone" { - type = "string" - description = "Google Cloud DNS Zone value to create etcd/k8s subdomains (e.g. dghubble.io)" -} - -variable "dns_base_zone_name" { - type = "string" - description = "Google Cloud DNS Zone name to create etcd/k8s subdomains (e.g. dghubble-io)" -} - -variable "k8s_domain_name" { - type = "string" - description = "Controller DNS name which resolves to the controller instance. Kubectl and workers use TLS client credentials to communicate via this endpoint." -} - variable "zone" { type = "string" - description = "Google zone that compute instances should be created in (e.g. gcloud compute zones list)" + description = "Google Cloud zone (e.g. us-central1-f, see `gcloud compute zones list`)" +} + +variable "dns_zone" { + type = "string" + description = "Google Cloud DNS Zone (e.g. google-cloud.dghubble.io)" +} + +variable "dns_zone_name" { + type = "string" + description = "Google Cloud DNS Zone name (e.g. google-cloud-prod-zone)" +} + +variable "ssh_authorized_key" { + type = "string" + description = "SSH public key for user 'core'" } variable "machine_type" { type = "string" default = "n1-standard-1" - description = "Machine type for compute instances (e.g. gcloud compute machine-types list)" + description = "Machine type for compute instances (see `gcloud compute machine-types list`)" } variable "os_image" { type = "string" - description = "OS image from which to initialize the disk (e.g. gcloud compute images list)" + description = "OS image from which to initialize the disk (see `gcloud compute images list`)" } variable "controller_count" {