简体   繁体   中英

How to get list of pods that are not linked to any service

How to get list of pods that are not linked to any service

Lets say i have pods:

Svc1-green-xyz and svc1-blue-lmn

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

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?

This is possible, but very hacky. Pods and services aren't really linked , so much as services use selectors 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 kubectl get endpoints , 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM