Cannot create informers to capture the pod metrics
See original GitHub issueTried 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:
- Created 2 years ago
- Comments:6 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks @shawkins . Workaround provided in the above comment https://github.com/fabric8io/kubernetes-client/issues/3639#issuecomment-989868438 works for me.
@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.