From e12d3cc937a40afd1a8d2d6f76427d6c43b6a128 Mon Sep 17 00:00:00 2001 From: Muskan Kumari Date: Sun, 10 May 2026 12:14:18 +0530 Subject: [PATCH 1/3] feat: add custom port support for sandbox Signed-off-by: Muskan Kumari --- .../config/subcommand/sandbox/config_flags.go | 2 +- .../config/subcommand/sandbox/sandbox_config.go | 17 +++++++++-------- flytectl/pkg/docker/docker_util.go | 8 +++++++- flytectl/pkg/sandbox/start.go | 7 +++++-- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/flytectl/cmd/config/subcommand/sandbox/config_flags.go b/flytectl/cmd/config/subcommand/sandbox/config_flags.go index 9238a0b5daa..c9476d78f7f 100755 --- a/flytectl/cmd/config/subcommand/sandbox/config_flags.go +++ b/flytectl/cmd/config/subcommand/sandbox/config_flags.go @@ -63,6 +63,6 @@ func (cfg Config) GetPFlagSet(prefix string) *pflag.FlagSet { cmdFlags.BoolVar(&DefaultConfig.Dev, fmt.Sprintf("%v%v", prefix, "dev"), DefaultConfig.Dev, "Optional. Only start minio and postgres in the sandbox.") cmdFlags.BoolVar(&DefaultConfig.DryRun, fmt.Sprintf("%v%v", prefix, "dryRun"), DefaultConfig.DryRun, "Optional. Only print the docker commands to bring up flyte sandbox/demo container.This will still call github api's to get the latest flyte release to use'") cmdFlags.BoolVar(&DefaultConfig.Force, fmt.Sprintf("%v%v", prefix, "force"), DefaultConfig.Force, "Optional. Forcefully delete existing sandbox cluster if it exists.") - cmdFlags.StringVar(&DefaultConfig.Port, fmt.Sprintf("%v%v", prefix, "port"), DefaultConfig.Port, "Optional. Specify the port for the Kubernetes in the sandbox.") + cmdFlags.StringSliceVar(&DefaultConfig.Ports, fmt.Sprintf("%v%v", prefix, "ports"), DefaultConfig.Ports, "Optional. Custom port mappings for sandbox.") return cmdFlags } diff --git a/flytectl/cmd/config/subcommand/sandbox/sandbox_config.go b/flytectl/cmd/config/subcommand/sandbox/sandbox_config.go index 6edf676913b..faf36f3ff7b 100644 --- a/flytectl/cmd/config/subcommand/sandbox/sandbox_config.go +++ b/flytectl/cmd/config/subcommand/sandbox/sandbox_config.go @@ -1,8 +1,6 @@ package sandbox import ( - "fmt" - "github.com/flyteorg/flyte/flytectl/pkg/docker" ) @@ -44,17 +42,20 @@ type Config struct { Force bool `json:"force" pflag:",Optional. Forcefully delete existing sandbox cluster if it exists."` - // Allow user to specify the port for the sandbox - Port string `json:"port" pflag:",Optional. Specify the port for the Kubernetes in the sandbox."` +Port string `json:"port" pflag:",Optional. Specify the port for Kubernetes in the sandbox."` + +// Allow user to specify the port for the sandbox +Ports []string `json:"ports" pflag:",Optional. Custom port mappings for sandbox."` } //go:generate pflags Config --default-var DefaultConfig --bind-default-var var ( DefaultConfig = &Config{ - Port: "6443", // Default port for the sandbox - } + Port: "6443", + Ports: []string{}, // Default port mappings +} ) func (c Config) GetK8sEndpoint() string { - return fmt.Sprintf("https://127.0.0.1:%s", c.Port) -} + return "https://127.0.0.1:30086" +} \ No newline at end of file diff --git a/flytectl/pkg/docker/docker_util.go b/flytectl/pkg/docker/docker_util.go index 08a2503aa1d..0f4bbe9c6e9 100644 --- a/flytectl/pkg/docker/docker_util.go +++ b/flytectl/pkg/docker/docker_util.go @@ -120,7 +120,12 @@ func GetDevPorts() (map[nat.Port]struct{}, map[nat.Port][]nat.PortBinding, error } // GetSandboxPorts will return sandbox ports -func GetSandboxPorts() (map[nat.Port]struct{}, map[nat.Port][]nat.PortBinding, error) { +func GetSandboxPorts(customPorts []string) (map[nat.Port]struct{}, map[nat.Port][]nat.PortBinding, error) { + + if len(customPorts) > 0 { + return nat.ParsePortSpecs(customPorts) + } + return nat.ParsePortSpecs([]string{ // Notice that two host ports are mapped to the same container port in the case of Flyteconsole, this is done to // support the generated URLs produced by pyflyte run @@ -134,6 +139,7 @@ func GetSandboxPorts() (map[nat.Port]struct{}, map[nat.Port][]nat.PortBinding, e }) } + // GetDemoPorts will return demo ports func GetDemoPorts(k8sPort string) (map[nat.Port]struct{}, map[nat.Port][]nat.PortBinding, error) { return nat.ParsePortSpecs([]string{ diff --git a/flytectl/pkg/sandbox/start.go b/flytectl/pkg/sandbox/start.go index 5536708988d..e72f90572e5 100644 --- a/flytectl/pkg/sandbox/start.go +++ b/flytectl/pkg/sandbox/start.go @@ -419,14 +419,17 @@ func StartDemoCluster(ctx context.Context, args []string, sandboxConfig *sandbox func StartSandboxCluster(ctx context.Context, args []string, sandboxConfig *sandboxCmdConfig.Config) error { demoImagePrefix := "dind" - exposedPorts, portBindings, err := docker.GetSandboxPorts() + + exposedPorts, portBindings, err := docker.GetSandboxPorts(sandboxConfig.Ports) if err != nil { return err } + err = StartClusterForSandbox(ctx, args, sandboxConfig, sandboxImageName, demoImagePrefix, exposedPorts, portBindings, util.SandBoxConsolePort) if err != nil { return err } + util.PrintSandboxStartMessage(util.SandBoxConsolePort, docker.SandboxKubeconfig, sandboxConfig.DryRun) return nil -} +} \ No newline at end of file From e034dbc5c3356b0f1b5c19b25d80a103bfe968cd Mon Sep 17 00:00:00 2001 From: Muskan Kumari Date: Sun, 10 May 2026 13:26:33 +0530 Subject: [PATCH 2/3] chore: regenerate generated files Signed-off-by: Muskan Kumari --- .../config/subcommand/sandbox/sandbox_config.go | 14 +++++++------- flytectl/pkg/docker/docker_util.go | 1 - flytectl/pkg/sandbox/start.go | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/flytectl/cmd/config/subcommand/sandbox/sandbox_config.go b/flytectl/cmd/config/subcommand/sandbox/sandbox_config.go index faf36f3ff7b..6307d3fc7e0 100644 --- a/flytectl/cmd/config/subcommand/sandbox/sandbox_config.go +++ b/flytectl/cmd/config/subcommand/sandbox/sandbox_config.go @@ -42,20 +42,20 @@ type Config struct { Force bool `json:"force" pflag:",Optional. Forcefully delete existing sandbox cluster if it exists."` -Port string `json:"port" pflag:",Optional. Specify the port for Kubernetes in the sandbox."` + Port string `json:"port" pflag:",Optional. Specify the port for Kubernetes in the sandbox."` -// Allow user to specify the port for the sandbox -Ports []string `json:"ports" pflag:",Optional. Custom port mappings for sandbox."` + // Allow user to specify the port for the sandbox + Ports []string `json:"ports" pflag:",Optional. Custom port mappings for sandbox."` } //go:generate pflags Config --default-var DefaultConfig --bind-default-var var ( DefaultConfig = &Config{ - Port: "6443", - Ports: []string{}, // Default port mappings -} + Port: "6443", + Ports: []string{}, // Default port mappings + } ) func (c Config) GetK8sEndpoint() string { return "https://127.0.0.1:30086" -} \ No newline at end of file +} diff --git a/flytectl/pkg/docker/docker_util.go b/flytectl/pkg/docker/docker_util.go index 0f4bbe9c6e9..cbd5ed8b41d 100644 --- a/flytectl/pkg/docker/docker_util.go +++ b/flytectl/pkg/docker/docker_util.go @@ -139,7 +139,6 @@ func GetSandboxPorts(customPorts []string) (map[nat.Port]struct{}, map[nat.Port] }) } - // GetDemoPorts will return demo ports func GetDemoPorts(k8sPort string) (map[nat.Port]struct{}, map[nat.Port][]nat.PortBinding, error) { return nat.ParsePortSpecs([]string{ diff --git a/flytectl/pkg/sandbox/start.go b/flytectl/pkg/sandbox/start.go index e72f90572e5..22d24a3198f 100644 --- a/flytectl/pkg/sandbox/start.go +++ b/flytectl/pkg/sandbox/start.go @@ -432,4 +432,4 @@ func StartSandboxCluster(ctx context.Context, args []string, sandboxConfig *sand util.PrintSandboxStartMessage(util.SandBoxConsolePort, docker.SandboxKubeconfig, sandboxConfig.DryRun) return nil -} \ No newline at end of file +} From 90a587f5c3c70185204a6e54e204c5b7d5ee8cb5 Mon Sep 17 00:00:00 2001 From: Muskan Kumari Date: Sun, 10 May 2026 13:31:42 +0530 Subject: [PATCH 3/3] feat: add custom port support for sandbox Signed-off-by: Muskan Kumari --- .../config/subcommand/sandbox/sandbox_config.go | 14 +++++++------- flytectl/pkg/docker/docker_util.go | 1 + flytectl/pkg/sandbox/start.go | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/flytectl/cmd/config/subcommand/sandbox/sandbox_config.go b/flytectl/cmd/config/subcommand/sandbox/sandbox_config.go index 6307d3fc7e0..faf36f3ff7b 100644 --- a/flytectl/cmd/config/subcommand/sandbox/sandbox_config.go +++ b/flytectl/cmd/config/subcommand/sandbox/sandbox_config.go @@ -42,20 +42,20 @@ type Config struct { Force bool `json:"force" pflag:",Optional. Forcefully delete existing sandbox cluster if it exists."` - Port string `json:"port" pflag:",Optional. Specify the port for Kubernetes in the sandbox."` +Port string `json:"port" pflag:",Optional. Specify the port for Kubernetes in the sandbox."` - // Allow user to specify the port for the sandbox - Ports []string `json:"ports" pflag:",Optional. Custom port mappings for sandbox."` +// Allow user to specify the port for the sandbox +Ports []string `json:"ports" pflag:",Optional. Custom port mappings for sandbox."` } //go:generate pflags Config --default-var DefaultConfig --bind-default-var var ( DefaultConfig = &Config{ - Port: "6443", - Ports: []string{}, // Default port mappings - } + Port: "6443", + Ports: []string{}, // Default port mappings +} ) func (c Config) GetK8sEndpoint() string { return "https://127.0.0.1:30086" -} +} \ No newline at end of file diff --git a/flytectl/pkg/docker/docker_util.go b/flytectl/pkg/docker/docker_util.go index cbd5ed8b41d..0f4bbe9c6e9 100644 --- a/flytectl/pkg/docker/docker_util.go +++ b/flytectl/pkg/docker/docker_util.go @@ -139,6 +139,7 @@ func GetSandboxPorts(customPorts []string) (map[nat.Port]struct{}, map[nat.Port] }) } + // GetDemoPorts will return demo ports func GetDemoPorts(k8sPort string) (map[nat.Port]struct{}, map[nat.Port][]nat.PortBinding, error) { return nat.ParsePortSpecs([]string{ diff --git a/flytectl/pkg/sandbox/start.go b/flytectl/pkg/sandbox/start.go index 22d24a3198f..e72f90572e5 100644 --- a/flytectl/pkg/sandbox/start.go +++ b/flytectl/pkg/sandbox/start.go @@ -432,4 +432,4 @@ func StartSandboxCluster(ctx context.Context, args []string, sandboxConfig *sand util.PrintSandboxStartMessage(util.SandBoxConsolePort, docker.SandboxKubeconfig, sandboxConfig.DryRun) return nil -} +} \ No newline at end of file