Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make load balancers optional for MIGs #108

Merged
merged 4 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 104 additions & 40 deletions mlab-oti/platform-cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,137 +15,201 @@ module "platform-cluster" {
mig_min_replicas = 1
mig_max_replicas = 5
network_tier = "PREMIUM"
probability = 1.0
tags = ["ndt-cloud"]
scopes = ["cloud-platform"]
}
migs = {
mlab1-ams11 = {
region = "europe-west4"
region = "europe-west4"
loadbalanced = true
probability = 0.5
},
mlab1-ber02 = {
# We cannot currently get any N2 quota in this region.
machine_type = "e2-highcpu-4"
region = "europe-west10"
machine_type = "e2-highcpu-4"
loadbalanced = true
},
mlab1-bom06 = {
region = "asia-south1"
region = "asia-south1"
loadbalanced = true
probability = 0.5
},
mlab1-bru07 = {
region = "europe-west1"
region = "europe-west1"
loadbalanced = true
probability = 0.5
},
mlab1-cgk02 = {
region = "asia-southeast2"
region = "asia-southeast2"
loadbalanced = true
},
mlab1-chs02 = {
region = "us-east1"
region = "us-east1"
loadbalanced = true
},
mlab1-cmh02 = {
region = "us-east5"
region = "us-east5"
loadbalanced = true
},
mlab1-del05 = {
region = "asia-south2"
region = "asia-south2"
loadbalanced = true
probability = 0.5
},
mlab1-dfw12 = {
region = "us-south1"
region = "us-south1"
loadbalanced = true
probability = 0.5
},
mlab1-doh02 = {
# This region is new and we can't currently get any N2 quota.
machine_type = "e2-highcpu-4"
region = "me-central1"
machine_type = "e2-highcpu-4"
loadbalanced = true
},
mlab1-fra08 = {
region = "europe-west3"
region = "europe-west3"
loadbalanced = true
probability = 0.5
},
mlab1-gru06 = {
region = "southamerica-east1"
region = "southamerica-east1"
loadbalanced = true
probability = 0.5
},
mlab1-hel02 = {
region = "europe-north1"
region = "europe-north1"
loadbalanced = true
},
mlab1-hkg05 = {
region = "asia-east2"
region = "asia-east2"
loadbalanced = true
probability = 0.5
},
mlab1-hnd07 = {
region = "asia-northeast1"
region = "asia-northeast1"
loadbalanced = true
probability = 0.5
},
mlab1-iad09 = {
region = "us-east4"
region = "us-east4"
loadbalanced = true
probability = 0.5
},
mlab1-icn02 = {
region = "asia-northeast3"
region = "asia-northeast3"
loadbalanced = true
},
mlab1-jnb02 = {
# This region is new and we can't currently get any N2 quota.
machine_type = "e2-highcpu-4"
region = "africa-south1"
machine_type = "e2-highcpu-4"
loadbalanced = true
probability = 0.5
},
mlab1-kix02 = {
region = "asia-northeast2"
region = "asia-northeast2"
loadbalanced = true
},
mlab1-las02 = {
region = "us-west4"
region = "us-west4"
loadbalanced = true
},
mlab1-lax10 = {
region = "us-west2"
region = "us-west2"
loadbalanced = true
probability = 0.5
},
mlab1-lhr10 = {
region = "europe-west2"
region = "europe-west2"
loadbalanced = true
probability = 0.5
},
mlab1-mad08 = {
region = "europe-southwest1"
region = "europe-southwest1"
loadbalanced = true
probability = 0.5
},
mlab1-mel02 = {
region = "australia-southeast2"
region = "australia-southeast2"
loadbalanced = true
},
mlab1-mil09 = {
region = "europe-west8"
region = "europe-west8"
loadbalanced = true
probability = 0.5
},
mlab1-oma02 = {
region = "us-central1"
region = "us-central1"
loadbalanced = true
},
mlab1-par09 = {
region = "europe-west9"
region = "europe-west9"
loadbalanced = true
probability = 0.5
},
mlab1-pdx03 = {
region = "us-west1"
region = "us-west1"
loadbalanced = true
},
mlab1-scl06 = {
region = "southamerica-west1"
region = "southamerica-west1"
loadbalanced = true
probability = 0.5
},
mlab1-sin03 = {
region = "asia-southeast1"
region = "asia-southeast1"
loadbalanced = true
probability = 0.5
},
mlab1-slc02 = {
region = "us-west3"
region = "us-west3"
loadbalanced = true
},
mlab1-syd08 = {
region = "australia-southeast1"
region = "australia-southeast1"
loadbalanced = true
probability = 0.5
},
mlab1-tlv02 = {
region = "me-west1"
region = "me-west1"
loadbalanced = true
},
mlab1-tpe03 = {
region = "asia-east1"
region = "asia-east1"
loadbalanced = true
probability = 0.5
},
mlab1-trn04 = {
region = "europe-west12"
region = "europe-west12"
loadbalanced = true
probability = 0.5
},
mlab1-waw02 = {
region = "europe-central2"
region = "europe-central2"
loadbalanced = true
},
mlab1-yul08 = {
region = "northamerica-northeast1"
region = "northamerica-northeast1"
loadbalanced = true
probability = 0.5
},
mlab1-yyz08 = {
region = "northamerica-northeast2"
region = "northamerica-northeast2"
loadbalanced = true
probability = 0.5
}
mlab1-zrh02 = {
region = "europe-west6"
region = "europe-west6"
loadbalanced = true
}
}
vms = {
mlab1-par08 = {
zone = "europe-west9-c"
zone = "europe-west9-c"
probability = 0.5
},
mlab1-pdx01 = {
zone = "us-west1-c"
Expand Down
19 changes: 12 additions & 7 deletions mlab-sandbox/platform-cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,31 @@ module "platform-cluster" {
instances = {
attributes = {
daemonset = "ndt"
disk_image = "platform-cluster-instance-2024-09-12t22-10-23"
disk_image = "platform-cluster-instance-2024-11-27t00-16-26"
disk_size_gb = 100
disk_type = "pd-ssd"
machine_type = "n2-highcpu-4"
mig_min_replicas = 1
mig_max_replicas = 2
network_tier = "PREMIUM"
probability = 1.0
tags = ["ndt-cloud"]
scopes = ["cloud-platform"]
},
migs = {
mlab1-chs0t = {
region = "us-east1"
region = "us-east1"
loadbalanced = false
daemonset = "ndt-autojoin"
},
mlab1-lax0t = {
daemonset = "ndt-canary"
region = "us-west2"
region = "us-west2"
loadbalanced = true
daemonset = "ndt-canary"
},
mlab1-pdx0t = {
region = "us-west1"
region = "us-west1"
loadbalanced = true
}
},
vms = {
Expand All @@ -39,7 +44,7 @@ module "platform-cluster" {

api_instances = {
machine_attributes = {
disk_image = "platform-cluster-api-instance-2024-09-12t22-10-23"
disk_image = "platform-cluster-api-instance-2024-11-27t00-16-26"
disk_size_gb_boot = 100
disk_size_gb_data = 10
# This will show up as /dev/disk/by-id/google-<name>
Expand Down Expand Up @@ -73,7 +78,7 @@ module "platform-cluster" {
}

prometheus_instance = {
disk_image = "platform-cluster-internal-instance-2024-09-12t22-10-23"
disk_image = "platform-cluster-internal-instance-2024-11-27t00-16-26"
disk_size_gb_boot = 100
disk_size_gb_data = 200
disk_type = "pd-ssd"
Expand Down
4 changes: 3 additions & 1 deletion mlab-staging/platform-cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ module "platform-cluster" {
mig_min_replicas = 1
mig_max_replicas = 3
network_tier = "PREMIUM"
probability = 1.0
tags = ["ndt-cloud"]
scopes = ["cloud-platform"]
},
migs = {
mlab4-dfw13 = {
region = "us-south1"
region = "us-south1"
loadbalanced = true
}
},
vms = {
Expand Down
4 changes: 3 additions & 1 deletion modules/platform-cluster/instancegroups.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ resource "google_compute_instance_template" "platform_cluster_mig_templates" {
"mlab/site=${split("-", each.key)[1]}",
"mlab/type=virtual"
])
k8s_node = "${each.key}.${data.google_client_config.current.project}.measurement-lab.org"
k8s_node = "${each.key}.${data.google_client_config.current.project}.measurement-lab.org"
loadbalanced = each.value.loadbalanced
probability = lookup(each.value, "probability", var.instances.attributes.probability)
}

name_prefix = "platform-cluster-mig-template-"
Expand Down
5 changes: 3 additions & 2 deletions modules/platform-cluster/instances.tf
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ resource "google_compute_instance" "platform_instances" {
"mlab/site=${split("-", each.key)[1]}",
"mlab/type=virtual"
])
k8s_node = "${each.key}.${data.google_client_config.current.project}.measurement-lab.org"
k8s_node = "${each.key}.${data.google_client_config.current.project}.measurement-lab.org"
probability = lookup(each.value, "probability", var.instances.attributes.probability)
}

name = "${each.key}-${data.google_client_config.current.project}-measurement-lab-org"
Expand All @@ -134,7 +135,7 @@ resource "google_compute_instance" "platform_instances" {
}

ipv6_access_config {
external_ipv6 = google_compute_address.platform_addresses_v6["${each.key}"].address
external_ipv6 = google_compute_address.platform_addresses_v6["${each.key}"].address
external_ipv6_prefix_length = 96
# From what I gather STANDARD network tier is not available for IPv6.
# https://cloud.google.com/network-tiers/docs/overview#resources
Expand Down
12 changes: 6 additions & 6 deletions modules/platform-cluster/loadbalancers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
# Managed instance group load balancers for regular platfrom VMs
#
resource "google_compute_address" "platform_cluster_mig_addresses" {
for_each = var.instances.migs
for_each = { for k, v in var.instances.migs : k => v if v.loadbalanced }

address_type = "EXTERNAL"
name = "${each.key}-${data.google_client_config.current.project}-measurement-lab-org"
region = each.value["region"]
}

resource "google_compute_address" "platform_cluster_mig_addresses_v6" {
for_each = var.instances.migs
for_each = { for k, v in var.instances.migs : k => v if v.loadbalanced }

address_type = "EXTERNAL"
ipv6_endpoint_type = "NETLB"
Expand All @@ -21,7 +21,7 @@ resource "google_compute_address" "platform_cluster_mig_addresses_v6" {
}

resource "google_compute_region_health_check" "platform_cluster_mig_health_checks" {
for_each = var.instances.migs
for_each = { for k, v in var.instances.migs : k => v if v.loadbalanced }

https_health_check {
port = 443
Expand All @@ -32,7 +32,7 @@ resource "google_compute_region_health_check" "platform_cluster_mig_health_check
}

resource "google_compute_region_backend_service" "platform_cluster_mig_backends" {
for_each = var.instances.migs
for_each = { for k, v in var.instances.migs : k => v if v.loadbalanced }

backend {
group = google_compute_region_instance_group_manager.platform_cluster_mig_managers[each.key].instance_group
Expand All @@ -47,7 +47,7 @@ resource "google_compute_region_backend_service" "platform_cluster_mig_backends"
}

resource "google_compute_forwarding_rule" "platform_cluster_mig_forwarding_rules" {
for_each = var.instances.migs
for_each = { for k, v in var.instances.migs : k => v if v.loadbalanced }

all_ports = true
backend_service = google_compute_region_backend_service.platform_cluster_mig_backends[each.key].id
Expand All @@ -59,7 +59,7 @@ resource "google_compute_forwarding_rule" "platform_cluster_mig_forwarding_rules
}

resource "google_compute_forwarding_rule" "platform_cluster_mig_forwarding_rules_v6" {
for_each = var.instances.migs
for_each = { for k, v in var.instances.migs : k => v if v.loadbalanced }

all_ports = true
backend_service = google_compute_region_backend_service.platform_cluster_mig_backends[each.key].id
Expand Down
Loading