FairwindsOps / pluto

A cli tool to help discover deprecated apiVersions in Kubernetes
https://fairwinds.com
Apache License 2.0
2.14k stars 124 forks source link

Add a `detect-all-in-cluster` command to run both `detect-helm` and `detect-api-resources` #455

Closed ivanfetch-wt closed 1 year ago

ivanfetch-wt commented 1 year ago

Checklist

Description

What's the goal of this PR?

Add a command to Pluto that combines all in-cluster detections - currently detect-helm and detect-api-resources.

Sample Output

$ ./pluto detect-all-in-cluster 2>/dev/null
NAME              KIND                VERSION                     REPLACEMENT            REMOVED   DEPRECATED  
badhelm/badhelm   Ingress             networking.k8s.io/v1beta1   networking.k8s.io/v1   true      true        
webapp            Ingress             networking.k8s.io/v1beta1   networking.k8s.io/v1   true      true        
webapp            Ingress             networking.k8s.io/v1beta1   networking.k8s.io/v1   true      true        
eks.privileged    PodSecurityPolicy   policy/v1beta1                                     false     true        
$ ./pluto detect-helm 2>/dev/null
NAME              KIND      VERSION                     REPLACEMENT            REMOVED   DEPRECATED  
badhelm/badhelm   Ingress   networking.k8s.io/v1beta1   networking.k8s.io/v1   true      true        
$ ./pluto detect-api-resources 2>/dev/null
NAME             KIND                VERSION                     REPLACEMENT            REMOVED   DEPRECATED  
webapp           Ingress             networking.k8s.io/v1beta1   networking.k8s.io/v1   true      true        
webapp           Ingress             networking.k8s.io/v1beta1   networking.k8s.io/v1   true      true        
eks.privileged   PodSecurityPolicy   policy/v1beta1                                     false     true        

What changes did you make?

I moved some code from the Cobra Run struct field into reusable functions, so I could call them from the new detect-all-in-cluster command.

What alternative solution should we consider, if any?

Although the detect-all-in-cluster command instantiates both a dynamic Kubernetes client and a Helm client, the only duplicated work is calling our kube.GetConfig() function, but determining the KubeConfig file twice is reasonable, compared to retaining it the first time and passing it around.

fairwinds-insights[bot] commented 1 year ago

Fairwinds Insights CI Report

View the Full Report

:white_check_mark: No new Action Items detected!