diff --git a/cmd/config/subcommand/sandbox/config_flags.go b/cmd/config/subcommand/sandbox/config_flags.go index 7b025f54..39b9ba1b 100755 --- a/cmd/config/subcommand/sandbox/config_flags.go +++ b/cmd/config/subcommand/sandbox/config_flags.go @@ -54,6 +54,7 @@ func (cfg Config) GetPFlagSet(prefix string) *pflag.FlagSet { cmdFlags.StringVar(&DefaultConfig.Version, fmt.Sprintf("%v%v", prefix, "version"), DefaultConfig.Version, "Version of flyte. Only supports flyte releases greater than v0.10.0") cmdFlags.StringVar(&DefaultConfig.Image, fmt.Sprintf("%v%v", prefix, "image"), DefaultConfig.Image, "Optional. Provide a fully qualified path to a Flyte compliant docker image.") cmdFlags.BoolVar(&DefaultConfig.Prerelease, fmt.Sprintf("%v%v", prefix, "pre"), DefaultConfig.Prerelease, "Optional. Pre release Version of flyte will be used for sandbox.") + cmdFlags.BoolVar(&DefaultConfig.DisableAgent, fmt.Sprintf("%v%v", prefix, "disable-agent"), DefaultConfig.DisableAgent, "Optional. Disable the agent service.") cmdFlags.StringSliceVar(&DefaultConfig.Env, fmt.Sprintf("%v%v", prefix, "env"), DefaultConfig.Env, "Optional. Provide Env variable in key=value format which can be passed to sandbox container.") cmdFlags.Var(&DefaultConfig.ImagePullPolicy, fmt.Sprintf("%v%v", prefix, "imagePullPolicy"), "Optional. Defines the image pull behavior [Always/IfNotPresent/Never]") cmdFlags.StringVar(&DefaultConfig.ImagePullOptions.RegistryAuth, fmt.Sprintf("%v%v", prefix, "imagePullOptions.registryAuth"), DefaultConfig.ImagePullOptions.RegistryAuth, "The base64 encoded credentials for the registry.") diff --git a/cmd/config/subcommand/sandbox/config_flags_test.go b/cmd/config/subcommand/sandbox/config_flags_test.go index 79f6e88f..37e2fc2a 100755 --- a/cmd/config/subcommand/sandbox/config_flags_test.go +++ b/cmd/config/subcommand/sandbox/config_flags_test.go @@ -155,6 +155,20 @@ func TestConfig_SetFlags(t *testing.T) { } }) }) + t.Run("Test_disable-agent", func(t *testing.T) { + + t.Run("Override", func(t *testing.T) { + testValue := "1" + + cmdFlags.Set("disable-agent", testValue) + if vBool, err := cmdFlags.GetBool("disable-agent"); err == nil { + testDecodeJson_Config(t, fmt.Sprintf("%v", vBool), &actual.DisableAgent) + + } else { + assert.FailNow(t, err.Error()) + } + }) + }) t.Run("Test_env", func(t *testing.T) { t.Run("Override", func(t *testing.T) { diff --git a/cmd/config/subcommand/sandbox/sandbox_config.go b/cmd/config/subcommand/sandbox/sandbox_config.go index 1dfce643..b1fa6985 100644 --- a/cmd/config/subcommand/sandbox/sandbox_config.go +++ b/cmd/config/subcommand/sandbox/sandbox_config.go @@ -19,6 +19,9 @@ type Config struct { // Default value false represents that Flytectl will not use the latest pre-release if it exists. Prerelease bool `json:"pre" pflag:",Optional. Pre release Version of flyte will be used for sandbox."` + // Agent Service + DisableAgent bool `json:"disable-agent" pflag:",Optional. Disable the agent service."` + // Optionally it is possible to pass in environment variables to sandbox container. Env []string `json:"env" pflag:",Optional. Provide Env variable in key=value format which can be passed to sandbox container."` diff --git a/pkg/sandbox/start.go b/pkg/sandbox/start.go index e79ec016..7a955180 100644 --- a/pkg/sandbox/start.go +++ b/pkg/sandbox/start.go @@ -229,6 +229,10 @@ func startSandbox(ctx context.Context, cli docker.Docker, g github.GHRepoService sandboxEnv = append(sandboxEnv, "FLYTE_DEV=True") } + if sandboxConfig.DisableAgent { + sandboxEnv = append(sandboxEnv, "DISABLE_AGENT=True") + } + ID, err := docker.StartContainer(ctx, cli, volumes, exposedPorts, portBindings, docker.FlyteSandboxClusterName, sandboxImage, sandboxEnv, sandboxConfig.DryRun) @@ -393,6 +397,7 @@ func StartDemoCluster(ctx context.Context, args []string, sandboxConfig *sandbox return err } // K3s will automatically write the file specified by this var, which is mounted from user's local state dir. + sandboxConfig.Env = append(sandboxConfig.Env, k3sKubeConfigEnvVar) err = StartCluster(ctx, args, sandboxConfig, demoImageName, sandboxImagePrefix, exposedPorts, portBindings, util.DemoConsolePort) if err != nil { diff --git a/pkg/sandbox/start_test.go b/pkg/sandbox/start_test.go index a09797d3..a99f5b91 100644 --- a/pkg/sandbox/start_test.go +++ b/pkg/sandbox/start_test.go @@ -106,6 +106,8 @@ func TestStartFunc(t *testing.T) { RegistryAuth: "", Platform: "", } + config.Dev = true + config.DisableAgent = true assert.Nil(t, util.SetupFlyteDir()) assert.Nil(t, os.MkdirAll(f.FilePathJoin(f.UserHomeDir(), ".flyte", "state"), os.ModePerm)) assert.Nil(t, ioutil.WriteFile(docker.Kubeconfig, []byte(content), os.ModePerm))