Hi there,
Even though it’s possible to define maximum node count through variables, I get the error outlined above and when I remove them, it works perfectly.
main.tf file
# Define variables for cluster configuration (unchanged)
# Define the main GKE cluster (unchanged)
resource "google_container_cluster" "gke_cluster" {
name = var.cluster_name
location = var.location
initial_node_count = var.initial_node_count
}
# Define a separate node pool with desired machine type and maximum count
resource "google_container_node_pool" "high_mem_pool" {
name = "high-mem-pool"
cluster = google_container_cluster.gke_cluster.name
node_count = var.initial_node_count # Initial node count (can be adjusted)
max_node_count = var.maximum_node_count # Use the defined variable
# Set machine type with more memory for memory-intensive workloads
node_config {
machine_type = "e2-standard-8"
}
}
variables.tf
# Define variables for cluster configuration (variable block)
variable "cluster_name" {
default = "gke-terraform"
}
variable "location" {
default = "us-central1"
}
variable "initial_node_count" {
default = 1
}
variable "maximum_node_count" {
default = 3
}
providers.tf
provider "google" {
project = "project-id" #change project id to suit your project
region = "us-central1"
}
I don’t know why I get the error and when I extensively looked at the problem, I looked at documentation and other resources extensively but couldn’t find an answer.