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

Autopilot集群设置超600秒终止宽限期失效问题咨询

解决GKE Autopilot终止宽限期被强制重置的问题

核心问题

你仅添加了cluster-autoscaler.kubernetes.io/safe-to-evict: "false"注解,但该注解仅用于标记Pod为不可驱逐的长时间运行实例,要突破terminationGracePeriodSeconds的600秒限制,还需满足完整的配置条件。

必须完成的配置项

  • 添加双注解组合:
    除了cluster-autoscaler.kubernetes.io/safe-to-evict: "false",必须额外添加cloud.google.com/extended-runtime: "true"注解,明确告知Autopilot集群该Pod需要延长运行时支持。
  • 确认工作负载类型:
    仅Deployment、StatefulSet、DaemonSet、ReplicaSet或独立Pod支持该特性,Job/CronJob无法使用。
  • 资源请求合规:
    Pod的CPU、内存请求必须在Autopilot集群允许的资源范围内,不能超出节点最大可用资源限制。
  • 设置合法的宽限期值:
    Autopilot允许的最大终止宽限期为86400秒(1天),超出该值仍会被截断,需将terminationGracePeriodSeconds设置在600~86400秒之间。

示例Deployment配置

apiVersion: apps/v1
kind: Deployment
metadata:
  name: extended-pods
spec:
  replicas: 1
  selector:
    matchLabels:
      app: extended-app
  template:
    metadata:
      annotations:
        cluster-autoscaler.kubernetes.io/safe-to-evict: "false"
        cloud.google.com/extended-runtime: "true"
      labels:
        app: extended-app
    spec:
      terminationGracePeriodSeconds: 3600 # 示例设置为1小时
      containers:
      - name: app-container
        image: your-image:tag
        resources:
          requests:
            cpu: "1"
            memory: "2Gi"

配置验证

应用配置后,执行以下命令检查是否生效:

kubectl get pod <pod-name> -o jsonpath='{.spec.terminationGracePeriodSeconds}{"\n"}{.metadata.annotations}'

若配置正确,将不会再收到autopilot-default-resources-mutator的警告,终止宽限期会保留你设置的值。

额外注意

  • 不可驱逐Pod会降低集群自动扩缩容的灵活性,仅在确有必要的场景使用。
  • 若使用StatefulSet,需同步确认PersistentVolume的回收策略,避免终止过程中数据丢失。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.16 04:46:01