--- title: Kubernetes HPA External Metrics 与 Prometheus Adapter 实战 keywords: HPA, external metrics, Prometheus Adapter, averageValue, autoscaling/v2 description: 使用 HPA 基于 Prometheus Adapter 的外部指标进行自动扩缩,配置目标值与副本范围,平滑应对流量波动。 categories: - 文章资讯 - 技术教程 --- HorizontalPodAutoscaler: ``` apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: api-hpa namespace: default spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: api minReplicas: 2 maxReplicas: 30 metrics: - type: External external: metric: name: http_requests_per_second selector: matchLabels: service: api target: type: AverageValue averageValue: 100 ```

发表评论 取消回复