feat: add --kubeconfig flag (#858)

* feat: add --kubeconfig flag

* docs: add kubeconfig flag example
This commit is contained in:
Alessio Greggi
2022-10-06 08:11:42 +03:00
committed by GitHub
parent 81c3c34ab8
commit 13f09315e7
2 changed files with 9 additions and 0 deletions
+5
View File
@@ -194,6 +194,11 @@ kubescape scan framework mitre --submit
kubescape scan control "Privileged container"
```
#### Scan using an anternative kubeconfig file
```
kubescape scan --kubeconfig cluster.conf
```
#### Scan specific namespaces
```
kubescape scan --include-namespaces development,staging,production
+4
View File
@@ -1,6 +1,7 @@
package scan
import (
"flag"
"fmt"
"github.com/kubescape/k8s-interface/k8sinterface"
@@ -97,6 +98,9 @@ func GetScanCommand(ks meta.IKubescape) *cobra.Command {
scanCmd.PersistentFlags().MarkHidden("silent") // this flag should be deprecated since we added the --logger support
// scanCmd.PersistentFlags().MarkHidden("format-version") // meant for testing different output approaches and not for common use
// Retrieve --kubeconfig flag from https://github.com/kubernetes/kubectl/blob/master/pkg/cmd/cmd.go
scanCmd.PersistentFlags().AddGoFlag(flag.Lookup("kubeconfig"))
hostF := scanCmd.PersistentFlags().VarPF(&scanInfo.HostSensorEnabled, "enable-host-scan", "", "Deploy ARMO K8s host-sensor daemonset in the scanned cluster. Deleting it right after we collecting the data. Required to collect valuable data from cluster nodes for certain controls. Yaml file: https://github.com/kubescape/kubescape/blob/master/core/pkg/hostsensorutils/hostsensor.yaml")
hostF.NoOptDefVal = "true"
hostF.DefValue = "false, for no TTY in stdin"