From 790a96566d195c601017e8a95aa0aec986b6ff7e Mon Sep 17 00:00:00 2001 From: Eduardo Apolinario <653394+eapolinario@users.noreply.github.com> Date: Wed, 20 Apr 2022 11:38:14 -0700 Subject: [PATCH] Bind 30080 to 30081 in the case of sandbox (#313) Signed-off-by: Eduardo Apolinario Co-authored-by: Eduardo Apolinario --- flytectl/cmd/demo/start.go | 2 +- flytectl/cmd/demo/start_test.go | 2 +- flytectl/pkg/docker/docker_util.go | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/flytectl/cmd/demo/start.go b/flytectl/cmd/demo/start.go index 0102b9d8cb..2ee48d9a0f 100644 --- a/flytectl/cmd/demo/start.go +++ b/flytectl/cmd/demo/start.go @@ -224,7 +224,7 @@ func startDemo(ctx context.Context, cli docker.Docker, reader io.Reader) (*bufio } fmt.Printf("%v booting flyte-demo container\n", emoji.FactoryWorker) - exposedPorts, portBindings, _ := docker.GetSandboxPorts() + exposedPorts, portBindings, _ := docker.GetDemoPorts() ID, err := docker.StartContainer(ctx, cli, volumes, exposedPorts, portBindings, docker.FlyteSandboxClusterName, demoImage, sandboxDefaultConfig.Env) diff --git a/flytectl/cmd/demo/start_test.go b/flytectl/cmd/demo/start_test.go index b04a595a91..70ab2cb749 100644 --- a/flytectl/cmd/demo/start_test.go +++ b/flytectl/cmd/demo/start_test.go @@ -78,7 +78,7 @@ var fakePod = corev1.Pod{ } func TestStartDemoFunc(t *testing.T) { - p1, p2, _ := docker.GetSandboxPorts() + p1, p2, _ := docker.GetDemoPorts() assert.Nil(t, util.SetupFlyteDir()) assert.Nil(t, os.MkdirAll(f.FilePathJoin(f.UserHomeDir(), ".flyte", "k3s"), os.ModePerm)) assert.Nil(t, ioutil.WriteFile(docker.Kubeconfig, []byte(content), os.ModePerm)) diff --git a/flytectl/pkg/docker/docker_util.go b/flytectl/pkg/docker/docker_util.go index 84374481ea..b6bef9549e 100644 --- a/flytectl/pkg/docker/docker_util.go +++ b/flytectl/pkg/docker/docker_util.go @@ -93,6 +93,21 @@ func RemoveSandbox(ctx context.Context, cli Docker, reader io.Reader) error { // GetSandboxPorts will return sandbox ports func GetSandboxPorts() (map[nat.Port]struct{}, map[nat.Port][]nat.PortBinding, error) { + 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 + "0.0.0.0:30080:30081", // Flyteconsole Port. + "0.0.0.0:30081:30081", // Flyteadmin Port + "0.0.0.0:30082:30082", // K8s Dashboard Port + "0.0.0.0:30084:30084", // Minio API Port + "0.0.0.0:30086:30086", // K8s cluster + "0.0.0.0:30088:30088", // Minio Console Port + "0.0.0.0:30089:30089", // Postgres Port + }) +} + +// GetDemoPorts will return demo ports +func GetDemoPorts() (map[nat.Port]struct{}, map[nat.Port][]nat.PortBinding, error) { return nat.ParsePortSpecs([]string{ "0.0.0.0:30080:30080", // Flyteconsole Port "0.0.0.0:30081:30081", // Flyteadmin Port