gcp上的节点池在每个区域仅需要一个实例时在每个区域中创建3个实例

时间:2020-10-22 14:42:50

标签: terraform google-kubernetes-engine terraform-provider-gcp

因此,我尝试创建2个节点池(入口节点池和Web节点池),入口在us-west1-a区域中必须只有1个实例,而在其他区域中Web必须具有3个实例。但是,当我运行Terraform代码时,结果是在Webpool上的3个区域和3个实例的入口池有3个实例。

这是定义群集区域和位置的方式,并且我了解到,通过不在location参数中定义区域,它会在整个区域中创建所有内容并将其分布在该区域的各个区域中,但是如果放置location =“ us -west1-a”在集群模块上创建我想要的(4个实例),但是所有这些都在us-west1-a区域中,当我真正需要它时,我首先会提到它:

module "cluster" {

  project                             = local.project
  source                              = "./gke"
  region                              = "us-west1"
  location                            = "us-west1"

resource "google_container_node_pool" "web_nodepool" {
  
  depends_on         = [google_container_cluster.dev-k8s, google_service_account.devcluster]
  name               = "dev-web-pool"
  project            = var.project
  location           = var.location
  cluster            = var.cluster_name
  initial_node_count = var.node_pools["web-pool"].initial_node_count

  management {
    auto_repair  =  true
    auto_upgrade =  true
  }

  node_config {
    machine_type    = "g1-small"
    disk_size_gb    = 20
    disk_type       = "pd-standard"
    image_type      = "COS"
    preemptible     = true
    service_account = "devcluster-serviceaccount@bamboo-host-289213.iam.gserviceaccount.com"
    oauth_scopes    = var.node_pools_oauth_scopes["urls-autorizacao"]

  }
}

resource "google_container_node_pool" "ingress_nodepool" {
  
  depends_on         = [google_container_cluster.dev-k8s, google_service_account.devcluster]
  name               = "dev-ingress-pool"
  project            = var.project
  location           = "us-west1-a"
  cluster            = var.cluster_name
  node_count         = 1
  

  management {
    auto_repair  =  true
    auto_upgrade =  true
  }

  node_config {
    machine_type    = "g1-small"
    disk_size_gb    = 10
    disk_type       = "pd-standard"
    image_type      = "COS"
    preemptible     = false
    service_account = "devcluster-serviceaccount@bamboo-host-289213.iam.gserviceaccount.com"
    oauth_scopes    = var.node_pools_oauth_scopes["urls-autorizacao"]

  }
}
'''




0 个答案:

没有答案