New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HPA on custom metrics #3134
Comments
TODO:
|
Note: you'll put the actual annotation key strings in |
@kevinswiber is working on this. |
Based on the latest autoscaling API version supported by GKE, I'm upgrading to To match the fields required to create an HPA resource, I propose using the following annotations. autoscaling.knative.dev/class: "hpa.autoscaling.knative.dev"
autoscaling.knative.dev/metric: "custom"
autoscaling.knative.dev/metricSourceType: "resource" # or... pods, object, external
autoscaling.knative.dev/metricName: "average.memory.heartshapedbox.com"
autoscaling.knative.dev/targetAverageUtilization: "50" # valid on resource type
autoscaling.knative.dev/targetAverageValue: 400m # valid on object, resource, pods, external types
autoscaling.knative.dev/targetValue: 800m # valid on object, external types
autoscaling.knative.dev/targetName: main-route # valid on object types
autoscaling.knative.dev/targetKind: Ingress # valid on object types
autoscaling.knative.dev/targetAPIVersion: extensions/v1beta1 # valid on object types Reference: https://godoc.org/k8s.io/api/autoscaling/v2beta1#MetricSpec This does add a non-trivial amount of complexity to this feature. Happy to receive feedback. |
Thanks for taking this on @kevinswiber. In the last Autoscaling WG we had a discussion on the API surface of our autoscaling configuration. The bottomline was a question-mark to whether or not it is a good idea to offload the whole API surface into what is essentially a In this case it also becomes almost easier to leave the HPA spec alone and tell the user to manipulate that herself vs. configuring it through annotations and reconciliation of the revision. @josephburnett What's your take here? Should we think about a new API surface as part of this? |
@markusthoemmes Thanks for your input. This all makes sense. The set-it-and-forget-it flow of just deploying a I'm not sure of the simplest solution. I think we'd also want the PodAutoscaler to retain ownership over the HPA. It might be possible for the user to add an annotation to a manually created HPA and have a reconciler auto-associate the Knative PodAutoscaler resource with the HPA. At that point, Knative could take control to include useful functionality like cascading deletes. |
FYI: I have the above proposal mostly working. I hesitate to update docs until we get through the design-prototyping cycle. I can put up a WIP PR if you like or hold off until design is solidified. |
I don't think we need all those annotations. We can focus on pod metrics and leave object metrics unimplemented. With that limitation, we would need the following annotations: autoscaling.knative.dev/class: "hpa.autoscaling.knative.dev" # preexisting
autoscaling.knative.dev/metric: "custom" # preexisting
autoscaling.knative.dev/target: 400m # preexisting, translates to averageValue
autoscaling.knative.dev/metricName: "average.memory.heartshapedbox.com" # NEW This adds only one new annotation, the @markusthoemmes @kevinswiber what do you think? |
@josephburnett This is fine. I'll have to add some defaults for the other fields. I'm happy to be involved in the discussion for the next round of design on this, as well. Piecing together a PR today. |
@markusthoemmes , does the work you did for HPA cover this? |
@vagababov it does not, no. |
@kevinswiber I presume you're no longer working on this? |
Is it already possible to disable the custom-metrics-server and switch the class to https://github.com/kubernetes-sigs/metrics-server ? |
Issues go stale after 90 days of inactivity. Send feedback to Knative Productivity Slack channel or file an issue in knative/test-infra. /lifecycle stale |
I'm leaning towards closing this as we haven't talked about it in ages and nobody asked about it in ages. Feel free to reopen if you disagree. |
Hi @siddharth-mitra - I don't believe this feature was ever implemented (the issue was closed in May 2020 since there weren't many requests for the feature). The HPA autoscaler class in knative currently only supports "cpu" (and, when #11668 lands, "memory") as a metric |
Hi @julz - Thank you for letting me know about the same. |
Proposal
HPA-class PodAutoscalers should be able to autoscale on any custom metric emitted from the user-container. For example, if the user serves JVM memory usage on a Promethus endpoint from their application container, they should be able to wire that up to a Kubernetes HPA with custom metrics.
For example, given this Service, Knative would create an HPA which points to the "average.memory.heartshapedbox.com" metric.
Non-requirements
Knative would not configure Prometheus to scrape the right metrics from the right path. That would be left to the operator to setup. Re-configuring a custom metrics server implementation on the fly is out of scope for what Knative autoscaler should do out-of-the-box. This plumbing is just to unlock a full custom metrics solution if necessary.
Note: #3132 does propose configuring Prometheus to scrape a metric off the queue-proxy. But since it's our metric and well known, it doesn't require reconfiguration.
The text was updated successfully, but these errors were encountered: