Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion flytectl/cmd/config/subcommand/sandbox/config_flags.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 9 additions & 8 deletions flytectl/cmd/config/subcommand/sandbox/sandbox_config.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package sandbox

import (
"fmt"

"github.com/flyteorg/flyte/flytectl/pkg/docker"
)

Expand Down Expand Up @@ -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"
}
8 changes: 7 additions & 1 deletion flytectl/pkg/docker/docker_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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{
Expand Down
7 changes: 5 additions & 2 deletions flytectl/pkg/sandbox/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Loading