【问题标题】:Is it possible to create a zone only node pool in a regional cluster in GKE?是否可以在 GKE 的区域集群中创建仅限区域的节点池?
【发布时间】:2021-04-02 12:37:57
【问题描述】:

我有一个用于冗余的区域集群。在这个集群中,我想在这个区域的 1 个区域中创建一个节点池。这种配置可行吗?我尝试这样做的原因是,我想在 1 个区域中运行像 RabbitMQ 这样的服务以避免分裂,并且我的应用程序服务在该区域的所有区域上运行以实现冗余。

我正在使用 terraform 创建集群和节点池,下面是我用于创建区域集群和区域节点池的配置

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"
  }
}

这会引发错误消息

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

【问题讨论】:

  • 提供您正在使用的 TF 版本并将 TF_LOG 更改为调试,将其打印到文本文件中,然后将其添加到您的帖子中以获得更详细的错误信息。

标签: kubernetes terraform google-kubernetes-engine


【解决方案1】:

发现google_container_node_pool 中的location 应该指定集群主控的区域/区域。要实际指定节点池位置 node_locations 应该使用。以下是有效的配置

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"
  }
}

【讨论】:

    猜你喜欢
    • 2020-02-19
    • 2021-04-13
    • 2021-02-14
    • 2019-06-20
    • 1970-01-01
    • 2019-12-04
    • 1970-01-01
    • 1970-01-01
    • 2022-11-14
    相关资源
    最近更新 更多