Also raised the issue here but not getting any response: https://github.com/kedacore/keda/issues/3669
Trying to use this trigger: https://keda.sh/docs/2.8/scalers/metrics-api/
I'm flexible on how I use it - here was my first attempt:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-keda-charlie
namespace: tsew
spec:
replicas: 1
selector:
matchLabels:
app: nginx-keda-charlie
template:
metadata:
labels:
app: nginx-keda-charlie
spec:
containers:
- name: nginx-keda-charlie
image: nginx
imagePullPolicy: Always
---
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: http-scaledobject
namespace: tsew
labels:
deploymentName: nginx-keda-charlie
spec:
scaleTargetRef:
name: nginx-keda-charlie
triggers:
- type: metrics-api
metadata:
metricType: Value
targetValue: "1"
url: "http://mockbin.org/bin/9cb318e0-e8d8-4dc5-a18f-f6135a0e2d4a"
valueLocation: 'tasks'
But I get this error:
"HorizontalPodAutoscaler.autoscaling "keda-hpa-http-scaledobject" is invalid: spec.metrics[0].external.target.averageValue: Invalid value: resource.Quantity{i:resource.int64Amount{value:0, scale:0}, d:resource.infDecAmount{Dec:(*inf.Dec)(nil)}, s:"0", Format:"DecimalSI"}: must be positive"
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.12.3/pkg/internal/controller/controller.go:121 sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.12.3/pkg/internal/controller/controller.go:320 sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.12.3/pkg/internal/controller/controller.go:273 sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2 /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.12.3/pkg/internal/controller/controller.go:234 2022-09-14T19:59:54Z ERROR Reconciler error {"controller": "scaledobject", "controllerGroup": "keda.sh", "controllerKind": "ScaledObject", "scaledObject": {"name":"http-scaledobject","namespace":"tsew"}, "namespace": "tsew", "name": "http-scaledobject", "reconcileID": "a7d1c215-a585-4a65-b85d-ba1152746edf", "error": "HorizontalPodAutoscaler.autoscaling "keda-hpa-http-scaledobject" is invalid: spec.metrics[0].external.target.averageValue: Invalid value: resource.Quantity{i:resource.int64Amount{value:0, scale:0}, d:resource.infDecAmount{Dec:(*inf.Dec)(nil)}, s:"0", Format:"DecimalSI"}: must be positive"} sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.12.3/pkg/internal/controller/controller.go:273 sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2 /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.12.3/pkg/internal/controller/controller.go:234
Steps to Reproduce the Problem
Your metrics API trigger should return application/json
in order for this to work. The endpoint in your example returns Content-Type: text/html; charset=utf-8
. Try this mockbin instead: https://mockbin.org/bin/336a8d99-9e09-4f1f-979d-851a6d1b1423