24 lines
832 B
YAML
24 lines
832 B
YAML
apiVersion: keda.sh/v1alpha1
|
|
kind: ScaledObject
|
|
metadata:
|
|
name: redis-scaler
|
|
namespace: redis
|
|
spec:
|
|
scaleTargetRef:
|
|
name: redis
|
|
minReplicaCount: 0 # 空闲时缩容到 0
|
|
maxReplicaCount: 5 # 最多 5 个副本
|
|
pollingInterval: 30 # 每 30 秒检查一次
|
|
cooldownPeriod: 300 # 缩容冷却期 5 分钟
|
|
triggers:
|
|
- type: prometheus
|
|
metadata:
|
|
serverAddress: http://kube-prometheus-stack-prometheus.monitoring.svc.cluster.local:9090
|
|
metricName: redis_connected_clients
|
|
query: sum(redis_connected_clients{namespace="redis"})
|
|
threshold: "1" # 有连接时启动
|
|
- type: cpu
|
|
metricType: Utilization
|
|
metadata:
|
|
value: "70" # CPU 使用率超过 70% 时扩容
|