-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add support to detect unused CRDs #106
Conversation
would you please review this? @yonahd It was a bit tricky.. the default generic kubernetes.Interface seems not to support working with api-extension.. so I needed to use api-extenion clientset ("k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset") also as working with CRs is not possible with default clientset, I had to use dynamic clientset. I appreciate your inputs on this. |
I reviewed the code on a high level and it looks overall good.(we'll do a proper code review in the next few days hopefully) The question here is whether presenting the user with individual unused CRDs adds value. Take
If only one of the above is not used can the user uninstall that individual CRD or is he bound by the higher level of Maybe we should be returning only the higher-level that all it's CRDs are not used, WDYT? |
It actually really depends.. for example for the monitoring.coreos.com, the prometheus operator neeeds all the CRDs to exist.. but for other project (e.g. argoproj.io) it has many components (argo-workflow, argo-events, argo-cd, argo-appset controller), which all of those CRDs are in the same higher level api group, but they can be deployed independently and each of those use their own set of CRDs in that api group. So I think to cover all such cases, it's better to left the decision on whether they can remove the CRDs or not, to user and we will only report on a per CRD basis. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall.
Please rebase and see the comment for making this code cleaner
@@ -80,6 +82,78 @@ func GetKubeClient(kubeconfig string) *kubernetes.Clientset { | |||
return clientset | |||
} | |||
|
|||
func GetAPIExtensionsClient(kubeconfig string) *apiextensionsclientset.Clientset { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very similar code to GetKubeClient
function
Let's create a function that gets the config and we can create different clientsets based off this function
Same for dynamic client
Also if you can add a couple test for this that would be great! |
@m-yosefpor Do you intend to finish this MR? |
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## unused_crds #106 +/- ##
===============================================
- Coverage 42.82% 39.52% -3.30%
===============================================
Files 17 18 +1
Lines 1749 1895 +146
===============================================
Hits 749 749
- Misses 898 1044 +146
Partials 102 102
☔ View full report in Codecov by Sentry. |
fixes #103