diff --git a/cmd/probe.go b/cmd/probe.go index 1278ee87..90d50142 100644 --- a/cmd/probe.go +++ b/cmd/probe.go @@ -8,6 +8,8 @@ import ( "github.com/spf13/cobra" ) +var verbose bool + var probeInstallOptions probe.Options // probeCmd represents the get command @@ -22,16 +24,16 @@ and what KubeArmor features will be supported e.g: observability, enforcement, e If KubeArmor is running, It probes which environment KubeArmor is running on (e.g: systemd mode, kubernetes etc.), the supported KubeArmor features in the environment, the pods being handled by KubeArmor and the policies running on each of these pods`, RunE: func(cmd *cobra.Command, args []string) error { - if err := probe.PrintProbeResult(client, probeInstallOptions); err != nil { - return err + if !verbose { + return probe.PrintAnnotatedPods(client, probeInstallOptions) } - return nil - + return probe.PrintProbeResult(client, probeInstallOptions); err != nil { }, } func init() { rootCmd.AddCommand(probeCmd) + probeCmd.Flags().BoolVarP(&verbose, "verbose", "v", false, "print verbose output of karmor probe") probeCmd.Flags().StringVarP(&probeInstallOptions.Namespace, "namespace", "n", "kube-system", "Namespace for resources") probeCmd.Flags().BoolVar(&probeInstallOptions.Full, "full", false, `If KubeArmor is not running, it deploys a daemonset to have access to more information on KubeArmor support in the environment and deletes daemonset after probing`) diff --git a/probe/probe.go b/probe/probe.go index 71ec6750..ad0215af 100644 --- a/probe/probe.go +++ b/probe/probe.go @@ -70,6 +70,17 @@ func probeDaemonUninstaller(c *k8s.Client, o Options) error { return nil } +// PrintAnnotatedPods only annotated pods and corresponding policies +func PrintAnnotatedPods(c *k8s.Client, o Options) error { + if isKubeArmorRunning(c, o) { + err := getAnnotatedPods(c) + if err != nil { + log.Println("error occured when getting annotated pods", err) + } + } + return nil +} + // PrintProbeResult prints the result for the host and k8s probing kArmor does to check compatibility with KubeArmor func PrintProbeResult(c *k8s.Client, o Options) error { if runtime.GOOS != "linux" {