-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(kuma-cni): add a init container to validate iptables rules are a…
…pplied (#9699) --------- Signed-off-by: Jay Jijie Chen <[email protected]> Co-authored-by: Krzysztof Słonka <[email protected]>
- Loading branch information
Showing
25 changed files
with
923 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
app/kumactl/cmd/install/install_transparent_proxy_validator.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
//go:build !windows | ||
// +build !windows | ||
|
||
package install | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"github.com/kumahq/kuma/pkg/core" | ||
kuma_log "github.com/kumahq/kuma/pkg/log" | ||
"github.com/kumahq/kuma/pkg/transparentproxy" | ||
"github.com/kumahq/kuma/pkg/transparentproxy/validate" | ||
) | ||
|
||
const defaultLogName = "validator" | ||
|
||
type transparentProxyValidatorArgs struct { | ||
IpFamilyMode string | ||
ValidationServerPort uint16 | ||
} | ||
|
||
func newInstallTransparentProxyValidator() *cobra.Command { | ||
args := transparentProxyValidatorArgs{ | ||
IpFamilyMode: "dualstack", | ||
ValidationServerPort: validate.ValidationServerPort, | ||
} | ||
cmd := &cobra.Command{ | ||
Use: "transparent-proxy-validator", | ||
Short: "Validates if transparent proxy has been set up successfully", | ||
Long: `Validates the transparent proxy setup by testing if the applied | ||
iptables rules are working correctly onto the pod. | ||
Follow the following steps to validate: | ||
1) install the transparent proxy using 'kumactl install transparent-proxy' | ||
2) run this command | ||
The result will be shown as text in stdout as well as the exit code. | ||
`, | ||
RunE: func(cmd *cobra.Command, _ []string) error { | ||
log := core.NewLoggerTo(os.Stdout, kuma_log.InfoLevel).WithName(defaultLogName) | ||
|
||
ipv6Supported, _ := transparentproxy.HasLocalIPv6() | ||
useIPv6 := ipv6Supported && args.IpFamilyMode == "ipv6" | ||
|
||
validator := validate.NewValidator(useIPv6, args.ValidationServerPort, log) | ||
|
||
return validator.Run() | ||
}, | ||
} | ||
|
||
cmd.Flags().StringVar(&args.IpFamilyMode, "ip-family-mode", args.IpFamilyMode, "The IP family mode that has enabled traffic redirection for when setting up transparent proxy. Can be 'dualstack' or 'ipv4'") | ||
cmd.Flags().Uint16Var(&args.ValidationServerPort, "validation-server-port", args.ValidationServerPort, "The port that the validation server will listen") | ||
return cmd | ||
} |
16 changes: 16 additions & 0 deletions
16
app/kumactl/cmd/install/install_transparent_proxy_validator_windows.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package install | ||
|
||
import ( | ||
"github.com/pkg/errors" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func newInstallTransparentProxyValidator() *cobra.Command { | ||
return &cobra.Command{ | ||
Use: "transparent-proxy-validator", | ||
Short: "Validates if transparent proxy has been set up successfully", | ||
RunE: func(_ *cobra.Command, _ []string) error { | ||
return errors.New("This command is not supported on your operating system") | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
package util | ||
|
||
const ( | ||
KumaSidecarContainerName = "kuma-sidecar" | ||
KumaGatewayContainerName = "kuma-gateway" | ||
KumaInitContainerName = "kuma-init" | ||
KumaSidecarContainerName = "kuma-sidecar" | ||
KumaGatewayContainerName = "kuma-gateway" | ||
KumaInitContainerName = "kuma-init" | ||
KumaCniValidationContainerName = "kuma-validation" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.