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 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 12 additions & 3 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,23 @@ 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 {
err := probe.PrintAnnotatedPods(client, probeInstallOptions)
if err != nil {
return err
}
} else {
if err := probe.PrintProbeResult(client, probeInstallOptions); err != nil {
return err
}
}
return nil
kranurag7 marked this conversation as resolved.
Show resolved Hide resolved

},
}

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
}

// only annotated pods and corresponding policies
kranurag7 marked this conversation as resolved.
Show resolved Hide resolved
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