<p>I am getting the pod metrics through kubectl command</p>

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

<p>but I want to try through Java client <a href="https://github.com/kubernetes-client/java/" rel="nofollow noreferrer">https://github.com/kubernetes-client/java/</a></p>

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

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

<pre><code>GET /apis/metrics/v1alpha1/namespaces/{namespace}/pods/{pod}
</code></pre>

<p>which will return the results of current metrics.</p>

<p>Here are a few references with ability to add even more custom metrics:</p>

<ul>
<li><a href="https://blog.jetstack.io/blog/resource-and-custom-metrics-hpa-v2/" rel="nofollow noreferrer">https://blog.jetstack.io/blog/resource-and-custom-metrics-hpa-v2/</a></li>
<li><a href="https://github.com/kubernetes/metrics" rel="nofollow noreferrer">https://github.com/kubernetes/metrics</a></li>
</ul>

<p>Hope this answers your question.</p>
