Skip to content

Commit

Permalink
feat(nodepool): disable autoscaling by default (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdulAhadAkhter committed Jul 29, 2024
1 parent 8fccc60 commit a39116e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
22 changes: 12 additions & 10 deletions node_pool/inputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ variable "kubernetes_version" {

variable "max_node_count" {
description = "Maximum number of nodes for autoscaling, per availability zone."
default = null
}

variable "min_node_count" {
description = "Minimum number of nodes for autoscaling, per availability zone."
default = null
}

variable "name" {
Expand All @@ -23,7 +25,7 @@ variable "region" {
}

variable "node_locations" {
type = list
type = list(any)
description = "The list of zones in which the node pool's nodes should be located. Nodes must be in the region of their regional cluster or in the same region as their cluster's zone for zonal clusters. If unspecified, the cluster-level node_locations will be used."
default = null
}
Expand All @@ -50,7 +52,7 @@ variable "machine_type" {

variable "node_labels" {
description = "Key Value Pairs of Labels to add to the nodes in the pool"
type = map
type = map(any)
default = {}
}

Expand All @@ -61,13 +63,13 @@ variable "node_metadata" {
}

variable "node_tags" {
type = list
type = list(any)
description = "List of strings for tags on node pool VMs. These are generally used for firewall rules."
default = []
}

variable "additional_oauth_scopes" {
type = list
type = list(any)
description = "List of strings for additional oauth scope in a node config"
default = []
}
Expand All @@ -92,7 +94,7 @@ variable "image_type" {
default = "COS"
}

variable "spot_nodes"{
variable "spot_nodes" {
type = bool
description = "Whether to use spot nodes"
default = false
Expand All @@ -106,24 +108,24 @@ variable "enable_secure_boot" {

variable "taint" {
description = "Dictionary of effect, key and value to apply on nodes in pool"
type = map
type = map(any)
default = null
}

variable "timeout_create"{
variable "timeout_create" {
type = string
description = "Override default timeout for CREATE function"
default = "30m"
}

variable "timeout_delete"{
variable "timeout_delete" {
type = string
description = "Override default timeout for DELETE function"
default = "30m"
}

variable "timeout_update"{
variable "timeout_update" {
type = string
description = "Override default timeout for UPDATE function"
default = "30m"
}
}
9 changes: 6 additions & 3 deletions node_pool/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@ resource "google_container_node_pool" "node_pool" {
version = var.kubernetes_version
initial_node_count = var.initial_node_count

autoscaling {
min_node_count = var.min_node_count
max_node_count = var.max_node_count
dynamic "autoscaling" {
for_each = (var.min_node_count != null && var.max_node_count != null) ? [1] : []
content {
min_node_count = var.min_node_count
max_node_count = var.max_node_count
}
}

node_config {
Expand Down

0 comments on commit a39116e

Please sign in to comment.