Skip to content

Commit

Permalink
Merge pull request #341 from kbst/kgieseking-gke-enhancements
Browse files Browse the repository at this point in the history
Kgieseking gke enhancements
  • Loading branch information
pst authored Dec 6, 2024
2 parents 5ebdcd5 + 89a5ece commit 251d13f
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 17 deletions.
10 changes: 5 additions & 5 deletions google/_modules/gke/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ resource "google_container_cluster" "current" {
}

dynamic "maintenance_exclusion" {
for_each = var.maintenance_exclusions
for_each = var.maintenance_exclusion_start_time != null ? [1] : []

content {
start_time = maintenance_exclusion.value.start_time
end_time = maintenance_exclusion.value.end_time
exclusion_name = maintenance_exclusion.value.exclusion_name
start_time = var.maintenance_exclusion_start_time
end_time = var.maintenance_exclusion_end_time
exclusion_name = var.maintenance_exclusion_name

exclusion_options {
scope = maintenance_exclusion.value.scope
scope = var.maintenance_exclusion_scope
}
}
}
Expand Down
12 changes: 11 additions & 1 deletion google/_modules/gke/node_pool/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ resource "google_container_node_pool" "current" {

node_locations = var.node_locations

dynamic "network_config" {
for_each = var.network_config == null ? [] : [1]

content {
enable_private_nodes = var.network_config["enable_private_nodes"]
create_pod_range = var.network_config["create_pod_range"]
pod_ipv4_cidr_block = var.network_config["pod_ipv4_cidr_block"]
}
}

#
#
# Node config
Expand All @@ -31,7 +41,7 @@ resource "google_container_node_pool" "current" {

labels = merge(var.labels, var.metadata_labels)

tags = var.metadata_tags
tags = concat(var.metadata_tags, var.instance_tags)

workload_metadata_config {
mode = var.node_workload_metadata_config
Expand Down
29 changes: 29 additions & 0 deletions google/_modules/gke/node_pool/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ variable "taints" {
default = null
}

variable "instance_tags" {
type = list(string)
description = "List of instance tags to apply to nodes."
default = []
}

variable "node_locations" {
type = list(string)
description = "List of zones in the cluster's region to start worker nodes in. Defaults to cluster's node locations."
Expand Down Expand Up @@ -152,3 +158,26 @@ variable "labels" {
description = "Kubernetes labels to set on the nodes created by the node pool. Merged with Kubestack default labels."
default = {}
}

variable "network_config" {
type = object({
enable_private_nodes = bool
create_pod_range = bool
pod_ipv4_cidr_block = string
})
description = "Additional network configuration for the node pool."
}

variable "ephemeral_storage_local_ssd_config" {
type = object({
local_ssd_count = number
})
description = "`ephemeral_storage_local_ssd_config` block, useful for node groups with local SSD. Defaults to `null`"
default = null
}

variable "labels" {
type = map(string)
description = "Kubernetes labels to set on the nodes created by the node pool. Merged with Kubestack default labels."
default = {}
}
26 changes: 18 additions & 8 deletions google/_modules/gke/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,24 @@ variable "daily_maintenance_window_start_time" {
description = "Start time of the daily maintenance window."
}

variable "maintenance_exclusions" {
type = list(object({
start_time = string
end_time = string
exclusion_name = string
scope = string
}))
description = "List of maintenance exclusion configuration to be set on the cluster."
variable "maintenance_exclusion_start_time" {
type = string
description = "Maintenance exclusion start time"
}

variable "maintenance_exclusion_end_time" {
type = string
description = "Maintenance exclusion end time"
}

variable "maintenance_exclusion_name" {
type = string
description = "Maintenance exclusion name"
}

variable "maintenance_exclusion_scope" {
type = string
description = "Maintenance exclusion scope"
}

variable "remove_default_node_pool" {
Expand Down
6 changes: 5 additions & 1 deletion google/cluster/configuration.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ locals {
"cluster_daily_maintenance_window_start_time",
"03:00",
)
cluster_maintenance_exclusions = lookup(local.cfg, "cluster_maintenance_exclusions", [])

cluster_maintenance_exclusion_start_time = lookup(local.cfg, "cluster_maintenance_exclusion_start_time", "")
cluster_maintenance_exclusion_end_time = lookup(local.cfg, "cluster_maintenance_exclusion_end_time", "")
cluster_maintenance_exclusion_name = lookup(local.cfg, "cluster_maintenance_exclusion_name", "")
cluster_maintenance_exclusion_scope = lookup(local.cfg, "cluster_maintenance_exclusion_scope", "")

remove_default_node_pool = lookup(local.cfg, "remove_default_node_pool", true)

Expand Down
6 changes: 5 additions & 1 deletion google/cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ module "cluster" {
release_channel = local.cluster_release_channel

daily_maintenance_window_start_time = local.cluster_daily_maintenance_window_start_time
maintenance_exclusions = local.cluster_maintenance_exclusions

maintenance_exclusion_start_time = local.cluster_maintenance_exclusion_start_time
maintenance_exclusion_end_time = local.cluster_maintenance_exclusion_end_time
maintenance_exclusion_name = local.cluster_maintenance_exclusion_name
maintenance_exclusion_scope = local.cluster_maintenance_exclusion_scope

remove_default_node_pool = local.remove_default_node_pool

Expand Down
7 changes: 7 additions & 0 deletions google/cluster/node-pool/configuration.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,12 @@ locals {

ephemeral_storage_local_ssd_config = local.cfg["ephemeral_storage_local_ssd_config"]

guest_accelerator = local.cfg["guest_accelerator"]
network_config = local.cfg["network_config"]

instance_tags = local.cfg["instance_tags"]

ephemeral_storage_local_ssd_config = local.cfg["ephemeral_storage_local_ssd_config"]

guest_accelerator = local.cfg["guest_accelerator"]
}
9 changes: 8 additions & 1 deletion google/cluster/node-pool/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ module "node_pool" {

node_workload_metadata_config = local.node_workload_metadata_config

taints = local.taints
taints = local.taints
instance_tags = local.instance_tags

labels = local.labels

Expand All @@ -40,4 +41,10 @@ module "node_pool" {
ephemeral_storage_local_ssd_config = local.ephemeral_storage_local_ssd_config

guest_accelerator = local.guest_accelerator

network_config = local.network_config

ephemeral_storage_local_ssd_config = local.ephemeral_storage_local_ssd_config

guest_accelerator = local.guest_accelerator
}
24 changes: 24 additions & 0 deletions google/cluster/node-pool/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ variable "configuration" {

labels = optional(map(string))

labels = optional(map(string))

extra_oauth_scopes = optional(list(string))

node_workload_metadata_config = optional(string)
Expand All @@ -48,6 +50,28 @@ variable "configuration" {
max_shared_clients_per_gpu = optional(number)
}))
}))

network_config = optional(object({
enable_private_nodes = bool
create_pod_range = bool
pod_ipv4_cidr_block = string
}))

instance_tags = optional(list(string))

ephemeral_storage_local_ssd_config = optional(object({
local_ssd_count = number
}))

guest_accelerator = optional(object({
type = string
count = number
gpu_partition_size = optional(string)
gpu_sharing_config = optional(object({
gpu_sharing_strategy = optional(string)
max_shared_clients_per_gpu = optional(number)
}))
}))
}))

description = "Map with per workspace cluster configuration."
Expand Down

0 comments on commit 251d13f

Please sign in to comment.