24 lines
906 B
YAML
24 lines
906 B
YAML
apiVersion: keda.sh/v1alpha1
|
||
kind: ScaledObject
|
||
metadata:
|
||
name: navigation-scaler
|
||
namespace: navigation
|
||
spec:
|
||
scaleTargetRef:
|
||
name: navigation
|
||
minReplicaCount: 1 # 至少保持 1 个副本(HPA 限制)
|
||
maxReplicaCount: 10 # 最多 10 个副本
|
||
pollingInterval: 15 # 每 15 秒检查一次
|
||
cooldownPeriod: 180 # 缩容冷却期 3 分钟
|
||
triggers:
|
||
- type: prometheus
|
||
metadata:
|
||
serverAddress: http://kube-prometheus-stack-prometheus.monitoring.svc.cluster.local:9090
|
||
metricName: nginx_http_requests_total
|
||
query: sum(rate(nginx_http_requests_total{namespace="navigation"}[1m]))
|
||
threshold: "10" # 每分钟超过 10 个请求时启动
|
||
- type: cpu
|
||
metricType: Utilization
|
||
metadata:
|
||
value: "60" # CPU 使用率超过 60% 时扩容
|