Kubernetes HPA 自动扩缩容实战基础配置示例apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: web-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: web
minReplicas: 2
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 60
自定义指标使用指标网关或适配器提供外部指标,如 QPS 或队列长度验证与监控通过压测观察副本变化与收敛时间关注扩容频率、防抖与资源上限排障要点确认 Metrics Server 与权限配置正常确认目标 Deployment 的资源请求与限制已设置总结结合资源与业务指标设定合理目标值,可获得弹性与成本的平衡。

发表评论 取消回复