Tap multiple pods statically (#51)

* WIP

* Update tap.go, provider.go, and 2 more files...

* WIP

* WIP

* Solved routine hanging forever: Added missing flag when calling mizuagent.

* Iterate channel with range.

* Panic if har channel is nil or if websocket connection is nil.

* StartPassiveTapper returns read only channel.

* Solved program exiting immediately: Wait for interrupt signal instead of exiting.

* Solve connecting issue - Retry a few times.

* Use lib const instead of magic.

* Nicer error prints.

* Don't coninue piping message if there is an error.

* Comment.

* Dependency injection.

* no message

* Fixed comment.

* Print tapped addresses when they are updated.

* Print errors in cleanup if there are any.

Co-authored-by: RamiBerm <rami.berman@up9.com>
Co-authored-by: Roee Gadot <roee.gadot@up9.com>
This commit is contained in:
nimrod-up9
2021-05-20 12:22:23 +03:00
committed by GitHub
parent 1ddc7f2f6b
commit da24608bec
14 changed files with 461 additions and 162 deletions

View File

@@ -2,6 +2,8 @@ package cmd
import (
"errors"
"fmt"
"regexp"
"github.com/spf13/cobra"
@@ -10,20 +12,25 @@ import (
)
var tapCmd = &cobra.Command{
Use: "tap [PODNAME]",
Use: "tap [POD REGEX]",
Short: "Record ingoing traffic of a kubernetes pod",
Long: `Record the ingoing traffic of a kubernetes pod.
Supported protocols are HTTP and gRPC.`,
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
return errors.New("PODNAME argument is required")
return errors.New("POD REGEX argument is required")
} else if len(args) > 1 {
return errors.New("Unexpected number of arguments")
}
podName := args[0]
regex, err := regexp.Compile(args[0])
if err != nil {
mizu.Run(podName)
return errors.New(fmt.Sprintf("%s is not a valid regex %s", args[0], err))
return nil
}
mizu.Run(regex)
return nil
},
}