inline node pools so they can be created in parallel

speeds up cluster creation
This commit is contained in:
E M 2026-04-28 16:46:22 +10:00
parent 70ae988c9b
commit f2b26ae5eb
No known key found for this signature in database
3 changed files with 63 additions and 36 deletions

View File

@ -1,46 +1,30 @@
# Kubernetes cluster runners-ci pool is configured inline in the module
# Both node pools are inline in the module so GCP provisions them in parallel.
module "gke" {
source = "../modules/gke"
name = "logos-storage-rel-tests"
project = var.project
region = var.region
zone = var.zone
node_pool_name = "runners-ci-e2-standard-2"
node_pool_machine_type = "e2-standard-2"
node_pool_min = 1
node_pool_max = 5
name = "logos-storage-rel-tests"
project = var.project
region = var.region
zone = var.zone
node_pool_name = "runners-ci-e2-standard-2"
node_pool_machine_type = "e2-standard-2"
node_pool_min = 1
node_pool_max = 5
node_pool_labels = {
allow-tests-pods = "false"
default-pool = "true"
scaling-type = "auto"
workload-type = "tests-runners-ci"
}
}
# Node pool - Tests Pods
resource "google_container_node_pool" "tests-pods" {
name = "tests-e2-medium"
cluster = module.gke.kubernetes_cluster_id
location = var.zone
project = var.project
autoscaling {
min_node_count = 0
max_node_count = 10
}
node_config {
machine_type = "e2-medium"
spot = true
labels = {
allow-tests-pods = "true"
default-pool = "false"
scaling-type = "auto"
workload-type = "tests-pods"
}
oauth_scopes = [
"https://www.googleapis.com/auth/cloud-platform",
]
tests_pool_name = "tests-e2-medium"
tests_pool_machine_type = "e2-medium"
tests_pool_max = 10
tests_pool_labels = {
allow-tests-pods = "true"
default-pool = "false"
scaling-type = "auto"
workload-type = "tests-pods"
}
}

View File

@ -1,5 +1,6 @@
# Kubernetes cluster runners-ci pool configured inline to avoid the
# remove_default_node_pool create-then-delete cycle that adds ~5 min.
# Both node pools are inline so GCP provisions them in parallel during
# cluster creation, avoiding the sequential create penalty of a separate
# google_container_node_pool resource.
resource "google_container_cluster" "this" {
name = local.name
location = var.zone
@ -29,4 +30,24 @@ resource "google_container_cluster" "this" {
]
}
}
node_pool {
name = var.tests_pool_name
initial_node_count = 0
autoscaling {
min_node_count = 0
max_node_count = var.tests_pool_max
}
node_config {
machine_type = var.tests_pool_machine_type
spot = true
labels = var.tests_pool_labels
oauth_scopes = [
"https://www.googleapis.com/auth/cloud-platform",
]
}
}
}

View File

@ -48,3 +48,25 @@ variable "node_pool_labels" {
scaling-type = "auto"
}
}
# Tests node pool (spot, scales to zero)
variable "tests_pool_name" {
type = string
description = "Name for the tests node pool."
}
variable "tests_pool_machine_type" {
type = string
description = "The GCE machine type for nodes in the tests pool."
}
variable "tests_pool_max" {
type = number
description = "Maximum number of nodes in the tests pool."
}
variable "tests_pool_labels" {
type = map(string)
description = "Kubernetes labels to apply to nodes in the tests pool."
default = {}
}