Kubernetes Java API for Metrics

5/15/2020

I am getting the pod metrics through kubectl command

kubectl top pods
NAME                CPU(cores)   MEMORY(bytes)
api-6bd876fc8b-85dnx   72m          553Mi
ui-67b794cf8d-gcrg5    0m           1Mi

but I want to try through Java client https://github.com/kubernetes-client/java/

Is there any support to get the Metrics for Pods and Nodes through kubernetes-client ?

-- geek
java
kubernetes

1 Answer

5/16/2020

The Resource Metrics API is not included in the official Java client library. so you have to query the API server as following:

GET /apis/metrics/v1alpha1/namespaces/{namespace}/pods/{pod}

which will return the results of current metrics.

Here are a few references with ability to add even more custom metrics:

Hope this answers your question.

-- Hiteshwar Sharma
Source: StackOverflow