diff --git a/README.md b/README.md index cf5a2fab8..aa9d7493f 100644 --- a/README.md +++ b/README.md @@ -388,6 +388,22 @@ To tap multiple pods using regex - ^C ``` +## Configuration + +Mizu can work with config file which should be stored in ${HOME}/.mizu/config.yaml (macOS: ~/.mizu/config.yaml)
+In case no config file found, defaults will be used.
+In case of partial configuration defined, all other fields will be used with defaults.
+You can always override the defaults or config file with CLI flags. + +To get the default config params run `mizu config`
+To generate a new config file with default values use `mizu config -r` + +Mizu has several undocumented flags which can be set by using --set flag (e.g., `mizu tap --set dump-logs=true`) +* **mizu-resources-namespace**: Type - String, See [Namespace-Restricted Mode](#namespace-restricted-mode) +* **telemetry**: Type - Boolean, Reports telemetry +* **dump-logs**: Type - Boolean, At the end of the execution it creates a zip file with logs (in .mizu folder) +* **kube-config-path**: Type - String, Setting the path to kube config (which isn't in standard path) + ## Advanced Usage ### Namespace-Restricted Mode diff --git a/cli/README.md b/cli/README.md deleted file mode 100644 index 5dd208131..000000000 --- a/cli/README.md +++ /dev/null @@ -1,26 +0,0 @@ -# mizu CLI -## Usage -`./mizu {pod_name_regex}` - -### Optional Flags - -| flag | default | purpose | -|----------------------|------------------|--------------------------------------------------------------------------------------------------------------| -| `--no-gui` | `false` | Don't host the web interface (not applicable at the moment) | -| `--gui-port` | `8899` | local port that web interface will be forwarded to | -| `--namespace` | | use namespace different than the one found in kubeconfig | -| `--kubeconfig` | | Path to custom kubeconfig file | - -There are some extra flags defined in code that will show up in `./mizu --help`, these are non functional stubs for now - -## Installation -Make sure your go version is at least 1.11 -1. cd to `mizu/cli` -2. Run `go mod download` (may take a moment) -3. Run `go build mizu.go` - -Alternatively, you can build+run directly using `go run mizu.go {pod_name_regex}` - - -## Known issues -* mid-flight port forwarding failures are not detected and no indication will be shown when this occurs diff --git a/cli/cmd/fetch.go b/cli/cmd/fetch.go index 184dc1450..3b9b4cc09 100644 --- a/cli/cmd/fetch.go +++ b/cli/cmd/fetch.go @@ -12,7 +12,7 @@ var fetchCmd = &cobra.Command{ Short: "Download recorded traffic to files", RunE: func(cmd *cobra.Command, args []string) error { go mizu.ReportRun("fetch", mizu.Config.Fetch) - if isCompatible, err := mizu.CheckVersionCompatibility(mizu.Config.Fetch.MizuPort); err != nil { + if isCompatible, err := mizu.CheckVersionCompatibility(mizu.Config.Fetch.GuiPort); err != nil { return err } else if !isCompatible { return nil @@ -31,5 +31,5 @@ func init() { fetchCmd.Flags().StringP(configStructs.DirectoryFetchName, "d", defaultFetchConfig.Directory, "Provide a custom directory for fetched entries") fetchCmd.Flags().Int(configStructs.FromTimestampFetchName, defaultFetchConfig.FromTimestamp, "Custom start timestamp for fetched entries") fetchCmd.Flags().Int(configStructs.ToTimestampFetchName, defaultFetchConfig.ToTimestamp, "Custom end timestamp fetched entries") - fetchCmd.Flags().Uint16P(configStructs.MizuPortFetchName, "p", defaultFetchConfig.MizuPort, "Custom port for mizu") + fetchCmd.Flags().Uint16P(configStructs.GuiPortFetchName, "p", defaultFetchConfig.GuiPort, "Provide a custom port for the web interface webserver") } diff --git a/cli/cmd/fetchRunner.go b/cli/cmd/fetchRunner.go index 3cc966481..9c372a632 100644 --- a/cli/cmd/fetchRunner.go +++ b/cli/cmd/fetchRunner.go @@ -16,7 +16,7 @@ import ( ) func RunMizuFetch() { - mizuProxiedUrl := kubernetes.GetMizuApiServerProxiedHostAndPath(mizu.Config.Fetch.MizuPort) + mizuProxiedUrl := kubernetes.GetMizuApiServerProxiedHostAndPath(mizu.Config.Fetch.GuiPort) resp, err := http.Get(fmt.Sprintf("http://%s/api/har?from=%v&to=%v", mizuProxiedUrl, mizu.Config.Fetch.FromTimestamp, mizu.Config.Fetch.ToTimestamp)) if err != nil { log.Fatal(err) diff --git a/cli/cmd/tap.go b/cli/cmd/tap.go index 17dc116d1..72e71f3fb 100644 --- a/cli/cmd/tap.go +++ b/cli/cmd/tap.go @@ -64,9 +64,9 @@ func init() { tapCmd.Flags().Bool(configStructs.AnalysisTapName, defaultTapConfig.Analysis, "Uploads traffic to UP9 for further analysis (Beta)") tapCmd.Flags().BoolP(configStructs.AllNamespacesTapName, "A", defaultTapConfig.AllNamespaces, "Tap all namespaces") tapCmd.Flags().StringArrayP(configStructs.PlainTextFilterRegexesTapName, "r", defaultTapConfig.PlainTextFilterRegexes, "List of regex expressions that are used to filter matching values from text/plain http bodies") - tapCmd.Flags().Bool(configStructs.HideHealthChecksTapName, defaultTapConfig.HideHealthChecks, "hides requests with kube-probe or prometheus user-agent headers") + tapCmd.Flags().Bool(configStructs.HideHealthChecksTapName, defaultTapConfig.HideHealthChecks, "Hides requests with kube-probe or prometheus user-agent headers") tapCmd.Flags().Bool(configStructs.DisableRedactionTapName, defaultTapConfig.DisableRedaction, "Disables redaction of potentially sensitive request/response headers and body values") - tapCmd.Flags().String(configStructs.HumanMaxEntriesDBSizeTapName, defaultTapConfig.HumanMaxEntriesDBSize, "override the default max entries db size of 200mb") + tapCmd.Flags().String(configStructs.HumanMaxEntriesDBSizeTapName, defaultTapConfig.HumanMaxEntriesDBSize, "Override the default max entries db size") tapCmd.Flags().String(configStructs.DirectionTapName, defaultTapConfig.Direction, "Record traffic that goes in this direction (relative to the tapped pod): in/any") tapCmd.Flags().Bool(configStructs.DryRunTapName, defaultTapConfig.DryRun, "Preview of all pods matching the regex, without tapping them") tapCmd.Flags().String(configStructs.EnforcePolicyFile, defaultTapConfig.EnforcePolicyFile, "Yaml file with policy rules") diff --git a/cli/mizu/configStructs/fetchConfig.go b/cli/mizu/configStructs/fetchConfig.go index 8d2eab946..e84fba8b6 100644 --- a/cli/mizu/configStructs/fetchConfig.go +++ b/cli/mizu/configStructs/fetchConfig.go @@ -4,12 +4,12 @@ const ( DirectoryFetchName = "directory" FromTimestampFetchName = "from" ToTimestampFetchName = "to" - MizuPortFetchName = "port" + GuiPortFetchName = "gui-port" ) type FetchConfig struct { Directory string `yaml:"directory" default:"."` FromTimestamp int `yaml:"from" default:"0"` ToTimestamp int `yaml:"to" default:"0"` - MizuPort uint16 `yaml:"port" default:"8899"` + GuiPort uint16 `yaml:"gui-port" default:"8899"` }