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