<p>I am trying to get the pod name with highest CPU utilization using kubectl command.
Able to retrieve list using following command but unable to write a jsonpath query to fetch the name of first pod from the output.
Appreciate any help in this regard. Thanks!</p>
<pre><code>kubectl top pod POD_NAME --sort-by=cpu
</code></pre>

<p><code>kubectl top</code> doesn't appear to enable <code>--output</code> formatting and so no JSON and thus no JSONPath :-(</p>
<p>You can:</p>
<pre class="lang-sh prettyprint-override"><code>kubectl top pod \
--sort-by=cpu \
--no-headers \
--namespace=${NAMESPACE} \
| head -n 1
</code></pre>
<p>I think it would be useful to support <code>--output</code> for all <code>kubectl</code> commands and you may wish to submit a feature request for this.</p>
<blockquote>
<p><strong>NOTE</strong> Hmmm <a href="https://github.com/kubernetes/kubectl/issues/753" rel="nofollow noreferrer"><code>kubectl top</code> output format options</a></p>
</blockquote>
