<p>Using <code>kubectl</code>, I want to <code>describe</code> one of the pods (can be a random one) filtered on a labelSelector. Currently, I perform it in two steps:</p>
<ol>
<li><code>get</code> the pods,</li>
<li>Copy the name of one of the results, and <code>describe</code> it.</li>
</ol>
<pre class="lang-bash prettyprint-override"><code>$ kubectl get pods -l app=my-app,environment=production
$ kubectl describe pods my-pod-name-copied-from-the-results
</code></pre>
<p>Can I do that with a one-liner, and without copying the pod name every single time?</p>

vahdet
<p>A one liner to get the first pod's decribe (if scaled to more than 1):</p>
<pre><code>kubectl -n namespace describe po &quot;$(kubectl -n namespace get po -l app.kubernetes.io/name=my-app --no-headers -o name|cut -d/ -f2|head -1)&quot;
</code></pre>
<p>If you need a random one (as mentioned in the other answer's comments):</p>
<pre><code>kubectl -n namespace describe po &quot;$(kubectl -n namespace get po -l app.kubernetes.io/name=my-app --no-headers -o name|cut -d/ -f2|shuf -n1)&quot;
</code></pre>
