<p>I have a <code>kubernetes</code> cluster working perfectly fine. It has 5 worker nodes. I am using below command to get the status of pods.</p>

<pre><code>kubectl get pod -o wide --namespace=machines
</code></pre>

<p>which shows below results</p>

<pre><code>NAME                  READY     STATUS              RESTARTS   AGE       IP        NODE
deployment-26hfn      0/4       ContainerCreating   0          5m        &lt;none&gt;    machine003
deployment-782mk      0/4       Pending             0          5m        &lt;none&gt;    machine001
deployment-7kcc7      0/4       Pending             0          5m        &lt;none&gt;    machine002
deployment-8fzqs      0/4       ContainerCreating   0          5m        &lt;none&gt;    machine004
deployment-zfzts      0/4       ContainerCreating   0          5m        &lt;none&gt;    machine005
</code></pre>

<p>As you can see, the above result is not in order from <code>machine001</code> to <code>machine 005</code>. Is it possible to print the output like below:</p>

<pre><code>NAME                  READY     STATUS              RESTARTS   AGE       IP        NODE
deployment-26hfn      0/4       Pending   0          5m        &lt;none&gt;    machine001
deployment-782mk      0/4       Pending             0          5m        &lt;none&gt;    machine002
deployment-7kcc7      0/4       ContainerCreating   0          5m        &lt;none&gt;    machine003
deployment-8fzqs      0/4       ContainerCreating   0          5m        &lt;none&gt;    machine004
deployment-zfzts      0/4       ContainerCreating   0          5m        &lt;none&gt;    machine005
</code></pre>

<p>You can pipe the kubectl command output to sort:</p>

<pre><code>kubectl get pods -o wide --namespace=machines | sort -k7
</code></pre>

<p>or to omit the first line</p>

<pre><code>kubectl get pods -o wide --namespace=machines | sed -n '1!p' | sort -k7
</code></pre>

<p>Also, you should be able to do this by <code>--sort-by</code> option in kubectl:</p>

<pre><code>kubectl get pods --all-namespaces -o wide --sort-by=.spec.nodeName
</code></pre>
