Is it possible to create a zone only node pool in a regional cluster in GKE?

12/23/2020

I have a regional cluster for redundancy. In this cluster I want to create a node-pool in just 1 zone in this region. Is this configuration possible? reason I trying this is, I want to run service like RabbitMQ in just 1 zone to avoid split, and my application services running on all zones in the region for redundancy.

I am using terraform to create the cluster and node pools, below is my config for creating region cluster and zone node pool

resource "google_container_cluster" "regional_cluster" {
  provider       = google-beta
  project        = "my-project"
  name           = "my-cluster"
  location       = "us-central1"
  node_locations = ["us-central1-a", "us-central1-b", "us-central1-c"]

  master_auth {
    username = ""
    password = ""

    client_certificate_config {
      issue_client_certificate = false
    }
  }
}

resource "google_container_node_pool" "one_zone" {
  project            = google_container_cluster.regional_cluster.project
  name               = "zone-pool"
  location           = "us-central1-b"
  cluster            = google_container_cluster.regional_cluster.name

  node_config {
    machine_type    = var.machine_type
    image_type      = var.image_type
    disk_size_gb    = 100
    disk_type       = "pd-standard"
  }
}

This throws an error message

error creating NodePool: googleapi: Error 404: Not found: projects/my-project/zones/us-central1-b/clusters/my-cluster., notFound
-- RandomQuests
google-kubernetes-engine
kubernetes
terraform

1 Answer

12/24/2020

Found out that location in google_container_node_pool should specify cluster master's region/zone. To actually specify the node-pool location node_locations should be used. Below is the config that worked

resource "google_container_cluster" "regional_cluster" {
  provider       = google-beta
  project        = "my-project"
  name           = "my-cluster"
  location       = "us-central1"
  node_locations = ["us-central1-a", "us-central1-b", "us-central1-c"]

  master_auth {
    username = ""
    password = ""

    client_certificate_config {
      issue_client_certificate = false
    }
  }
}

resource "google_container_node_pool" "one_zone" {
  project            = google_container_cluster.regional_cluster.project
  name               = "zone-pool"
  location           = google_container_cluster.regional_cluster.location
  node_locations     = ["us-central1-b"]
  cluster            = google_container_cluster.regional_cluster.name

  node_config {
    machine_type    = var.machine_type
    image_type      = var.image_type
    disk_size_gb    = 100
    disk_type       = "pd-standard"
  }
}
-- RandomQuests
Source: StackOverflow