From 2ff251829b29ace6a01ef5413cd31cbe01d1c7ef Mon Sep 17 00:00:00 2001 From: Siddharth Rawat Date: Thu, 23 Nov 2023 09:46:55 -0500 Subject: [PATCH] fix: add variables to autoscaling parameters --- modules/k8s/main.tf | 4 ++-- modules/k8s/variables.tf | 2 ++ root/example.tfvars | 2 ++ root/main.tf | 2 ++ root/variables.tf | 10 ++++++++++ 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/modules/k8s/main.tf b/modules/k8s/main.tf index 8d857ed..6fbae5b 100644 --- a/modules/k8s/main.tf +++ b/modules/k8s/main.tf @@ -77,8 +77,8 @@ resource "google_container_node_pool" "gke_linux_node_pool" { node_count = 1 autoscaling { - max_node_count = 2 # change to 6 - min_node_count = 1 # change to 3 + max_node_count = var.max_node_count # change to 6 + min_node_count = var.min_node_count # change to 3 } management { diff --git a/modules/k8s/variables.tf b/modules/k8s/variables.tf index 37aa00b..ffa1635 100644 --- a/modules/k8s/variables.tf +++ b/modules/k8s/variables.tf @@ -4,6 +4,8 @@ variable "region" {} variable "project_id" {} variable "account_id_kubernetes" {} variable "initial_node_count" {} +variable "max_node_count" {} +variable "min_node_count" {} variable "node_zones" {} variable "master_ipv4_cidr_block" {} variable "authorized_ipv4_cidr_block" {} diff --git a/root/example.tfvars b/root/example.tfvars index 19128a1..30868dd 100644 --- a/root/example.tfvars +++ b/root/example.tfvars @@ -20,4 +20,6 @@ source_subnetwork_ip_ranges_to_nat = "LIST_OF_SUBNETWORKS" nat_ip_allocate_strategy = "MANUAL_ONLY" account_id_kubernetes = "" initial_node_count = 1 +max_node_count = 2 +min_node_count = 1 node_zones = ["", ""] diff --git a/root/main.tf b/root/main.tf index 87c781d..a52e80b 100644 --- a/root/main.tf +++ b/root/main.tf @@ -92,6 +92,8 @@ module "k8s" { region = var.region account_id_kubernetes = var.account_id_kubernetes initial_node_count = var.initial_node_count + max_node_count = var.max_node_count + min_node_count = var.min_node_count node_zones = var.node_zones master_ipv4_cidr_block = var.cluster_master_ip_cidr_range pods_ipv4_cidr_block = var.cluster_pods_ip_cidr_range diff --git a/root/variables.tf b/root/variables.tf index 9b6d9fc..86bad9a 100644 --- a/root/variables.tf +++ b/root/variables.tf @@ -115,3 +115,13 @@ variable "cluster_services_ip_cidr_range" { type = string description = "The CIDR range to use for Kubernetes cluster services" } + +variable "max_node_count" { + type = number + description = "The max node count when autoscaling the cluster" +} + +variable "min_node_count" { + type = number + description = "THe min node count when autoscaling the cluster" +}