<p>I want to select the first node that has the most CPU usage, I run the following but I need the first node without manipulating the output itself</p>
<pre><code>Kubectl top node --sort-by='{.spec.status.capacity.cpu}'
</code></pre>
<p>this gives me all the nodes sorted
I'm thinking about something like in SQL</p>
<pre><code>kubectl top 1 node --sort-by='{.spec.status.capacity.cpu}'
</code></pre>
<p>any Help</p>

Mohamed Nehad
<p>kubectl doesn't provide built in option to get only one node using top command but you can achieve it using simple shell command (if your are running in linux/Mac based system) like below</p>
<pre><code>kubectl top node --sort-by=cpu --no-headers | head -1
</code></pre>
<p>The above command works if your kubectl version is 1.18 (or greater).</p>
<p>If your kubectl version is less than 1.18 version then sort command in top will return inconsistent response due to <a href="https://github.com/kubernetes/kubernetes/issues/81270" rel="nofollow noreferrer">issue</a>, in this case you can use below command to make it work.</p>
<pre><code>kubectl top node --no-headers | sort -k3 -n | tail -1
</code></pre>
