---
title: KEDA 基于 Prometheus 指标自动伸缩实践
keywords: KEDA, ScaledObject, prometheus trigger, threshold, pollingInterval, cooldownPeriod
description: 使用 KEDA 根据 Prometheus 指标自动伸缩 Deployment,配置触发器与轮询/冷却参数以平滑扩缩容。
categories:
- 文章资讯
- 技术教程
---
ScaledObject(基于 Prometheus 指标):
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: api-scaled
namespace: default
spec:
scaleTargetRef:
name: api
minReplicaCount: 2
maxReplicaCount: 20
pollingInterval: 30
cooldownPeriod: 300
triggers:
- type: prometheus
metadata:
serverAddress: http://prometheus-operated.default.svc.cluster.local
metricName: http_requests_per_second
query: sum(rate(http_requests_total{service="api"}[2m]))
threshold: "100"

发表评论 取消回复