<p>How to get list of pods that are not linked to any service</p>

<p>Lets say i have pods:</p>

<p><code>Svc1-green-xyz</code> and <code>svc1-blue-lmn</code></p>

<p>Service <code>svc1</code> is served by <code>svc1-green-xyz</code>. With <code>svc1-blue-lmn</code> is a prior version of the same service and is not used. </p>

<p><em>I want to select all such unused pods that are not serving any service and delete them. How can this be done. Is there a helm command that can be used?</em> </p>

lr-pal
<p>This is possible, but very hacky. Pods and services aren't really <em>linked</em>, so much as services use <em>selectors</em> to determine which pods they should target. What's really happening is that services keep track of a list of endpoints they need to forward traffic to. So, you could theoretically get a list of all endpoints for a service <code>kubectl get endpoints</code>, filter based on IP address, and remove all pods whose IPs are not in that list. If you're going through all this, though, you're probably doing something wrong.</p>
