【问题标题】:Standard GKE + node pools cannot enable Autoscaling标准 GKE + 节点池无法启用自动扩缩
【发布时间】:2023-02-15 23:38:38
【问题描述】:

Cloud Foundation Fabric 模块: https://github.com/GoogleCloudPlatform/cloud-foundation-fabric/tree/master/modules/gke-cluster

https://github.com/GoogleCloudPlatform/cloud-foundation-fabric/tree/master/modules/gke-nodepool

尝试使用 2 个单独的节点池 (gke-nodepool) 配置 GKE 标准集群 (gke-cluster),并启用自动缩放。

在我指定的集群级别:

cluster_autoscaling = {
  enabled    = true
  cpu_min    = 15
  cpu_max    = 85
  memory_min = 15
  memory_max = 85
 }

在节点池级别:

nodepool_config = {
  autoscaling_config = {
  min_node_count = 1
  max_node_count = 4
 }

我所看到的:当我转到 GCP 控制台 > GKE > 选择集群 > 节点并查看自动缩放属性时,它已设置为关闭。

期待:我认为,如果我通过指定我的缩放阈值在集群级别启用了集群自动缩放,那么我单独创建的任何节点池以及我为其提供的 autoscaling_config 都会在 GCP 控制台中显示“Autoscaling ON”。

更新:这是我的实际模块配置:

module "gke-cluster" {
  source                   = "../../../Modules/gke-cluster"
  project_id               = module.project.project_id
  name                     = "cluster-name"
  location                 = local.svpc.subnets["${local.subnet-gke}"].region
  node_locations           = local.nodepool_zones
  network                  = local.svpc.network.id
  subnetwork               = local.svpc.subnets["${local.subnet-gke}"].id
  secondary_range_pods     = "pods"
  secondary_range_services = "services"

  min_master_version = "1.22.12-gke.2300"
  enable_autopilot   = false
  release_channel    = "STABLE"

  addons = {
    dns_cache_config = true
    cloudrun_config = {
      disabled = true
    }
    gce_persistent_disk_csi_driver_config = true
    horizontal_pod_autoscaling            = true
    http_load_balancing                   = true
    config_connector_config               = false
    kalm_config                           = false
    istio_config = {
      enabled = false
      tls     = false
    }
    network_policy_config = false
  }

  cluster_autoscaling = {
    enabled    = true
    cpu_min    = 15
    cpu_max    = 85
    memory_min = 15
    memory_max = 85
  }

  master_authorized_ranges = {
*REDACTED*
  }

  maintenance_config = {
    recurring_window = {
      start_time = "2020-11-18T00:00:00Z"
      end_time   = "2050-01-01T04:00:00Z"
      recurrence = "FREQ=WEEKLY"
    }
    daily_maintenance_window = null
    maintenance_exclusion    = []
  }

  private_cluster_config = {
    enable_private_nodes    = true
    enable_private_endpoint = true
    master_ipv4_cidr_block  = local.master_ipv4_cidr_block
    master_global_access    = false
  }

  node_config = {
    image_type = "cos_containerd"
    shielded_instance_config = {
      enable_secure_boot          = true
      enable_integrity_monitoring = true
    }
    gcfs  = false
    gvnic = false
  }

  labels = {
*REDACTED*
  }

  depends_on = [module.gke-service-account]
}

module "cpu-nodepool" {
  source            = "../../../Modules/gke-nodepool"
  project_id        = module.project.project_id
  name              = "cpu-nodepool"
  cluster_name      = "cluster-name"
  location          = local.node_location
  max_pods_per_node = 110
  node_count = {
    initial = 1
  }
  tags = [*REDACTED*]

  node_config = {
    image_type                    = "cos_containerd"
    disk_size_gb                  = local.disk_size_gb
    disk_type                     = "pd-standard"
    machine_type                  = local.cpu_machine_type
    preemptible                   = false
    workload_metadata_config_mode = "GKE_METADATA"
    shielded_instance_config = {
      enable_secure_boot          = true
      enable_integrity_monitoring = true
    }
    gcfs  = false
    gvnic = false
  }

  nodepool_config = {
    autoscaling_config = {
      min_node_count = 1
      max_node_count = 3
    }
    management_config = {
      auto_repair  = true
      auto_upgrade = true
    }
  }

  service_account = {
    create       = false
    email        = module.gke-service-account.email
    oauth_scopes = ["https://www.googleapis.com/auth/cloud-platform"]
  }

  depends_on = [module.gke-cluster]
}
module "gpu-nodepool" {
  source            = "../../../Modules/gke-nodepool"
  project_id        = module.roject.project_id
  name              = "gpu-nodepool"
  cluster_name      = "cluster-name"
  location          = local.node_location
  max_pods_per_node = 110
  node_count = {
    initial = 1
  }
  tags = [*REDACTED*]

  node_config = {
    image_type                    = "cos_containerd"
    disk_size_gb                  = local.disk_size_gb
    disk_type                     = "pd-standard"
    machine_type                  = local.gpu_machine_type
    preemptible                   = false
    workload_metadata_config_mode = "GKE_METADATA"
    shielded_instance_config = {
      enable_secure_boot          = true
      enable_integrity_monitoring = true
    }
    guest_accelerator = {
      count = local.gpu_count
      type  = local.gpu_accelerator
    }
    gcfs  = false
    gvnic = false
  }

  nodepool_config = {
    autoscaling_config = {
      min_node_count = 1
      max_node_count = 4
    }
    management_config = {
      auto_repair  = true
      auto_upgrade = true
    }
  }

  service_account = {
    create       = false
    email        = module.gke-service-account.email
    oauth_scopes = ["https://www.googleapis.com/auth/cloud-platform"]
  }

  labels = {
*REDACTED*
  }

  depends_on = [module.gke-cluster]
}

【问题讨论】:

  • 请编辑问题以将其限制为具有足够详细信息的特定问题,以确定适当的答案。

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


【解决方案1】:

【讨论】:

    猜你喜欢
    • 2022-01-15
    • 2021-06-23
    • 2021-04-23
    • 1970-01-01
    • 2021-06-12
    • 2021-11-21
    • 2019-12-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多