question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot create informers to capture the pod metrics

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
vegouthacommented, Dec 17, 2021

Thanks @shawkins . Workaround provided in the above comment https://github.com/fabric8io/kubernetes-client/issues/3639#issuecomment-989868438 works for me.

2reactions
shawkinscommented, 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

unable to fully collect metrics · Issue #130 - GitHub
The logs of metrics-server show that it receives a - Raw (json) response - from kubelet, but i can't retrieve the metrics via...
Read more >
SharedInformerFactoryWithOptio...
I get the output for all the pods, the namespace is getting filtered but not the labels. Not able to figure out where...
Read more >
Stay informed with kubernetes informers - FireHydrant
This is where the Informer types in the cache package come in. So let's build a simple tool that informs us of Kubernetes...
Read more >
Code error 403 when trying to access Kubernetes cluster
I've created a kubernetes cluster and all the pods are in running state. But when I try to access the cluster I get...
Read more >
Our Journey Taking Kubernetes State Metrics to the Next Level
It focuses on monitoring the health of deployments, nodes, pods etc. Kubernetes State Metrics is one of our favorite tools here at Datadog, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found