You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何调整GKE集群镜像垃圾回收阈值及Terraform配置方法

调整GKE集群节点镜像垃圾回收阈值的Terraform实现

由于GKE控制台不支持配置节点镜像垃圾回收阈值,你需要通过Terraform的google_container_node_pool资源,利用其kubelet_config块来修改image_gc_high_threshold_percent参数,将触发自动清理的剩余空间阈值从默认85%调低至70%。

核心配置示例

resource "google_container_node_pool" "example_node_pool" {
  name       = "example-node-pool"
  cluster    = google_container_cluster.example_cluster.name
  location   = google_container_cluster.example_cluster.location
  node_count = 3

  node_config {
    machine_type = "e2-medium"
    # 其他节点配置(如服务账号、标签等)
  }

  # 配置kubelet参数,调整镜像垃圾回收阈值
  kubelet_config {
    image_gc_high_threshold_percent = 70
    # 建议配套调低低阈值,避免频繁触发回收(默认80%)
    image_gc_low_threshold_percent  = 60
  }
}

关键说明

  • kubelet_config块是GKE节点池资源中专门用于配置kubelet运行参数的字段,对应Kubernetes官方定义的KubeletConfiguration结构
  • image_gc_high_threshold_percent:当节点磁盘使用率达到该值(即剩余空间30%)时,kubelet会自动清理未使用的镜像
  • 配套设置image_gc_low_threshold_percent:当磁盘使用率降到该值以下时,停止镜像清理,避免频繁回收操作
  • 如果是修改现有节点池,配置更新后需要执行节点池滚动更新(Terraform会自动触发),确保新配置生效

内容的提问来源于stack exchange,提问作者a1dude

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.26 10:07:19