yogeshkk / K8sPurger

Hunt Unused Resources In Kubernetes
Apache License 2.0
254 stars 27 forks source link

Need to get just one type resource #12

Closed kotarusv closed 2 years ago

kotarusv commented 3 years ago

This script is very useful. I been looking for quite some to list unused PVC, not being used in any pods. I don't find any solution so far. I found this script is super helpful in what am looking for. However, It would be nice if script takes 1 or more arguments to print just a specific type of resource. For example, I want to just print unused PVC, not interested in other resources. This helps

  1. Script doesn't have to fetch every resource which is not interested. fewer API calls to cluster
  2. Easy to get information rather than searching in big list of all the resources

Srinivas Kotaru

yogeshkk commented 3 years ago

Thanks a lot @kotarusv

There are two parts.

  1. I am trying to do as few API calls as possible. There is only one big API call(list pod) and I am extracting Secret, CM, PVC, and SA from it. So if I add this flag you won't see any significant improvement in time. Only people interested in others can see significant improvement.

  2. User experience. When new users try to run the script they don't need to know all the parameters they have to provide to get the correct output. They can just run the script and they will get output. So even if I have to add such parameter it will be for power user mean it will exclude flag and you have to exclude all but the one you interested in. This again makes the life of the power user difficult so I am trying to avoid the same.

I did try to make the output nice let me know if I can improve it further also ideally If you have the big output that case of concern. Also, I have added Prometheus integration for such output you can check in Prometheus or in Grafana to view them nicely.