I am trying to create hpa for memory based metric, so I provided the annotations in my service according to docs.
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: helloworld-go
namespace: default
spec:
template:
metadata:
annotations:
autoscaling.knative.dev/class: "hpa.autoscaling.knative.dev"
autoscaling.knative.dev/metric: "memory"
https://knative.dev/docs/serving/autoscaling/autoscaling-metrics/#setting-metrics-per-revision
HPA -> as you can see, metric type is only CPU, I have also checked yaml output, but it always create a hpa with cpu metrics only, I don't have much experience with this autoscaling.
And the annotations are added to my hpa from service.
Any suggestions on this, or what I am doing wrong.
finally after some research and expermients
To make the HPA work for knative service, we also need to specify the target as annotations, as we can see here:
This if condition for hpa will only work, if we specify some target for metric. https://github.com/knative/serving/blob/91ac3b335131565cb9304ed9f6259c959f71b996/pkg/reconciler/autoscaling/hpa/resources/hpa.go#L62
now it works by adding one more annotation:
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: helloworld-go
namespace: default
spec:
template:
metadata:
annotations:
autoscaling.knative.dev/class: "hpa.autoscaling.knative.dev"
autoscaling.knative.dev/metric: "memory"
autoscaling.knative.dev/target: "75"