Skip to content
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

Cannot create informers to capture the pod metrics #3639

Closed
vegoutha opened this issue Dec 9, 2021 · 6 comments · Fixed by #3664
Closed

Cannot create informers to capture the pod metrics #3639

vegoutha opened this issue Dec 9, 2021 · 6 comments · Fixed by #3664
Assignees

Comments

@vegoutha
Copy link

vegoutha commented Dec 9, 2021

Tried to create informer with resource object PodMetrics and observed the below error:

Code Snippet:

 client.get.resources(classOf[PodMetrics]).inform()

Error message:

Failure executing: GET at: https://localhost:5125/apis/metrics.k8s.io/v1beta1/namespaces/default/podmetrics. 

Message: the server could not find the requested resource. 

Listed the api-resources with APIVERSION "metrics.k8s.io/v1beta1":

nodes                                          metrics.k8s.io/v1beta1                 false        NodeMetrics
pods                                           metrics.k8s.io/v1beta1                 true         PodMetrics

GET URL is supposed to be https://localhost:5125/apis/metrics.k8s.io/v1beta1/namespaces/default/pods

@rohanKanojia Please let me know how to capture the pod metrics using informers.

@shawkins
Copy link
Contributor

shawkins commented Dec 9, 2021

@vegoutha it looks like the metadata for pod and node metrics is not correct as it's just using the default plural. The workaround would be to use generic logic:

client.genericKubernetesResources(new ResourceDefintionContext.Builder().withGroup("metrics.k8s.io").withVersion("v1beta1").withPlural("pods").withNamespaced(true).build()).inform

You can convert between a GenericKubernetesResource and PodMetrics by using Serialization.jsonMapper().convertValue(genericResource, PodMetrics.class) or just use the generic.

@shawkins
Copy link
Contributor

shawkins commented Dec 9, 2021

@vegoutha I was trying to see if quick progress could be made on #3589 to address the root issue here, but I don't see that working out anytime soon. We'll have to come up with an alternative fix in the meantime to have the appropriate plurals here.

@manusa
Copy link
Member

manusa commented Dec 14, 2021

#3639 (comment)

Does this actually work?

Metrics HTTP API is not standard, I wasn't sure that this could actually work.

@shawkins
Copy link
Contributor

Does this actually work?

It should, or at least it will hit the endpoint he is wanting to.

There reason that informers don't work here is that they are pulling the plural from the class. Regular node/pod metric operations are working because the plural is being passed via the *OperationImpl.

@vegoutha
Copy link
Author

Thanks @shawkins . Workaround provided in the above comment #3639 (comment) works for me.

@shawkins
Copy link
Contributor

Also related to this is that NodeMetrics is currently marked as Namespaced, and it should not be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants