jthomperoo / predictive-horizontal-pod-autoscaler

Horizontal Pod Autoscaler built with predictive abilities using statistical models
Apache License 2.0
330 stars 30 forks source link

Support custom metrics retrieval from a custom controller (CRD based) with per-resource mode #63

Closed igorshevach closed 2 years ago

igorshevach commented 2 years ago

Describe the bug metrics retrieval works fine with predefined resource types (such as deployment). however, switching to custom controller with crd fails to retrieve metrics with error: 2022/04/05 19:10:52 no kind "MyCC" is registered for version "MyCC.com/v1" in scheme "/app/main.go:121" Mind, that custom-pod-autoscaler which has recently underwent code refactor succeeds in resolving the CRD type and retrieves scale object.

To Reproduce Steps to reproduce the behavior:

  1. Deploy custom controller
  2. Configure phpa to reference it via scaleTargetRef
  3. Deploy the phpa, rleevant clusterrole+clusterrolebinding for accessing the crd.
  4. wait until error appears in logs; phpa fails to get metric
  5. See error

Expected behavior PHPA instance should be able to retrieve metrics just as running kubectl get --raw /api/... does.

Kubernetes Details (kubectl version): Client Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.5", GitCommit:"5c99e2ac2ff9a3c549d9ca665e7bc05a3e18f07e", GitTreeState:"clean", BuildDate:"2021-12-16T08:38:33Z", GoVersion:"go1.16.12", Compiler:"gc", Platform:"darwin/amd64"} Server Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.5", GitCommit:"5c99e2ac2ff9a3c549d9ca665e7bc05a3e18f07e", GitTreeState:"clean", BuildDate:"2021-12-16T08:32:32Z", GoVersion:"go1.16.12", Compiler:"gc", Platform:"linux/amd64"} PHPA - up to date CPA - up to date

Additional context Add any other context about the problem here.

jthomperoo commented 2 years ago

Hey, thanks for raising this - recently support for custom operators/controllers has been added to the underlying Custom Pod Autoscaler - so I'll look at upgrading this project to use CPA v2.5.0 which will include this functionality.

jthomperoo commented 2 years ago

This is now available in v0.10.0.