<h2>The problem</h2>
<p>It seems that deleting a pod by UID used to be possible, but has been removed (<a href="https://github.com/kubernetes/kubernetes/issues/40121" rel="noreferrer">https://github.com/kubernetes/kubernetes/issues/40121</a>).</p>
<p>It also seems one cannot <em><strong>get</strong></em> a pod by its resource either (<a href="https://github.com/kubernetes/kubernetes/issues/20572" rel="noreferrer">https://github.com/kubernetes/kubernetes/issues/20572</a>).</p>
<p>(Why did they remove deleting by UID, what is the use of the UID then?)</p>
<h2>Why do I want to use UID in the first place, and not, say, name?</h2>
<p>Because I need something like <em>replicas</em> and none of the controllers (like Job, Deployment etc) suit my case.<br />
The good thing about UIDs is that kubernetes generates them -- I don't have to worry about differentiating the pods then, I just save the returned UID. So it would be great if I could use it later to delete that particular pod (&quot;replica&quot;).</p>
<h2>The question</h2>
<p>Is it really not possible to use the UID to <em><strong>get</strong></em>/<em><strong>delete</strong></em>?</p>
<p>Is my only option then to take care of differentiating the pods myself (e.g. keep a counter or generate a unique id myself and set it as the name or label)?</p>

<p>This works as a <strong>get</strong> by UID:</p>
<blockquote>
<h2>Use kubectl <code>custom-columns</code></h2>
<p>List all PodName along with its UID of a namespace:</p>
<pre><code>$ kubectl get pods -n &lt;namespace&gt; -o custom-columns=PodName:.metadata.name,PodUID:.metadata.uid
</code></pre>
</blockquote>
<p>source: <a href="https://stackoverflow.com/questions/57799684/how-do-i-get-the-pod-id-in-kubernetes">How do I get the pod ID in Kubernetes?</a></p>
<p>Using <code>awk</code> and <code>xargs</code> and you can delete with <code>custom-columns</code> too.</p>
