简体   繁体   中英

Terraform: Create single node GKE cluster

I am trying to create a GKE cluster of node size 1. However, it always create a cluster of 3 nodes. Why is that?

resource "google_container_cluster" "gke-cluster" {
  name = "sonarqube"
  location = "asia-southeast1"
  remove_default_node_pool = true
  initial_node_count = 1
}

resource "google_container_node_pool" "gke-node-pool" {
  name = "sonarqube"
  location = "asia-southeast1"
  cluster = google_container_cluster.gke-cluster.name
  node_count = 1

  node_config {
    machine_type = "n1-standard-1"
    metadata = {
      disable-legacy-endpoints = "true"
    }

    labels = {
      app = "sonarqube"
    }
  }
}

在此处输入图片说明

Ok, found I can do so using node_locations :

resource "google_container_cluster" "gke-cluster" {
  name = "sonarqube"
  location = "asia-southeast1"
  node_locations = [
    "asia-southeast1-a"
  ]
  remove_default_node_pool = true
  initial_node_count = 1
}

Without that, it seems GKE will create 1 node per zone.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM