Skip to content

Commit 89d9c62

Browse files
feat(gke): Allow the ability to create a node pool with spot instances (#232)
1 parent 5584646 commit 89d9c62

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

google_gke/cluster.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,9 @@ resource "google_container_node_pool" "pools" {
284284
sysctls = local.node_pools_sysctls[each.key]
285285
}
286286
}
287+
288+
spot = local.node_pools_spot_enabled[each.key]
289+
287290
machine_type = each.value.machine_type
288291
oauth_scopes = local.node_pools_oauth_scopes[each.key]
289292
service_account = google_service_account.cluster_service_account.email

google_gke/locals.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ locals {
5353
node_pools_guest_accelerator = { for node_pool in var.node_pools : node_pool.name => lookup(var.node_pools_guest_accelerator, node_pool.name, {}) }
5454
node_pools_tags = { for node_pool in var.node_pools : node_pool.name => setunion(local.tags, lookup(var.node_pools_tags, node_pool.name, [])) }
5555
node_pools_taints = { for node_pool in var.node_pools : node_pool.name => lookup(var.node_pools_taints, node_pool.name, []) }
56+
node_pools_spot_enabled = { for node_pool in var.node_pools : node_pool.name => lookup(var.node_pools_spot_enabled, node_pool.name, false) }
5657

5758
# Google Group for RBAC
5859
cluster_authenticator_security_group = var.google_group_name == null ? [] : [{

google_gke/variables.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,14 @@ variable "node_pools_guest_accelerator" {
261261
}
262262
}
263263

264+
variable "node_pools_spot_enabled" {
265+
description = "Map containing node pools spot enabled. Each node pool's name is the key. See locals.tf for defaults."
266+
type = map(bool)
267+
default = {
268+
tf-default-node-pool = false
269+
}
270+
}
271+
264272
#
265273
# Monitoring
266274
#

0 commit comments

Comments
 (0)