Skip to content
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

add verbose flag for karmor probe #227

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions cmd/probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"github.com/spf13/cobra"
)

var verbose bool

var probeInstallOptions probe.Options

// probeCmd represents the get command
Expand All @@ -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`)
Expand Down
11 changes: 11 additions & 0 deletions probe/probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down