配置自动扩缩容
配置AI应用自动扩缩容,包括自动扩缩容vGPU资源请求、限制等。
步骤 1. 开启自动扩缩容
添加Pod自动扩缩容注解
需配合工作负载注解使用:创建工作负载
# 开启垂直扩缩容
tensor-fusion.ai/autoscale: 'true'
# 配置目标资源,可填 all | compute | vram,未设置时默认为 all
tensor-fusion.ai/autoscale-target: allPod 注解用于快速开启资源自动调整。百分位、边界、定时规则和外部伸缩器等细节请放到 WorkloadProfile 或 SchedulingConfigTemplate 中配置。
使用工作负载配置文件进行详细配置
- 垂直扩缩容: 基于GPU资源历史使用量数据,采用社区VPA Histogram算法实现。 VPA算法生成的估算值由Target、LowerBound、UpperBound组成,默认对应P90、P50、P95用量。 若当前资源用量在LowerBound和UpperBound范围外,则生成推荐值。
若 enable 不为 true,则只生成推荐值,不会实际应用资源推荐值。
- 定时扩缩容: 基于标准的cron表达式,当
enable为true,并且在start和end范围内生效,超出时间范围则恢复至添加工作负载时指定的资源值,Cron表达式参考
autoScalingConfig:
# 垂直扩缩容配置
autoSetResources:
# 是否开启
enable: true
# 目标资源
targetResource: all # compute | vram | all
# 计算资源目标值百分位,默认值:0.9
targetComputePercentile: "0.9"
# 计算资源下边界值百分位,默认值:0.5
lowerBoundComputePercentile: "0.5"
# 计算资源上边界值百分位,默认值:0.95
upperBoundComputePercentile: "0.95"
# 计算VRAM目标值百分位,默认值:0.9
targetVRAMPercentile: "0.9"
# 计算VRAM下边界值百分位,默认值:0.5
lowerBoundVRAMPercentile: "0.5"
# 计算VRAM上边界值百分位,默认值:0.95
upperBoundVRAMPercentile: "0.95"
# 请求估算值扩大系数 默认值:0.15
marginFraction: "0.15"
# 推荐值与当前值差异超过该阈值才更新,默认值:0.1
updateThreshold: "0.1"
# 查询历史指标的时间范围,默认值:2h
historyDataPeriod: 2h
# 工作负载创建后等待足够指标再开始调整,默认值:30m
initialDelayPeriod: 30m
# 评估周期,默认跟随全局自动扩缩容周期
interval: 1m
# 定时扩缩容配置
cronScalingRules:
# 是否启用该规则
- enable: true
# 规则名称
name: "test"
# 规则生效起始时间
start: "0 0 * * Thu"
# 规则生效结束时间
end: "59 23 * * Thu"
# 期望设置的GPU资源值
desiredResources:
limits:
tflops: "99"
vram: 10Gi
requests:
tflops: "44"
vram: 5Gi步骤 2. 观测扩缩容状态
工作负载会生成对应的
TensorFusionWorkload资源对象,Status中的字段会实时反应当前扩缩容状态
status:
conditions:
# GPU资源推荐值产生的原因
- lastTransitionTime: '2025-10-09T09:16:46Z'
message: TFLOPS scaled up due to (1) below lower bound (2)
reason: OutOfEstimatedBound
status: 'True'
type: RecommendationProvided
# 当前GPU资源推荐值
recommendation:
limits:
tflops: '13'
vram: 1Gi
requests:
tflops: '13'
vram: 1Gi
# 当前已应用GPU资源推荐值的副本数
appliedRecommendedReplicas: 3
# 当前生效的定时扩缩容规则
activeCronScalingRule: <...>