I'm running KEDA v2.17 on Google Kubernetes Engine (GKE) Autopilot, and I've observed that my deployment scales down to 1 replica after about 15 minutes, even though my API consistently returns a static value of 4.
I'm using the metrics-api trigger. The API is a dummy endpoint that always returns this payload: { "replicaCount": 4 }
I expected the deployment to stay at 4 replicas indefinitely, but it consistently scales down after a while. There are no errors in keda-operator or keda-operator-metrics-apiserver, and the API is healthy (no crashes, OOMs, etc.).
ScaledObject configuration:
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: pod-scaler
namespace: default
spec:
scaleTargetRef:
name: minimal-spot-server
pollingInterval: 10
cooldownPeriod: 60
minReplicaCount: 0
maxReplicaCount: 8
triggers:
- type: metrics-api
metadata:
targetValue: "1.0"
url: http://backend.default.svc.cluster.local:80/metrics_test
valueLocation: "replicaCount"
Why is the deployment scaling down to 1 after 15 minutes, despite the metrics-api returning a constant value of 4? Is there something I'm missing about how KEDA interprets or persists external metrics?
I found the problem: Flux CD was reconfiguring the deployment every X minutes, causing KEDA to scale down to zero the number of replicas and restart from scratch.