Merge pull request #89 from up9inc/tap_grooming

Mizu tap analyze grooming
This commit is contained in:
Igor Gov 2021-06-30 12:12:49 +03:00 committed by GitHub
commit 35ef211477
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 6 deletions

View File

@ -63,7 +63,7 @@ func init() {
tapCmd.Flags().Uint16VarP(&mizuTapOptions.GuiPort, "gui-port", "p", 8899, "Provide a custom port for the web interface webserver") tapCmd.Flags().Uint16VarP(&mizuTapOptions.GuiPort, "gui-port", "p", 8899, "Provide a custom port for the web interface webserver")
tapCmd.Flags().StringVarP(&mizuTapOptions.Namespace, "namespace", "n", "", "Namespace selector") tapCmd.Flags().StringVarP(&mizuTapOptions.Namespace, "namespace", "n", "", "Namespace selector")
tapCmd.Flags().BoolVar(&mizuTapOptions.Analyze, "analyze", false, "Analyze traffic") tapCmd.Flags().BoolVar(&mizuTapOptions.Analyze, "analyze", false, "Uploads traffic to UP9 cloud for further analysis")
tapCmd.Flags().StringVar(&mizuTapOptions.AnalyzeDestination, "dest", "up9.app", "Destination environment") tapCmd.Flags().StringVar(&mizuTapOptions.AnalyzeDestination, "dest", "up9.app", "Destination environment")
tapCmd.Flags().BoolVarP(&mizuTapOptions.AllNamespaces, "all-namespaces", "A", false, "Tap all namespaces") tapCmd.Flags().BoolVarP(&mizuTapOptions.AllNamespaces, "all-namespaces", "A", false, "Tap all namespaces")
tapCmd.Flags().StringVarP(&mizuTapOptions.KubeConfigPath, "kube-config", "k", "", "Path to kube-config file") tapCmd.Flags().StringVarP(&mizuTapOptions.KubeConfigPath, "kube-config", "k", "", "Path to kube-config file")

View File

@ -73,7 +73,7 @@ func RunMizuTap(podRegexQuery *regexp.Regexp, tappingOptions *MizuTapOptions) {
return return
} }
go portForwardApiPod(ctx, kubernetesProvider, cancel, tappingOptions, ) // TODO convert this to job for built in pod ttl or have the running app handle this go portForwardApiPod(ctx, kubernetesProvider, cancel, tappingOptions) // TODO convert this to job for built in pod ttl or have the running app handle this
go watchPodsForTapping(ctx, kubernetesProvider, cancel, podRegexQuery, tappingOptions) go watchPodsForTapping(ctx, kubernetesProvider, cancel, podRegexQuery, tappingOptions)
go syncApiStatus(ctx, cancel, tappingOptions) go syncApiStatus(ctx, cancel, tappingOptions)
@ -86,7 +86,6 @@ type GuestToken struct {
Model string `json:"model"` Model string `json:"model"`
} }
func getGuestToken(url string, target *GuestToken) error { func getGuestToken(url string, target *GuestToken) error {
resp, err := http.Get(url) resp, err := http.Get(url)
if err != nil { if err != nil {
@ -104,8 +103,6 @@ func CreateAnonymousToken(envPrefix string) (*GuestToken, error) {
fmt.Println(err) fmt.Println(err)
return nil, err return nil, err
} }
fmt.Println("Token:", token.Token, "model:", token.Model)
return token, nil return token, nil
} }
@ -283,6 +280,7 @@ func portForwardApiPod(ctx context.Context, kubernetesProvider *kubernetes.Provi
if _, err := http.Get(fmt.Sprintf("http://localhost:%d/api/uploadEntries?token=%s&model=%s&dest=%s", tappingOptions.GuiPort, token.Token, token.Model, tappingOptions.AnalyzeDestination)); err != nil { if _, err := http.Get(fmt.Sprintf("http://localhost:%d/api/uploadEntries?token=%s&model=%s&dest=%s", tappingOptions.GuiPort, token.Token, token.Model, tappingOptions.AnalyzeDestination)); err != nil {
fmt.Println(err) fmt.Println(err)
} else { } else {
fmt.Println("Staring to upload and analyze the data, it may take a few minutes")
fmt.Println("https://" + tappingOptions.AnalyzeDestination + "/share/" + token.Token) fmt.Println("https://" + tappingOptions.AnalyzeDestination + "/share/" + token.Token)
} }
} }