From 6e92a8835cfacd9adc38271db629c18661f2c964 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 --- cmd/demo/start.go | 2 +- cmd/demo/start_test.go | 2 +- pkg/docker/docker_util.go | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/cmd/demo/start.go b/cmd/demo/start.go index 0102b9d8..2ee48d9a 100644 --- a/cmd/demo/start.go +++ b/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/cmd/demo/start_test.go b/cmd/demo/start_test.go index b04a595a..70ab2cb7 100644 --- a/cmd/demo/start_test.go +++ b/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/pkg/docker/docker_util.go b/pkg/docker/docker_util.go index 84374481..b6bef954 100644 --- a/pkg/docker/docker_util.go +++ b/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