Refactor GCP to remove controller internal module
* Remove the controller internal module to align with other platforms and since its not a supported use case
This commit is contained in:
parent
9bb3de5327
commit
5035d56db2
|
@ -16,6 +16,10 @@ Notable changes between versions.
|
||||||
* To SSH during a disk install for debugging, SSH as user "core" with port 2222
|
* To SSH during a disk install for debugging, SSH as user "core" with port 2222
|
||||||
* Remove the old trick of using a user "debug" during disk install
|
* Remove the old trick of using a user "debug" during disk install
|
||||||
|
|
||||||
|
#### Google Cloud
|
||||||
|
|
||||||
|
* Refactor out the `controller` internal module
|
||||||
|
|
||||||
#### Addons
|
#### Addons
|
||||||
|
|
||||||
* Add Prometheus discovery for etcd peers on controller nodes ([#175](https://github.com/poseidon/typhoon/pull/175))
|
* Add Prometheus discovery for etcd peers on controller nodes ([#175](https://github.com/poseidon/typhoon/pull/175))
|
||||||
|
|
|
@ -17,7 +17,7 @@ resource "google_dns_record_set" "controllers" {
|
||||||
rrdatas = ["${google_compute_address.controllers-ip.address}"]
|
rrdatas = ["${google_compute_address.controllers-ip.address}"]
|
||||||
}
|
}
|
||||||
|
|
||||||
# Network Load Balancer (i.e. forwarding rule)
|
# Network Load Balancer for controllers
|
||||||
resource "google_compute_forwarding_rule" "controller-https-rule" {
|
resource "google_compute_forwarding_rule" "controller-https-rule" {
|
||||||
name = "${var.cluster_name}-controller-https-rule"
|
name = "${var.cluster_name}-controller-https-rule"
|
||||||
ip_address = "${google_compute_address.controllers-ip.address}"
|
ip_address = "${google_compute_address.controllers-ip.address}"
|
|
@ -4,7 +4,7 @@ module "bootkube" {
|
||||||
|
|
||||||
cluster_name = "${var.cluster_name}"
|
cluster_name = "${var.cluster_name}"
|
||||||
api_servers = ["${format("%s.%s", var.cluster_name, var.dns_zone)}"]
|
api_servers = ["${format("%s.%s", var.cluster_name, var.dns_zone)}"]
|
||||||
etcd_servers = "${module.controllers.etcd_fqdns}"
|
etcd_servers = ["${null_resource.repeat.*.triggers.domain}"]
|
||||||
asset_dir = "${var.asset_dir}"
|
asset_dir = "${var.asset_dir}"
|
||||||
networking = "${var.networking}"
|
networking = "${var.networking}"
|
||||||
network_mtu = 1440
|
network_mtu = 1440
|
||||||
|
|
|
@ -1,44 +0,0 @@
|
||||||
module "controllers" {
|
|
||||||
source = "controllers"
|
|
||||||
cluster_name = "${var.cluster_name}"
|
|
||||||
|
|
||||||
# GCE
|
|
||||||
region = "${var.region}"
|
|
||||||
network = "${google_compute_network.network.name}"
|
|
||||||
dns_zone = "${var.dns_zone}"
|
|
||||||
dns_zone_name = "${var.dns_zone_name}"
|
|
||||||
count = "${var.controller_count}"
|
|
||||||
machine_type = "${var.controller_type}"
|
|
||||||
os_image = "${var.os_image}"
|
|
||||||
disk_size = "${var.disk_size}"
|
|
||||||
|
|
||||||
# configuration
|
|
||||||
networking = "${var.networking}"
|
|
||||||
kubeconfig = "${module.bootkube.kubeconfig}"
|
|
||||||
ssh_authorized_key = "${var.ssh_authorized_key}"
|
|
||||||
service_cidr = "${var.service_cidr}"
|
|
||||||
cluster_domain_suffix = "${var.cluster_domain_suffix}"
|
|
||||||
clc_snippets = "${var.controller_clc_snippets}"
|
|
||||||
}
|
|
||||||
|
|
||||||
module "workers" {
|
|
||||||
source = "workers"
|
|
||||||
name = "${var.cluster_name}"
|
|
||||||
cluster_name = "${var.cluster_name}"
|
|
||||||
|
|
||||||
# GCE
|
|
||||||
region = "${var.region}"
|
|
||||||
network = "${google_compute_network.network.name}"
|
|
||||||
count = "${var.worker_count}"
|
|
||||||
machine_type = "${var.worker_type}"
|
|
||||||
os_image = "${var.os_image}"
|
|
||||||
disk_size = "${var.disk_size}"
|
|
||||||
preemptible = "${var.worker_preemptible}"
|
|
||||||
|
|
||||||
# configuration
|
|
||||||
kubeconfig = "${module.bootkube.kubeconfig}"
|
|
||||||
ssh_authorized_key = "${var.ssh_authorized_key}"
|
|
||||||
service_cidr = "${var.service_cidr}"
|
|
||||||
cluster_domain_suffix = "${var.cluster_domain_suffix}"
|
|
||||||
clc_snippets = "${var.worker_clc_snippets}"
|
|
||||||
}
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Discrete DNS records for each controller's private IPv4 for etcd usage
|
# Discrete DNS records for each controller's private IPv4 for etcd usage
|
||||||
resource "google_dns_record_set" "etcds" {
|
resource "google_dns_record_set" "etcds" {
|
||||||
count = "${var.count}"
|
count = "${var.controller_count}"
|
||||||
|
|
||||||
# DNS Zone name where record should be created
|
# DNS Zone name where record should be created
|
||||||
managed_zone = "${var.dns_zone_name}"
|
managed_zone = "${var.dns_zone_name}"
|
||||||
|
@ -21,11 +21,11 @@ data "google_compute_zones" "all" {
|
||||||
|
|
||||||
# Controller instances
|
# Controller instances
|
||||||
resource "google_compute_instance" "controllers" {
|
resource "google_compute_instance" "controllers" {
|
||||||
count = "${var.count}"
|
count = "${var.controller_count}"
|
||||||
|
|
||||||
name = "${var.cluster_name}-controller-${count.index}"
|
name = "${var.cluster_name}-controller-${count.index}"
|
||||||
zone = "${element(data.google_compute_zones.all.names, count.index)}"
|
zone = "${element(data.google_compute_zones.all.names, count.index)}"
|
||||||
machine_type = "${var.machine_type}"
|
machine_type = "${var.controller_type}"
|
||||||
|
|
||||||
metadata {
|
metadata {
|
||||||
user-data = "${element(data.ct_config.controller_ign.*.rendered, count.index)}"
|
user-data = "${element(data.ct_config.controller_ign.*.rendered, count.index)}"
|
||||||
|
@ -41,7 +41,7 @@ resource "google_compute_instance" "controllers" {
|
||||||
}
|
}
|
||||||
|
|
||||||
network_interface {
|
network_interface {
|
||||||
network = "${var.network}"
|
network = "${google_compute_network.network.name}"
|
||||||
|
|
||||||
# Ephemeral external IP
|
# Ephemeral external IP
|
||||||
access_config = {}
|
access_config = {}
|
||||||
|
@ -51,9 +51,13 @@ resource "google_compute_instance" "controllers" {
|
||||||
tags = ["${var.cluster_name}-controller"]
|
tags = ["${var.cluster_name}-controller"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
locals {
|
||||||
|
controllers_ipv4_public = ["${google_compute_instance.controllers.*.network_interface.0.access_config.0.assigned_nat_ip}"]
|
||||||
|
}
|
||||||
|
|
||||||
# Controller Container Linux Config
|
# Controller Container Linux Config
|
||||||
data "template_file" "controller_config" {
|
data "template_file" "controller_config" {
|
||||||
count = "${var.count}"
|
count = "${var.controller_count}"
|
||||||
|
|
||||||
template = "${file("${path.module}/cl/controller.yaml.tmpl")}"
|
template = "${file("${path.module}/cl/controller.yaml.tmpl")}"
|
||||||
|
|
||||||
|
@ -65,7 +69,7 @@ data "template_file" "controller_config" {
|
||||||
# etcd0=https://cluster-etcd0.example.com,etcd1=https://cluster-etcd1.example.com,...
|
# etcd0=https://cluster-etcd0.example.com,etcd1=https://cluster-etcd1.example.com,...
|
||||||
etcd_initial_cluster = "${join(",", formatlist("%s=https://%s:2380", null_resource.repeat.*.triggers.name, null_resource.repeat.*.triggers.domain))}"
|
etcd_initial_cluster = "${join(",", formatlist("%s=https://%s:2380", null_resource.repeat.*.triggers.name, null_resource.repeat.*.triggers.domain))}"
|
||||||
|
|
||||||
kubeconfig = "${indent(10, var.kubeconfig)}"
|
kubeconfig = "${indent(10, module.bootkube.kubeconfig)}"
|
||||||
ssh_authorized_key = "${var.ssh_authorized_key}"
|
ssh_authorized_key = "${var.ssh_authorized_key}"
|
||||||
k8s_dns_service_ip = "${cidrhost(var.service_cidr, 10)}"
|
k8s_dns_service_ip = "${cidrhost(var.service_cidr, 10)}"
|
||||||
cluster_domain_suffix = "${var.cluster_domain_suffix}"
|
cluster_domain_suffix = "${var.cluster_domain_suffix}"
|
||||||
|
@ -75,7 +79,7 @@ data "template_file" "controller_config" {
|
||||||
# Horrible hack to generate a Terraform list of a desired length without dependencies.
|
# Horrible hack to generate a Terraform list of a desired length without dependencies.
|
||||||
# Ideal ${repeat("etcd", 3) -> ["etcd", "etcd", "etcd"]}
|
# Ideal ${repeat("etcd", 3) -> ["etcd", "etcd", "etcd"]}
|
||||||
resource null_resource "repeat" {
|
resource null_resource "repeat" {
|
||||||
count = "${var.count}"
|
count = "${var.controller_count}"
|
||||||
|
|
||||||
triggers {
|
triggers {
|
||||||
name = "etcd${count.index}"
|
name = "etcd${count.index}"
|
||||||
|
@ -84,8 +88,8 @@ resource null_resource "repeat" {
|
||||||
}
|
}
|
||||||
|
|
||||||
data "ct_config" "controller_ign" {
|
data "ct_config" "controller_ign" {
|
||||||
count = "${var.count}"
|
count = "${var.controller_count}"
|
||||||
content = "${element(data.template_file.controller_config.*.rendered, count.index)}"
|
content = "${element(data.template_file.controller_config.*.rendered, count.index)}"
|
||||||
pretty_print = false
|
pretty_print = false
|
||||||
snippets = ["${var.clc_snippets}"]
|
snippets = ["${var.controller_clc_snippets}"]
|
||||||
}
|
}
|
|
@ -1,7 +0,0 @@
|
||||||
output "etcd_fqdns" {
|
|
||||||
value = ["${null_resource.repeat.*.triggers.domain}"]
|
|
||||||
}
|
|
||||||
|
|
||||||
output "ipv4_public" {
|
|
||||||
value = ["${google_compute_instance.controllers.*.network_interface.0.access_config.0.assigned_nat_ip}"]
|
|
||||||
}
|
|
|
@ -1,87 +0,0 @@
|
||||||
variable "cluster_name" {
|
|
||||||
type = "string"
|
|
||||||
description = "Unique cluster name"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "region" {
|
|
||||||
type = "string"
|
|
||||||
description = "Google Cloud region (e.g. us-central1, see `gcloud compute regions list`)."
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "network" {
|
|
||||||
type = "string"
|
|
||||||
description = "Name of the network to attach to the compute instance interfaces"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "dns_zone" {
|
|
||||||
type = "string"
|
|
||||||
description = "Google Cloud DNS Zone value to create etcd/k8s subdomains (e.g. dghubble.io)"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "dns_zone_name" {
|
|
||||||
type = "string"
|
|
||||||
description = "Google Cloud DNS Zone name to create etcd/k8s subdomains (e.g. dghubble-io)"
|
|
||||||
}
|
|
||||||
|
|
||||||
# instances
|
|
||||||
|
|
||||||
variable "count" {
|
|
||||||
type = "string"
|
|
||||||
description = "Number of controller compute instances the instance group should manage"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "machine_type" {
|
|
||||||
type = "string"
|
|
||||||
description = "Machine type for compute instances (e.g. 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)"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "disk_size" {
|
|
||||||
type = "string"
|
|
||||||
default = "40"
|
|
||||||
description = "Size of the disk in GB"
|
|
||||||
}
|
|
||||||
|
|
||||||
# configuration
|
|
||||||
|
|
||||||
variable "networking" {
|
|
||||||
description = "Choice of networking provider (flannel or calico)"
|
|
||||||
type = "string"
|
|
||||||
default = "calico"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "kubeconfig" {
|
|
||||||
type = "string"
|
|
||||||
description = "Generated Kubelet kubeconfig"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "ssh_authorized_key" {
|
|
||||||
type = "string"
|
|
||||||
description = "SSH public key for logging in as user 'core'"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "service_cidr" {
|
|
||||||
description = <<EOD
|
|
||||||
CIDR IPv4 range to assign Kubernetes services.
|
|
||||||
The 1st IP will be reserved for kube_apiserver, the 10th IP will be reserved for kube-dns.
|
|
||||||
EOD
|
|
||||||
|
|
||||||
type = "string"
|
|
||||||
default = "10.3.0.0/16"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "cluster_domain_suffix" {
|
|
||||||
description = "Queries for domains with the suffix will be answered by kube-dns. Default is cluster.local (e.g. foo.default.svc.cluster.local) "
|
|
||||||
type = "string"
|
|
||||||
default = "cluster.local"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "clc_snippets" {
|
|
||||||
type = "list"
|
|
||||||
description = "Container Linux Config snippets"
|
|
||||||
default = []
|
|
||||||
}
|
|
|
@ -1,19 +1,22 @@
|
||||||
|
# Deprecated
|
||||||
output "controllers_ipv4_public" {
|
output "controllers_ipv4_public" {
|
||||||
value = ["${module.controllers.ipv4_public}"]
|
value = ["${google_compute_instance.controllers.*.network_interface.0.access_config.0.assigned_nat_ip}"]
|
||||||
}
|
}
|
||||||
|
|
||||||
output "ingress_static_ip" {
|
output "ingress_static_ip" {
|
||||||
value = "${module.workers.ingress_static_ip}"
|
value = "${module.workers.ingress_static_ip}"
|
||||||
}
|
}
|
||||||
|
|
||||||
output "network_name" {
|
|
||||||
value = "${google_compute_network.network.name}"
|
|
||||||
}
|
|
||||||
|
|
||||||
output "network_self_link" {
|
output "network_self_link" {
|
||||||
value = "${google_compute_network.network.self_link}"
|
value = "${google_compute_network.network.self_link}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Outputs for worker pools
|
||||||
|
|
||||||
|
output "network_name" {
|
||||||
|
value = "${google_compute_network.network.name}"
|
||||||
|
}
|
||||||
|
|
||||||
output "kubeconfig" {
|
output "kubeconfig" {
|
||||||
value = "${module.bootkube.kubeconfig}"
|
value = "${module.bootkube.kubeconfig}"
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ resource "null_resource" "copy-controller-secrets" {
|
||||||
|
|
||||||
connection {
|
connection {
|
||||||
type = "ssh"
|
type = "ssh"
|
||||||
host = "${element(module.controllers.ipv4_public, count.index)}"
|
host = "${element(local.controllers_ipv4_public, count.index)}"
|
||||||
user = "core"
|
user = "core"
|
||||||
timeout = "15m"
|
timeout = "15m"
|
||||||
}
|
}
|
||||||
|
@ -65,14 +65,14 @@ resource "null_resource" "copy-controller-secrets" {
|
||||||
resource "null_resource" "bootkube-start" {
|
resource "null_resource" "bootkube-start" {
|
||||||
depends_on = [
|
depends_on = [
|
||||||
"module.bootkube",
|
"module.bootkube",
|
||||||
"module.controllers",
|
|
||||||
"module.workers",
|
"module.workers",
|
||||||
|
"google_dns_record_set.controllers",
|
||||||
"null_resource.copy-controller-secrets",
|
"null_resource.copy-controller-secrets",
|
||||||
]
|
]
|
||||||
|
|
||||||
connection {
|
connection {
|
||||||
type = "ssh"
|
type = "ssh"
|
||||||
host = "${element(module.controllers.ipv4_public, 0)}"
|
host = "${element(local.controllers_ipv4_public, 0)}"
|
||||||
user = "core"
|
user = "core"
|
||||||
timeout = "15m"
|
timeout = "15m"
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
module "workers" {
|
||||||
|
source = "workers"
|
||||||
|
name = "${var.cluster_name}"
|
||||||
|
cluster_name = "${var.cluster_name}"
|
||||||
|
|
||||||
|
# GCE
|
||||||
|
region = "${var.region}"
|
||||||
|
network = "${google_compute_network.network.name}"
|
||||||
|
count = "${var.worker_count}"
|
||||||
|
machine_type = "${var.worker_type}"
|
||||||
|
os_image = "${var.os_image}"
|
||||||
|
disk_size = "${var.disk_size}"
|
||||||
|
preemptible = "${var.worker_preemptible}"
|
||||||
|
|
||||||
|
# configuration
|
||||||
|
kubeconfig = "${module.bootkube.kubeconfig}"
|
||||||
|
ssh_authorized_key = "${var.ssh_authorized_key}"
|
||||||
|
service_cidr = "${var.service_cidr}"
|
||||||
|
cluster_domain_suffix = "${var.cluster_domain_suffix}"
|
||||||
|
clc_snippets = "${var.worker_clc_snippets}"
|
||||||
|
}
|
Loading…
Reference in New Issue