概览与核心价值自动伸缩通过按需分配计算资源提升稳定性与成本效率。HPA 负责副本数伸缩,VPA 负责资源规格调优,KEDA 负责事件驱动伸缩;三者组合可覆盖绝大多数生产负载场景。核心概念与技术架构HPA:基于 `autoscaling/v2` 的指标驱动副本数伸缩,支持多指标与自定义指标。VPA:自动推荐或调整容器 `requests/limits`,提升调度与利用率。KEDA:对接外部事件源与指标系统,实现细粒度与异步场景伸缩。实战与示例apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: web namespace: default spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: web minReplicas: 2 maxReplicas: 20 metrics: - type: Resource resource: name: cpu target: type: Utilization averageUtilization: 60 apiVersion: autoscaling.k8s.io/v1 kind: VerticalPodAutoscaler metadata: name: web-vpa spec: targetRef: apiVersion: apps/v1 kind: Deployment name: web updatePolicy: updateMode: Auto resourcePolicy: containerPolicies: - containerName: web minAllowed: cpu: 200m memory: 256Mi maxAllowed: cpu: 2000m memory: 2Gi apiVersion: keda.sh/v1alpha1 kind: ScaledObject metadata: name: web-keda spec: scaleTargetRef: name: web minReplicaCount: 2 maxReplicaCount: 20 triggers: - type: prometheus metadata: serverAddress: http://prometheus-server.monitoring.svc.cluster.local metricName: http_requests_total threshold: "100" query: sum(rate(http_requests_total[1m])) 验证与度量使用 `kubectl get hpa`、`kubectl top pods` 与负载回放验证阈值与伸缩速率。对比成本与响应时间指标,评估不同策略组合的收益与风险。最佳实践与工程建议指标统一:以 SLO 为核心统一伸缩阈值,避免局部最优。资源治理:结合 VPA 与调度策略,减少资源碎片与不足请求。事件驱动:为异步工作负载采用 KEDA,提升峰值流量下的稳定性。版本与来源Kubernetes Releases:https://kubernetes.io/releases/EKS 版本生命周期与支持: https://docs.aws.amazon.com/eks/latest/userguide/kubernetes-versions.html

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论
立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部
1.577980s