Skip to content

Add default node pool to GKE cluster #1044

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions tools/kubernetes/terraform/examples/v5e/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ variable "project_id" {}
variable "resource_name_prefix" {}
variable "region" {}
variable "tpu_node_pools" {}
variable "cpu_node_pool" {}
variable "maintenance_interval" {}


Expand All @@ -11,5 +12,6 @@ module "tpu-gke" {
resource_name_prefix = var.resource_name_prefix
region = var.region
tpu_node_pools = var.tpu_node_pools
cpu_node_pool = var.cpu_node_pool
maintenance_interval = var.maintenance_interval
}
7 changes: 7 additions & 0 deletions tools/kubernetes/terraform/examples/v5e/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,11 @@ tpu_node_pools = [{
topology = "16x16"
policy = "sb-compact-4d"
}]
cpu_node_pool = {
zone = ["us-east5-a", "us-east5-b", "us-east5-c"]
machine_type = "n2-standard-64",
initial_node_count_per_zone = 1,
min_node_count_per_zone = 1,
max_node_count_per_zone = 10
}
maintenance_interval = "PERIODIC"
27 changes: 27 additions & 0 deletions tools/kubernetes/terraform/module/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,30 @@ resource "google_container_node_pool" "multihost_tpu" {
policy_name = var.tpu_node_pools[count.index].policy
}
}

resource "google_container_node_pool" "cpu_node_pool" {
provider = google-beta
project = var.project_id
name = "cpu-node-pool"
location = var.region
node_locations = var.cpu_node_pool.zone
cluster = google_container_cluster.tpu_cluster.name
initial_node_count = var.cpu_node_pool.initial_node_count_per_zone
autoscaling {
min_node_count = var.cpu_node_pool.min_node_count_per_zone
max_node_count = var.cpu_node_pool.max_node_count_per_zone
}
node_config {
oauth_scopes = [
"https://www.googleapis.com/auth/cloud-platform"
]
machine_type = var.cpu_node_pool.machine_type

metadata = {
disable-legacy-endpoints = "true"
}
gcfs_config {
enabled = true
}
}
}
7 changes: 7 additions & 0 deletions tools/kubernetes/terraform/module/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,11 @@ tpu_node_pools = [{
machine_type = "ct4p-hightpu-4t"
topology = "2x2x2"
}]
cpu_node_pool = {
zone = ["us-central2-a", "us-central2-b", "us-central2-c"]
machine_type = "n2-standard-64",
initial_node_count_per_zone = 1,
min_node_count_per_zone = 1,
max_node_count_per_zone = 10
}
maintenance_interval = "AS_NEEDED"
17 changes: 17 additions & 0 deletions tools/kubernetes/terraform/module/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,23 @@ variable "tpu_node_pools" {
}))
}

variable "cpu_node_pool" {
description = "cpu nodepool config"
type = object({
zone = list(string),
machine_type = string,
initial_node_count_per_zone = number,
min_node_count_per_zone = number,
max_node_count_per_zone = number
})
validation {
condition = (
(var.cpu_node_pool.min_node_count_per_zone >=0 && var.cpu_node_pool.min_node_count_per_zone <= var.cpu_node_pool.max_node_count_per_zone)
)
error_message = "cpu_node_pool.min_node_count_per_zone must be >= 0 and <= cpu_node_pool.max_node_count_per_zone."
}
}

variable "maintenance_interval" {
default = "AS_NEEDED"
description = "maintenance interval for TPU machines."
Expand Down