<p>I have several namespaces in my cluster and would like a log like:</p>
<pre><code>NAMESPACE            NAME                                          PODS  
MY_NAMESPACE         my_ns6446f67599-25g7f                         10   
</code></pre>

Ramon Medeiros
<p>You can also try this one liner:</p>
<pre><code>kubectl get pods --all-namespaces | awk '{print $1}' | sort | uniq -c | sort -k1 -n -r
</code></pre>
<p>Which will yield:</p>
<pre><code>136 some-ns
133 kube-system
119 other-ns
</code></pre>
<p>Explaining a bit:</p>
<ul>
<li><code>kubectl get pods --all-namespaces</code> will list all pods with namespace in the first column.</li>
<li><code>awk { print $1 }</code> will &quot;filter out&quot; the first column which is the namespace</li>
<li><code>sort</code> will sort the name of namespaces alphabetically</li>
<li><code>uniq -c</code> will count how many times each namespace appeared and aggregate with a count as the first column (e.g. <code>136 some-ns</code> means that <code>some-ns</code> appeared 136 times).</li>
<li><code>sort -k1 -n -r</code> this one will sort from the namespace which appeared the most (i.e. had most pods) to the one that appeared the least. <code>-k1</code> means that I am using the first column to sort, <code>-n</code> I am using numeric comparison and <code>-r</code> and I am doing a reverse ordering.</li>
</ul>
