Skip to content

Commit 251d13f

Browse files
authored
Merge pull request #341 from kbst/kgieseking-gke-enhancements
Kgieseking gke enhancements
2 parents 5ebdcd5 + 89a5ece commit 251d13f

File tree

9 files changed

+112
-17
lines changed

9 files changed

+112
-17
lines changed

google/_modules/gke/cluster.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ resource "google_container_cluster" "current" {
7474
}
7575

7676
dynamic "maintenance_exclusion" {
77-
for_each = var.maintenance_exclusions
77+
for_each = var.maintenance_exclusion_start_time != null ? [1] : []
7878

7979
content {
80-
start_time = maintenance_exclusion.value.start_time
81-
end_time = maintenance_exclusion.value.end_time
82-
exclusion_name = maintenance_exclusion.value.exclusion_name
80+
start_time = var.maintenance_exclusion_start_time
81+
end_time = var.maintenance_exclusion_end_time
82+
exclusion_name = var.maintenance_exclusion_name
8383

8484
exclusion_options {
85-
scope = maintenance_exclusion.value.scope
85+
scope = var.maintenance_exclusion_scope
8686
}
8787
}
8888
}

google/_modules/gke/node_pool/main.tf

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ resource "google_container_node_pool" "current" {
1414

1515
node_locations = var.node_locations
1616

17+
dynamic "network_config" {
18+
for_each = var.network_config == null ? [] : [1]
19+
20+
content {
21+
enable_private_nodes = var.network_config["enable_private_nodes"]
22+
create_pod_range = var.network_config["create_pod_range"]
23+
pod_ipv4_cidr_block = var.network_config["pod_ipv4_cidr_block"]
24+
}
25+
}
26+
1727
#
1828
#
1929
# Node config
@@ -31,7 +41,7 @@ resource "google_container_node_pool" "current" {
3141

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

34-
tags = var.metadata_tags
44+
tags = concat(var.metadata_tags, var.instance_tags)
3545

3646
workload_metadata_config {
3747
mode = var.node_workload_metadata_config

google/_modules/gke/node_pool/variables.tf

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@ variable "taints" {
119119
default = null
120120
}
121121

122+
variable "instance_tags" {
123+
type = list(string)
124+
description = "List of instance tags to apply to nodes."
125+
default = []
126+
}
127+
122128
variable "node_locations" {
123129
type = list(string)
124130
description = "List of zones in the cluster's region to start worker nodes in. Defaults to cluster's node locations."
@@ -152,3 +158,26 @@ variable "labels" {
152158
description = "Kubernetes labels to set on the nodes created by the node pool. Merged with Kubestack default labels."
153159
default = {}
154160
}
161+
162+
variable "network_config" {
163+
type = object({
164+
enable_private_nodes = bool
165+
create_pod_range = bool
166+
pod_ipv4_cidr_block = string
167+
})
168+
description = "Additional network configuration for the node pool."
169+
}
170+
171+
variable "ephemeral_storage_local_ssd_config" {
172+
type = object({
173+
local_ssd_count = number
174+
})
175+
description = "`ephemeral_storage_local_ssd_config` block, useful for node groups with local SSD. Defaults to `null`"
176+
default = null
177+
}
178+
179+
variable "labels" {
180+
type = map(string)
181+
description = "Kubernetes labels to set on the nodes created by the node pool. Merged with Kubestack default labels."
182+
default = {}
183+
}

google/_modules/gke/variables.tf

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,24 @@ variable "daily_maintenance_window_start_time" {
5353
description = "Start time of the daily maintenance window."
5454
}
5555

56-
variable "maintenance_exclusions" {
57-
type = list(object({
58-
start_time = string
59-
end_time = string
60-
exclusion_name = string
61-
scope = string
62-
}))
63-
description = "List of maintenance exclusion configuration to be set on the cluster."
56+
variable "maintenance_exclusion_start_time" {
57+
type = string
58+
description = "Maintenance exclusion start time"
59+
}
60+
61+
variable "maintenance_exclusion_end_time" {
62+
type = string
63+
description = "Maintenance exclusion end time"
64+
}
65+
66+
variable "maintenance_exclusion_name" {
67+
type = string
68+
description = "Maintenance exclusion name"
69+
}
70+
71+
variable "maintenance_exclusion_scope" {
72+
type = string
73+
description = "Maintenance exclusion scope"
6474
}
6575

6676
variable "remove_default_node_pool" {

google/cluster/configuration.tf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ locals {
3030
"cluster_daily_maintenance_window_start_time",
3131
"03:00",
3232
)
33-
cluster_maintenance_exclusions = lookup(local.cfg, "cluster_maintenance_exclusions", [])
33+
34+
cluster_maintenance_exclusion_start_time = lookup(local.cfg, "cluster_maintenance_exclusion_start_time", "")
35+
cluster_maintenance_exclusion_end_time = lookup(local.cfg, "cluster_maintenance_exclusion_end_time", "")
36+
cluster_maintenance_exclusion_name = lookup(local.cfg, "cluster_maintenance_exclusion_name", "")
37+
cluster_maintenance_exclusion_scope = lookup(local.cfg, "cluster_maintenance_exclusion_scope", "")
3438

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

google/cluster/main.tf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ module "cluster" {
2727
release_channel = local.cluster_release_channel
2828

2929
daily_maintenance_window_start_time = local.cluster_daily_maintenance_window_start_time
30-
maintenance_exclusions = local.cluster_maintenance_exclusions
30+
31+
maintenance_exclusion_start_time = local.cluster_maintenance_exclusion_start_time
32+
maintenance_exclusion_end_time = local.cluster_maintenance_exclusion_end_time
33+
maintenance_exclusion_name = local.cluster_maintenance_exclusion_name
34+
maintenance_exclusion_scope = local.cluster_maintenance_exclusion_scope
3135

3236
remove_default_node_pool = local.remove_default_node_pool
3337

google/cluster/node-pool/configuration.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,12 @@ locals {
4242

4343
ephemeral_storage_local_ssd_config = local.cfg["ephemeral_storage_local_ssd_config"]
4444

45+
guest_accelerator = local.cfg["guest_accelerator"]
46+
network_config = local.cfg["network_config"]
47+
48+
instance_tags = local.cfg["instance_tags"]
49+
50+
ephemeral_storage_local_ssd_config = local.cfg["ephemeral_storage_local_ssd_config"]
51+
4552
guest_accelerator = local.cfg["guest_accelerator"]
4653
}

google/cluster/node-pool/main.tf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ module "node_pool" {
3030

3131
node_workload_metadata_config = local.node_workload_metadata_config
3232

33-
taints = local.taints
33+
taints = local.taints
34+
instance_tags = local.instance_tags
3435

3536
labels = local.labels
3637

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

4243
guest_accelerator = local.guest_accelerator
44+
45+
network_config = local.network_config
46+
47+
ephemeral_storage_local_ssd_config = local.ephemeral_storage_local_ssd_config
48+
49+
guest_accelerator = local.guest_accelerator
4350
}

google/cluster/node-pool/variables.tf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ variable "configuration" {
2929

3030
labels = optional(map(string))
3131

32+
labels = optional(map(string))
33+
3234
extra_oauth_scopes = optional(list(string))
3335

3436
node_workload_metadata_config = optional(string)
@@ -48,6 +50,28 @@ variable "configuration" {
4850
max_shared_clients_per_gpu = optional(number)
4951
}))
5052
}))
53+
54+
network_config = optional(object({
55+
enable_private_nodes = bool
56+
create_pod_range = bool
57+
pod_ipv4_cidr_block = string
58+
}))
59+
60+
instance_tags = optional(list(string))
61+
62+
ephemeral_storage_local_ssd_config = optional(object({
63+
local_ssd_count = number
64+
}))
65+
66+
guest_accelerator = optional(object({
67+
type = string
68+
count = number
69+
gpu_partition_size = optional(string)
70+
gpu_sharing_config = optional(object({
71+
gpu_sharing_strategy = optional(string)
72+
max_shared_clients_per_gpu = optional(number)
73+
}))
74+
}))
5175
}))
5276

5377
description = "Map with per workspace cluster configuration."

0 commit comments

Comments
 (0)