使用 terraform 创建 kubernetes 集群时,`错误 403:区域配额不足,无法满足请求:资源“SSD_TOTAL_GB”`

Dar*_*ioB 8 google-cloud-platform terraform terraform-provider-gcp

您好,我正在 google cloud 免费套餐帐户中使用 kubernetes 和 terraform(尝试使用免费的 300 美元)。这是我的 terraform 资源声明,它是我从 terraform 资源页面复制的非常标准的内容。这里没有什么特别奇怪的。

resource "google_container_cluster" "cluster" {
  name = "${var.cluster-name}-${terraform.workspace}"
  location = var.region
  initial_node_count = 1
  project = var.project-id
  remove_default_node_pool = true
}

resource "google_container_node_pool" "cluster_node_pool" {
  name       = "${var.cluster-name}-${terraform.workspace}-node-pool"
  location   = var.region
  cluster    = google_container_cluster.cluster.name
  node_count = 1

  node_config {
    preemptible  = true
    machine_type = "e2-medium"
    service_account = google_service_account.default.email
    oauth_scopes    = [
      "https://www.googleapis.com/auth/cloud-platform"
    ]
  }
}
Run Code Online (Sandbox Code Playgroud)

这个 terraform 片段过去工作得很好。为了不让这 300 美元花得太快,每天结束时我都会用 来销毁集群terraform destroy。然而有一天,kubernetes 集群创建停止工作了。这是错误:

Error: googleapi: Error 403: Insufficient regional quota to satisfy request: resource "SSD_TOTAL_GB": request requires '300.0' and is short '50.0'. project has a quota of '250.0' with '250.0' available. View and manage quotas at https://console.cloud.google.com/iam-admin/quotas?usage=USED&project=xxxxxx., forbidden
Run Code Online (Sandbox Code Playgroud)

在所有 terraform 销毁之后,似乎有些东西没有得到清理,最终建立了一些配额,我无法再创建集群了。我仍然可以通过谷歌云网络界面创建集群(我只尝试使用自动驾驶仪,并且在同一位置)。我有点困惑为什么会发生这种情况。我的假设正确吗?我是否需要删除 terraform 不会自动删除的内容?如果是的话为什么?有没有办法解决这个问题并能够再次使用 terraform 创建集群?

thu*_*v89 10

我遇到了同样的问题,我想我知道发生了什么。这里的关键是要理解区域集群和区域集群之间的区别。

太棒了;区域集群仅在区域中运行,而区域集群可以跨多个区域进行复制。

从文档来看,

默认情况下,GKE 跨控制平面区域的三个区域复制每个节点池

我认为这就是为什么我们看到要求达到 300GB (3 * 100GB),而默认--disk-size为 100GB。

解决方案是将 设为locationazone而不是 a region。当然,这里我假设区域集群可以满足您的要求。例如

resource "google_container_cluster" "cluster" {
  name = "${var.cluster-name}-${terraform.workspace}"
  location = "us-central1-f"
  initial_node_count = 1
  project = var.project-id
  remove_default_node_pool = true
}

resource "google_container_node_pool" "cluster_node_pool" {
  name       = "${var.cluster-name}-${terraform.workspace}-node-pool"
  location   = "us-central1-f"
  cluster    = google_container_cluster.cluster.name
  node_count = 1

  node_config {
    ...
  }
}
Run Code Online (Sandbox Code Playgroud)