From 2ec83b5f375b36883d5fe72875685e5db698310e Mon Sep 17 00:00:00 2001 From: Eric Stroczynski Date: Mon, 20 Jan 2020 13:36:20 -0800 Subject: [PATCH 01/11] cmd/operator-sdk: 'run local' is now 'run --local', and 'alpha run --olm' is now 'run --olm'. doc/cli: regenerate cli --- cmd/operator-sdk/alpha/cmd.go | 2 - cmd/operator-sdk/alpha/run/cmd.go | 49 -------- cmd/operator-sdk/cli/cli.go | 4 +- .../{run => exec-entrypoint}/ansible.go | 0 .../{up => exec-entrypoint}/cmd.go | 24 ++-- .../{run => exec-entrypoint}/helm.go | 0 cmd/operator-sdk/run/cmd.go | 94 ++++++++++++-- cmd/operator-sdk/{up => run}/local.go | 115 +++++++----------- doc/cli/operator-sdk.md | 4 +- doc/cli/operator-sdk_alpha.md | 1 - doc/cli/operator-sdk_alpha_cleanup.md | 12 +- doc/cli/operator-sdk_alpha_run.md | 30 ----- doc/cli/operator-sdk_exec-entrypoint.md | 22 ++++ ...> operator-sdk_exec-entrypoint_ansible.md} | 6 +- ...d => operator-sdk_exec-entrypoint_helm.md} | 6 +- doc/cli/operator-sdk_run.md | 26 ++-- doc/cli/operator-sdk_up.md | 20 --- doc/cli/operator-sdk_up_local.md | 30 ----- internal/olm/operator/operator.go | 19 +-- 19 files changed, 211 insertions(+), 253 deletions(-) delete mode 100644 cmd/operator-sdk/alpha/run/cmd.go rename cmd/operator-sdk/{run => exec-entrypoint}/ansible.go (100%) rename cmd/operator-sdk/{up => exec-entrypoint}/cmd.go (55%) rename cmd/operator-sdk/{run => exec-entrypoint}/helm.go (100%) rename cmd/operator-sdk/{up => run}/local.go (59%) delete mode 100644 doc/cli/operator-sdk_alpha_run.md create mode 100644 doc/cli/operator-sdk_exec-entrypoint.md rename doc/cli/{operator-sdk_run_ansible.md => operator-sdk_exec-entrypoint_ansible.md} (89%) rename doc/cli/{operator-sdk_run_helm.md => operator-sdk_exec-entrypoint_helm.md} (86%) delete mode 100644 doc/cli/operator-sdk_up.md delete mode 100644 doc/cli/operator-sdk_up_local.md diff --git a/cmd/operator-sdk/alpha/cmd.go b/cmd/operator-sdk/alpha/cmd.go index 2b62a87009b..cac9b2513a0 100644 --- a/cmd/operator-sdk/alpha/cmd.go +++ b/cmd/operator-sdk/alpha/cmd.go @@ -19,7 +19,6 @@ import ( "github.com/operator-framework/operator-sdk/cmd/operator-sdk/alpha/cleanup" "github.com/operator-framework/operator-sdk/cmd/operator-sdk/alpha/kubebuilder" "github.com/operator-framework/operator-sdk/cmd/operator-sdk/alpha/olm" - run "github.com/operator-framework/operator-sdk/cmd/operator-sdk/alpha/run" "github.com/spf13/cobra" ) @@ -33,7 +32,6 @@ func NewCmd() *cobra.Command { cmd.AddCommand( olm.NewCmd(), kubebuilder.NewCmd(), - run.NewCmd(), cleanup.NewCmd(), bundle.NewCmd(), ) diff --git a/cmd/operator-sdk/alpha/run/cmd.go b/cmd/operator-sdk/alpha/run/cmd.go deleted file mode 100644 index 46e2028f8b2..00000000000 --- a/cmd/operator-sdk/alpha/run/cmd.go +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2020 The Operator-SDK Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package run - -import ( - olmoperator "github.com/operator-framework/operator-sdk/internal/olm/operator" - - log "github.com/sirupsen/logrus" - "github.com/spf13/cobra" -) - -type runArgs struct { - olm bool -} - -func NewCmd() *cobra.Command { - cargs := &runArgs{} - c := &olmoperator.OLMCmd{} - cmd := &cobra.Command{ - Use: "run", - Short: "Run an Operator in a variety of environments", - RunE: func(cmd *cobra.Command, args []string) error { - switch { - case cargs.olm: - if err := c.Run(); err != nil { - log.Fatalf("Failed to run operator: %v", err) - } - } - return nil - }, - } - // OLM is the default. - cmd.Flags().BoolVar(&cargs.olm, "olm", true, "The operator to be run will be managed by OLM in a cluster.") - // TODO(estroz): refactor flag setting when new run mode options are added. - c.AddToFlagSet(cmd.Flags()) - return cmd -} diff --git a/cmd/operator-sdk/cli/cli.go b/cmd/operator-sdk/cli/cli.go index 523d03b7261..80779ee6ced 100644 --- a/cmd/operator-sdk/cli/cli.go +++ b/cmd/operator-sdk/cli/cli.go @@ -24,6 +24,7 @@ import ( "github.com/operator-framework/operator-sdk/cmd/operator-sdk/alpha" "github.com/operator-framework/operator-sdk/cmd/operator-sdk/build" "github.com/operator-framework/operator-sdk/cmd/operator-sdk/completion" + execentrypoint "github.com/operator-framework/operator-sdk/cmd/operator-sdk/exec-entrypoint" "github.com/operator-framework/operator-sdk/cmd/operator-sdk/generate" "github.com/operator-framework/operator-sdk/cmd/operator-sdk/migrate" "github.com/operator-framework/operator-sdk/cmd/operator-sdk/new" @@ -32,7 +33,6 @@ import ( "github.com/operator-framework/operator-sdk/cmd/operator-sdk/run" "github.com/operator-framework/operator-sdk/cmd/operator-sdk/scorecard" "github.com/operator-framework/operator-sdk/cmd/operator-sdk/test" - "github.com/operator-framework/operator-sdk/cmd/operator-sdk/up" "github.com/operator-framework/operator-sdk/cmd/operator-sdk/version" "github.com/operator-framework/operator-sdk/internal/flags" "github.com/operator-framework/operator-sdk/internal/util/projutil" @@ -65,6 +65,7 @@ func GetCLIRoot() *cobra.Command { root.AddCommand(alpha.NewCmd()) root.AddCommand(build.NewCmd()) root.AddCommand(completion.NewCmd()) + root.AddCommand(execentrypoint.NewCmd()) root.AddCommand(generate.NewCmd()) root.AddCommand(migrate.NewCmd()) root.AddCommand(new.NewCmd()) @@ -73,7 +74,6 @@ func GetCLIRoot() *cobra.Command { root.AddCommand(run.NewCmd()) root.AddCommand(scorecard.NewCmd()) root.AddCommand(test.NewCmd()) - root.AddCommand(up.NewCmd()) root.AddCommand(version.NewCmd()) return root diff --git a/cmd/operator-sdk/run/ansible.go b/cmd/operator-sdk/exec-entrypoint/ansible.go similarity index 100% rename from cmd/operator-sdk/run/ansible.go rename to cmd/operator-sdk/exec-entrypoint/ansible.go diff --git a/cmd/operator-sdk/up/cmd.go b/cmd/operator-sdk/exec-entrypoint/cmd.go similarity index 55% rename from cmd/operator-sdk/up/cmd.go rename to cmd/operator-sdk/exec-entrypoint/cmd.go index 98f636faf0b..51b119f306d 100644 --- a/cmd/operator-sdk/up/cmd.go +++ b/cmd/operator-sdk/exec-entrypoint/cmd.go @@ -1,4 +1,4 @@ -// Copyright 2018 The Operator-SDK Authors +// Copyright 2019 The Operator-SDK Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,20 +12,26 @@ // See the License for the specific language governing permissions and // limitations under the License. -package up +package run import ( "github.com/spf13/cobra" ) +// NewCmd returns a command that contains subcommands to run specific +// operator types. func NewCmd() *cobra.Command { - upCmd := &cobra.Command{ - Use: "up", - Short: "Launches the operator", - Long: `The up command has subcommands that can launch the operator in various ways. -`, + runCmd := &cobra.Command{ + Use: "exec-entrypoint", + Short: "Runs a generic operator", + Long: `Runs a generic operator. This is intended to be used when running +in a Pod inside a cluster. Developers wanting to run their operator locally +should use "run --local" instead.`, } - upCmd.AddCommand(newLocalCmd()) - return upCmd + runCmd.AddCommand( + newRunAnsibleCmd(), + newRunHelmCmd(), + ) + return runCmd } diff --git a/cmd/operator-sdk/run/helm.go b/cmd/operator-sdk/exec-entrypoint/helm.go similarity index 100% rename from cmd/operator-sdk/run/helm.go rename to cmd/operator-sdk/exec-entrypoint/helm.go diff --git a/cmd/operator-sdk/run/cmd.go b/cmd/operator-sdk/run/cmd.go index 1513148ecaf..33badb0e979 100644 --- a/cmd/operator-sdk/run/cmd.go +++ b/cmd/operator-sdk/run/cmd.go @@ -15,21 +15,95 @@ package run import ( + "fmt" + "path/filepath" + + olmoperator "github.com/operator-framework/operator-sdk/internal/olm/operator" + olmcatalog "github.com/operator-framework/operator-sdk/internal/scaffold/olm-catalog" + k8sinternal "github.com/operator-framework/operator-sdk/internal/util/k8sutil" + "github.com/operator-framework/operator-sdk/internal/util/projutil" + aoflags "github.com/operator-framework/operator-sdk/pkg/ansible/flags" + hoflags "github.com/operator-framework/operator-sdk/pkg/helm/flags" + + log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) -// NewCmd returns a command that contains subcommands to run specific -// operator types. +type runCmd struct { + // Common options. + kubeconfig string + namespace string + + // Run type. + olm, local bool + + // Run type-specific options. + olmArgs olmoperator.OLMCmd + localArgs runLocalArgs +} + func NewCmd() *cobra.Command { - runCmd := &cobra.Command{ + c := &runCmd{} + cmd := &cobra.Command{ Use: "run", - Short: "Runs a generic operator", - Long: `Runs a generic operator. This is intended to be used when running -in a Pod inside a cluster. Developers wanting to run their operator locally -should use "up local" instead.`, + Short: "Run an Operator in a variety of environments", + RunE: func(cmd *cobra.Command, args []string) error { + projutil.MustInProjectRoot() + + switch { + case c.olm: + c.olmArgs.KubeconfigPath = c.kubeconfig + c.olmArgs.OperatorNamespace = c.namespace + if c.olmArgs.ManifestsDir == "" { + operatorName := filepath.Base(projutil.MustGetwd()) + c.olmArgs.ManifestsDir = filepath.Join(olmcatalog.OLMCatalogDir, operatorName) + } + if err := c.olmArgs.Run(); err != nil { + log.Fatalf("Failed to run operator using OLM: %v", err) + } + case c.local: + // Get default namespace to watch if unset. + if !cmd.Flags().Changed("namespace") { + _, defaultNamespace, err := k8sinternal.GetKubeconfigAndNamespace(c.kubeconfig) + if err != nil { + return fmt.Errorf("error getting kubeconfig and default namespace: %v", err) + } + c.namespace = defaultNamespace + } + c.localArgs.kubeconfig = c.kubeconfig + c.localArgs.namespace = c.namespace + if err := c.localArgs.run(); err != nil { + log.Fatalf("Failed to run operator locally: %v", err) + } + } + return nil + }, } + // Avoid sorting flags so we can group them according to run type. + cmd.Flags().SortFlags = false + + // Shared flags. + cmd.Flags().StringVar(&c.kubeconfig, "kubeconfig", "", + "The file path to kubernetes configuration file. Defaults to location "+ + "specified by $KUBECONFIG, or to default file rules if not set") + cmd.Flags().StringVar(&c.namespace, "namespace", "", + "The namespace where the operator watches for changes.") - runCmd.AddCommand(newRunAnsibleCmd()) - runCmd.AddCommand(newRunHelmCmd()) - return runCmd + // 'run --olm' and related flags. + cmd.Flags().BoolVar(&c.olm, "olm", true, + "The operator to be run will be managed by OLM in a cluster.") + c.olmArgs.AddToFlagSet(cmd.Flags()) + + // 'run --local' and related flags. + cmd.Flags().BoolVar(&c.local, "local", false, + "The operator will be run locally by building the operator binary with "+ + "the ability to access a kubernetes cluster using a kubeconfig file.") + c.localArgs.addToFlags(cmd.Flags()) + switch projutil.GetOperatorType() { + case projutil.OperatorTypeAnsible: + c.localArgs.ansibleOperatorFlags = aoflags.AddTo(cmd.Flags(), "(ansible operator)") + case projutil.OperatorTypeHelm: + c.localArgs.helmOperatorFlags = hoflags.AddTo(cmd.Flags(), "(helm operator)") + } + return cmd } diff --git a/cmd/operator-sdk/up/local.go b/cmd/operator-sdk/run/local.go similarity index 59% rename from cmd/operator-sdk/up/local.go rename to cmd/operator-sdk/run/local.go index 61ad9a61ee8..593159c9864 100644 --- a/cmd/operator-sdk/up/local.go +++ b/cmd/operator-sdk/run/local.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package up +package run import ( "fmt" @@ -25,7 +25,6 @@ import ( "syscall" "github.com/operator-framework/operator-sdk/internal/scaffold" - k8sInternal "github.com/operator-framework/operator-sdk/internal/util/k8sutil" "github.com/operator-framework/operator-sdk/internal/util/projutil" "github.com/operator-framework/operator-sdk/pkg/ansible" aoflags "github.com/operator-framework/operator-sdk/pkg/ansible/flags" @@ -33,89 +32,63 @@ import ( hoflags "github.com/operator-framework/operator-sdk/pkg/helm/flags" "github.com/operator-framework/operator-sdk/pkg/k8sutil" "github.com/operator-framework/operator-sdk/pkg/log/zap" + log "github.com/sirupsen/logrus" - "github.com/spf13/cobra" + "github.com/spf13/pflag" logf "sigs.k8s.io/controller-runtime/pkg/log" ) -// newLocalCmd - up local command to run an operator loccally -func newLocalCmd() *cobra.Command { - upLocalCmd := &cobra.Command{ - Use: "local", - Short: "Launches the operator locally", - Long: `The operator-sdk up local command launches the operator on the local machine -by building the operator binary with the ability to access a -kubernetes cluster using a kubeconfig file. -`, - RunE: upLocalFunc, - } - - upLocalCmd.Flags().StringVar(&kubeConfig, "kubeconfig", "", "The file path to kubernetes configuration file; defaults to location specified by $KUBECONFIG with a fallback to $HOME/.kube/config if not set") - upLocalCmd.Flags().StringVar(&operatorFlags, "operator-flags", "", "The flags that the operator needs. Example: \"--flag1 value1 --flag2=value2\"") - upLocalCmd.Flags().StringVar(&namespace, "namespace", "", "The namespace where the operator watches for changes.") - upLocalCmd.Flags().StringVar(&ldFlags, "go-ldflags", "", "Set Go linker options") - upLocalCmd.Flags().BoolVar(&enableDelve, "enable-delve", false, "Start the operator using the delve debugger") - switch projutil.GetOperatorType() { - case projutil.OperatorTypeAnsible: - ansibleOperatorFlags = aoflags.AddTo(upLocalCmd.Flags(), "(ansible operator)") - case projutil.OperatorTypeHelm: - helmOperatorFlags = hoflags.AddTo(upLocalCmd.Flags(), "(helm operator)") - } - return upLocalCmd -} - -var ( - kubeConfig string - operatorFlags string +type runLocalArgs struct { + kubeconfig string namespace string + operatorFlags string ldFlags string enableDelve bool ansibleOperatorFlags *aoflags.AnsibleOperatorFlags helmOperatorFlags *hoflags.HelmOperatorFlags -) +} -func upLocalFunc(cmd *cobra.Command, args []string) error { - log.Info("Running the operator locally.") +func (c runLocalArgs) addToFlags(fs *pflag.FlagSet) { + prefix := "[local only] " + fs.StringVar(&c.operatorFlags, "operator-flags", "", + prefix+"The flags that the operator needs. Example: \"--flag1 value1 --flag2=value2\"") + fs.StringVar(&c.ldFlags, "go-ldflags", "", prefix+"Set Go linker options") + fs.BoolVar(&c.enableDelve, "enable-delve", false, + prefix+"Start the operator using the delve debugger") +} - // get default namespace to watch if unset - if !cmd.Flags().Changed("namespace") { - _, defaultNamespace, err := k8sInternal.GetKubeconfigAndNamespace(kubeConfig) - if err != nil { - return fmt.Errorf("failed to get kubeconfig and default namespace: %v", err) - } - namespace = defaultNamespace - } - log.Infof("Using namespace %s.", namespace) +func (c runLocalArgs) run() error { + log.Infof("Running the operator locally in namespace %s.", c.namespace) switch t := projutil.GetOperatorType(); t { case projutil.OperatorTypeGo: - return upLocal() + return c.runGo() case projutil.OperatorTypeAnsible: - return upLocalAnsible() + return c.runAnsible() case projutil.OperatorTypeHelm: - return upLocalHelm() + return c.runHelm() } return projutil.ErrUnknownOperatorType{} } -func upLocal() error { +func (c runLocalArgs) runGo() error { projutil.MustInProjectRoot() absProjectPath := projutil.MustGetwd() projectName := filepath.Base(absProjectPath) outputBinName := filepath.Join(scaffold.BuildBinDir, projectName+"-local") - if err := buildLocal(outputBinName); err != nil { + if err := c.buildLocal(outputBinName); err != nil { return fmt.Errorf("failed to build operator to run locally: %v", err) } args := []string{} - if operatorFlags != "" { - extraArgs := strings.Split(operatorFlags, " ") + if c.operatorFlags != "" { + extraArgs := strings.Split(c.operatorFlags, " ") args = append(args, extraArgs...) } var dc *exec.Cmd - if enableDelve { + if c.enableDelve { delveArgs := []string{"--listen=:2345", "--headless=true", "--api-version=2", "exec", outputBinName, "--"} delveArgs = append(delveArgs, args...) @@ -125,10 +98,10 @@ func upLocal() error { dc = exec.Command(outputBinName, args...) } - c := make(chan os.Signal) - signal.Notify(c, os.Interrupt, syscall.SIGTERM) + ch := make(chan os.Signal) + signal.Notify(ch, os.Interrupt, syscall.SIGTERM) go func() { - <-c + <-ch err := dc.Process.Kill() if err != nil { log.Fatalf("Failed to terminate the operator: (%v)", err) @@ -138,10 +111,10 @@ func upLocal() error { dc.Env = os.Environ() dc.Env = append(dc.Env, fmt.Sprintf("%s=%s", k8sutil.ForceRunModeEnv, k8sutil.LocalRunMode)) // only set env var if user explicitly specified a kubeconfig path - if kubeConfig != "" { - dc.Env = append(dc.Env, fmt.Sprintf("%v=%v", k8sutil.KubeConfigEnvVar, kubeConfig)) + if c.kubeconfig != "" { + dc.Env = append(dc.Env, fmt.Sprintf("%v=%v", k8sutil.KubeConfigEnvVar, c.kubeconfig)) } - dc.Env = append(dc.Env, fmt.Sprintf("%v=%v", k8sutil.WatchNamespaceEnvVar, namespace)) + dc.Env = append(dc.Env, fmt.Sprintf("%v=%v", k8sutil.WatchNamespaceEnvVar, c.namespace)) if err := projutil.ExecCmd(dc); err != nil { return fmt.Errorf("failed to run operator locally: %v", err) @@ -150,27 +123,27 @@ func upLocal() error { return nil } -func upLocalAnsible() error { +func (c runLocalArgs) runAnsible() error { logf.SetLogger(zap.Logger()) - if err := setupOperatorEnv(); err != nil { + if err := setupOperatorEnv(c.kubeconfig, c.namespace); err != nil { return err } - return ansible.Run(ansibleOperatorFlags) + return ansible.Run(c.ansibleOperatorFlags) } -func upLocalHelm() error { +func (c runLocalArgs) runHelm() error { logf.SetLogger(zap.Logger()) - if err := setupOperatorEnv(); err != nil { + if err := setupOperatorEnv(c.kubeconfig, c.namespace); err != nil { return err } - return helm.Run(helmOperatorFlags) + return helm.Run(c.helmOperatorFlags) } -func setupOperatorEnv() error { +func setupOperatorEnv(kubeconfig, namespace string) error { // Set the kubeconfig that the manager will be able to grab // only set env var if user explicitly specified a kubeconfig path - if kubeConfig != "" { - if err := os.Setenv(k8sutil.KubeConfigEnvVar, kubeConfig); err != nil { + if kubeconfig != "" { + if err := os.Setenv(k8sutil.KubeConfigEnvVar, kubeconfig); err != nil { return fmt.Errorf("failed to set %s environment variable: %v", k8sutil.KubeConfigEnvVar, err) } } @@ -191,12 +164,12 @@ func setupOperatorEnv() error { return nil } -func buildLocal(outputBinName string) error { +func (c runLocalArgs) buildLocal(outputBinName string) error { var args []string - if ldFlags != "" { - args = []string{"-ldflags", ldFlags} + if c.ldFlags != "" { + args = []string{"-ldflags", c.ldFlags} } - if enableDelve { + if c.enableDelve { args = append(args, "-gcflags=\"all=-N -l\"") } opts := projutil.GoCmdOptions{ diff --git a/doc/cli/operator-sdk.md b/doc/cli/operator-sdk.md index ae8dbb6a43b..5908250a25b 100644 --- a/doc/cli/operator-sdk.md +++ b/doc/cli/operator-sdk.md @@ -18,14 +18,14 @@ An SDK for building operators with ease * [operator-sdk alpha](operator-sdk_alpha.md) - Run an alpha subcommand * [operator-sdk build](operator-sdk_build.md) - Compiles code and builds artifacts * [operator-sdk completion](operator-sdk_completion.md) - Generators for shell completions +* [operator-sdk exec-entrypoint](operator-sdk_exec-entrypoint.md) - Runs a generic operator * [operator-sdk generate](operator-sdk_generate.md) - Invokes specific generator * [operator-sdk migrate](operator-sdk_migrate.md) - Adds source code to an operator * [operator-sdk new](operator-sdk_new.md) - Creates a new operator application * [operator-sdk olm-catalog](operator-sdk_olm-catalog.md) - Invokes a olm-catalog command * [operator-sdk print-deps](operator-sdk_print-deps.md) - Print Golang packages and versions required to run the operator -* [operator-sdk run](operator-sdk_run.md) - Runs a generic operator +* [operator-sdk run](operator-sdk_run.md) - Run an Operator in a variety of environments * [operator-sdk scorecard](operator-sdk_scorecard.md) - Run scorecard tests * [operator-sdk test](operator-sdk_test.md) - Tests the operator -* [operator-sdk up](operator-sdk_up.md) - Launches the operator * [operator-sdk version](operator-sdk_version.md) - Prints the version of operator-sdk diff --git a/doc/cli/operator-sdk_alpha.md b/doc/cli/operator-sdk_alpha.md index 868f8d7e0c8..dd0f41f1559 100644 --- a/doc/cli/operator-sdk_alpha.md +++ b/doc/cli/operator-sdk_alpha.md @@ -18,5 +18,4 @@ Run an alpha subcommand * [operator-sdk alpha bundle](operator-sdk_alpha_bundle.md) - Work with operator bundle metadata and bundle images * [operator-sdk alpha cleanup](operator-sdk_alpha_cleanup.md) - Delete and clean up after a running Operator * [operator-sdk alpha olm](operator-sdk_alpha_olm.md) - Manage the Operator Lifecycle Manager installation in your cluster -* [operator-sdk alpha run](operator-sdk_alpha_run.md) - Run an Operator in a variety of environments diff --git a/doc/cli/operator-sdk_alpha_cleanup.md b/doc/cli/operator-sdk_alpha_cleanup.md index d36313b0f78..65564a412fd 100644 --- a/doc/cli/operator-sdk_alpha_cleanup.md +++ b/doc/cli/operator-sdk_alpha_cleanup.md @@ -15,14 +15,12 @@ operator-sdk alpha cleanup [flags] ``` --force-registry Force deletion of the in-cluster registry. -h, --help help for cleanup - --include strings Path to Kubernetes resource manifests, ex. Role, Subscription. These supplement or override defaults generated by run/cleanup - --install-mode string InstallMode to create OperatorGroup with. Format: InstallModeType=[ns1,ns2[, ...]] - --kubeconfig string Path to kubeconfig - --manifests string Directory containing package manifest and operator bundles. - --namespace string Namespace in which to create resources + --include strings [olm only] Path to Kubernetes resource manifests, ex. Role, Subscription. These supplement or override defaults generated by run/cleanup + --install-mode string [olm only] InstallMode to create OperatorGroup with. Format: InstallModeType=[ns1,ns2[, ...]] + --manifests string [olm only] Directory containing package manifest and operator bundles. --olm The operator to be deleted is managed by OLM in a cluster. (default true) - --operator-version string Version of operator to deploy - --timeout duration Time to wait for the command to complete before failing (default 2m0s) + --operator-version string [olm only] Version of operator to deploy + --timeout duration [olm only] Time to wait for the command to complete before failing (default 2m0s) ``` ### SEE ALSO diff --git a/doc/cli/operator-sdk_alpha_run.md b/doc/cli/operator-sdk_alpha_run.md deleted file mode 100644 index 5a0f58ae393..00000000000 --- a/doc/cli/operator-sdk_alpha_run.md +++ /dev/null @@ -1,30 +0,0 @@ -## operator-sdk alpha run - -Run an Operator in a variety of environments - -### Synopsis - -Run an Operator in a variety of environments - -``` -operator-sdk alpha run [flags] -``` - -### Options - -``` - -h, --help help for run - --include strings Path to Kubernetes resource manifests, ex. Role, Subscription. These supplement or override defaults generated by run/cleanup - --install-mode string InstallMode to create OperatorGroup with. Format: InstallModeType=[ns1,ns2[, ...]] - --kubeconfig string Path to kubeconfig - --manifests string Directory containing package manifest and operator bundles. - --namespace string Namespace in which to create resources - --olm The operator to be run will be managed by OLM in a cluster. (default true) - --operator-version string Version of operator to deploy - --timeout duration Time to wait for the command to complete before failing (default 2m0s) -``` - -### SEE ALSO - -* [operator-sdk alpha](operator-sdk_alpha.md) - Run an alpha subcommand - diff --git a/doc/cli/operator-sdk_exec-entrypoint.md b/doc/cli/operator-sdk_exec-entrypoint.md new file mode 100644 index 00000000000..9042b049d88 --- /dev/null +++ b/doc/cli/operator-sdk_exec-entrypoint.md @@ -0,0 +1,22 @@ +## operator-sdk exec-entrypoint + +Runs a generic operator + +### Synopsis + +Runs a generic operator. This is intended to be used when running +in a Pod inside a cluster. Developers wanting to run their operator locally +should use "run --local" instead. + +### Options + +``` + -h, --help help for exec-entrypoint +``` + +### SEE ALSO + +* [operator-sdk](operator-sdk.md) - An SDK for building operators with ease +* [operator-sdk exec-entrypoint ansible](operator-sdk_exec-entrypoint_ansible.md) - Runs as an ansible operator +* [operator-sdk exec-entrypoint helm](operator-sdk_exec-entrypoint_helm.md) - Runs as a helm operator + diff --git a/doc/cli/operator-sdk_run_ansible.md b/doc/cli/operator-sdk_exec-entrypoint_ansible.md similarity index 89% rename from doc/cli/operator-sdk_run_ansible.md rename to doc/cli/operator-sdk_exec-entrypoint_ansible.md index 37430932fbb..8d0e7bd1130 100644 --- a/doc/cli/operator-sdk_run_ansible.md +++ b/doc/cli/operator-sdk_exec-entrypoint_ansible.md @@ -1,4 +1,4 @@ -## operator-sdk run ansible +## operator-sdk exec-entrypoint ansible Runs as an ansible operator @@ -9,7 +9,7 @@ in a Pod inside a cluster. Developers wanting to run their operator locally should use "up local" instead. ``` -operator-sdk run ansible [flags] +operator-sdk exec-entrypoint ansible [flags] ``` ### Options @@ -30,5 +30,5 @@ operator-sdk run ansible [flags] ### SEE ALSO -* [operator-sdk run](operator-sdk_run.md) - Runs a generic operator +* [operator-sdk exec-entrypoint](operator-sdk_exec-entrypoint.md) - Runs a generic operator diff --git a/doc/cli/operator-sdk_run_helm.md b/doc/cli/operator-sdk_exec-entrypoint_helm.md similarity index 86% rename from doc/cli/operator-sdk_run_helm.md rename to doc/cli/operator-sdk_exec-entrypoint_helm.md index 99ab7b85d67..905225576cf 100644 --- a/doc/cli/operator-sdk_run_helm.md +++ b/doc/cli/operator-sdk_exec-entrypoint_helm.md @@ -1,4 +1,4 @@ -## operator-sdk run helm +## operator-sdk exec-entrypoint helm Runs as a helm operator @@ -9,7 +9,7 @@ in a Pod inside a cluster. Developers wanting to run their operator locally should use "up local" instead. ``` -operator-sdk run helm [flags] +operator-sdk exec-entrypoint helm [flags] ``` ### Options @@ -27,5 +27,5 @@ operator-sdk run helm [flags] ### SEE ALSO -* [operator-sdk run](operator-sdk_run.md) - Runs a generic operator +* [operator-sdk exec-entrypoint](operator-sdk_exec-entrypoint.md) - Runs a generic operator diff --git a/doc/cli/operator-sdk_run.md b/doc/cli/operator-sdk_run.md index 7e05befc9f6..f922cac528d 100644 --- a/doc/cli/operator-sdk_run.md +++ b/doc/cli/operator-sdk_run.md @@ -1,22 +1,34 @@ ## operator-sdk run -Runs a generic operator +Run an Operator in a variety of environments ### Synopsis -Runs a generic operator. This is intended to be used when running -in a Pod inside a cluster. Developers wanting to run their operator locally -should use "up local" instead. +Run an Operator in a variety of environments + +``` +operator-sdk run [flags] +``` ### Options ``` - -h, --help help for run + --kubeconfig string The file path to kubernetes configuration file. Defaults to location specified by $KUBECONFIG, or to default file rules if not set + --namespace string The namespace where the operator watches for changes. + --olm The operator to be run will be managed by OLM in a cluster. (default true) + --manifests string [olm only] Directory containing package manifest and operator bundles. + --operator-version string [olm only] Version of operator to deploy + --install-mode string [olm only] InstallMode to create OperatorGroup with. Format: InstallModeType=[ns1,ns2[, ...]] + --include strings [olm only] Path to Kubernetes resource manifests, ex. Role, Subscription. These supplement or override defaults generated by run/cleanup + --timeout duration [olm only] Time to wait for the command to complete before failing (default 2m0s) + --local The operator will be run locally by building the operator binary with the ability to access a kubernetes cluster using a kubeconfig file. + --operator-flags string [local only] The flags that the operator needs. Example: "--flag1 value1 --flag2=value2" + --go-ldflags string [local only] Set Go linker options + --enable-delve [local only] Start the operator using the delve debugger + -h, --help help for run ``` ### SEE ALSO * [operator-sdk](operator-sdk.md) - An SDK for building operators with ease -* [operator-sdk run ansible](operator-sdk_run_ansible.md) - Runs as an ansible operator -* [operator-sdk run helm](operator-sdk_run_helm.md) - Runs as a helm operator diff --git a/doc/cli/operator-sdk_up.md b/doc/cli/operator-sdk_up.md deleted file mode 100644 index bfc0342871c..00000000000 --- a/doc/cli/operator-sdk_up.md +++ /dev/null @@ -1,20 +0,0 @@ -## operator-sdk up - -Launches the operator - -### Synopsis - -The up command has subcommands that can launch the operator in various ways. - - -### Options - -``` - -h, --help help for up -``` - -### SEE ALSO - -* [operator-sdk](operator-sdk.md) - An SDK for building operators with ease -* [operator-sdk up local](operator-sdk_up_local.md) - Launches the operator locally - diff --git a/doc/cli/operator-sdk_up_local.md b/doc/cli/operator-sdk_up_local.md deleted file mode 100644 index 927f170d28b..00000000000 --- a/doc/cli/operator-sdk_up_local.md +++ /dev/null @@ -1,30 +0,0 @@ -## operator-sdk up local - -Launches the operator locally - -### Synopsis - -The operator-sdk up local command launches the operator on the local machine -by building the operator binary with the ability to access a -kubernetes cluster using a kubeconfig file. - - -``` -operator-sdk up local [flags] -``` - -### Options - -``` - --enable-delve Start the operator using the delve debugger - --go-ldflags string Set Go linker options - -h, --help help for local - --kubeconfig string The file path to kubernetes configuration file; defaults to location specified by $KUBECONFIG with a fallback to $HOME/.kube/config if not set - --namespace string The namespace where the operator watches for changes. - --operator-flags string The flags that the operator needs. Example: "--flag1 value1 --flag2=value2" -``` - -### SEE ALSO - -* [operator-sdk up](operator-sdk_up.md) - Launches the operator - diff --git a/internal/olm/operator/operator.go b/internal/olm/operator/operator.go index 664184bb22e..fef30a917d7 100644 --- a/internal/olm/operator/operator.go +++ b/internal/olm/operator/operator.go @@ -85,13 +85,18 @@ type OLMCmd struct { // nolint:golint var installModeFormat = "InstallModeType=[ns1,ns2[, ...]]" func (c *OLMCmd) AddToFlagSet(fs *pflag.FlagSet) { - fs.StringVar(&c.ManifestsDir, "manifests", "", "Directory containing package manifest and operator bundles.") - fs.StringVar(&c.OperatorVersion, "operator-version", "", "Version of operator to deploy") - fs.StringVar(&c.InstallMode, "install-mode", "", "InstallMode to create OperatorGroup with. Format: "+installModeFormat) - fs.StringVar(&c.KubeconfigPath, "kubeconfig", "", "Path to kubeconfig") - fs.StringVar(&c.OperatorNamespace, "namespace", "", "Namespace in which to create resources") - fs.StringSliceVar(&c.IncludePaths, "include", nil, "Path to Kubernetes resource manifests, ex. Role, Subscription. These supplement or override defaults generated by run/cleanup") - fs.DurationVar(&c.Timeout, "timeout", defaultTimeout, "Time to wait for the command to complete before failing") + prefix := "[olm only] " + fs.StringVar(&c.ManifestsDir, "manifests", "", + prefix+"Directory containing package manifest and operator bundles.") + fs.StringVar(&c.OperatorVersion, "operator-version", "", + prefix+"Version of operator to deploy") + fs.StringVar(&c.InstallMode, "install-mode", "", + prefix+"InstallMode to create OperatorGroup with. Format: "+installModeFormat) + fs.StringSliceVar(&c.IncludePaths, "include", nil, + prefix+"Path to Kubernetes resource manifests, ex. Role, Subscription. "+ + "These supplement or override defaults generated by run/cleanup") + fs.DurationVar(&c.Timeout, "timeout", defaultTimeout, + prefix+"Time to wait for the command to complete before failing") } func (c *OLMCmd) validate() error { From d7e26d17ccee296319e5c0846fa3ad8bdcedb167 Mon Sep 17 00:00:00 2001 From: Eric Stroczynski Date: Mon, 20 Jan 2020 14:24:00 -0800 Subject: [PATCH 02/11] move cleanup command from alpha --- cmd/operator-sdk/alpha/cleanup/cmd.go | 50 ------------ cmd/operator-sdk/alpha/cmd.go | 2 - cmd/operator-sdk/cleanup/cmd.go | 79 +++++++++++++++++++ cmd/operator-sdk/cli/cli.go | 2 + doc/cli/operator-sdk.md | 1 + doc/cli/operator-sdk_alpha.md | 1 - ...pha_cleanup.md => operator-sdk_cleanup.md} | 17 ++-- 7 files changed, 91 insertions(+), 61 deletions(-) delete mode 100644 cmd/operator-sdk/alpha/cleanup/cmd.go create mode 100644 cmd/operator-sdk/cleanup/cmd.go rename doc/cli/{operator-sdk_alpha_cleanup.md => operator-sdk_cleanup.md} (61%) diff --git a/cmd/operator-sdk/alpha/cleanup/cmd.go b/cmd/operator-sdk/alpha/cleanup/cmd.go deleted file mode 100644 index 454be7f8eae..00000000000 --- a/cmd/operator-sdk/alpha/cleanup/cmd.go +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2020 The Operator-SDK Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package cleanup - -import ( - olmoperator "github.com/operator-framework/operator-sdk/internal/olm/operator" - - log "github.com/sirupsen/logrus" - "github.com/spf13/cobra" -) - -type cleanupArgs struct { - olm bool -} - -func NewCmd() *cobra.Command { - cargs := &cleanupArgs{} - c := &olmoperator.OLMCmd{} - cmd := &cobra.Command{ - Use: "cleanup", - Short: "Delete and clean up after a running Operator", - RunE: func(cmd *cobra.Command, args []string) error { - switch { - case cargs.olm: - if err := c.Cleanup(); err != nil { - log.Fatalf("Failed to clean up operator: %v", err) - } - } - return nil - }, - } - // OLM is the default. - cmd.Flags().BoolVar(&cargs.olm, "olm", true, "The operator to be deleted is managed by OLM in a cluster.") - // TODO(estroz): refactor flag setting when new run mode options are added. - c.AddToFlagSet(cmd.Flags()) - cmd.Flags().BoolVar(&c.ForceRegistry, "force-registry", false, "Force deletion of the in-cluster registry.") - return cmd -} diff --git a/cmd/operator-sdk/alpha/cmd.go b/cmd/operator-sdk/alpha/cmd.go index cac9b2513a0..c6b4555ca6c 100644 --- a/cmd/operator-sdk/alpha/cmd.go +++ b/cmd/operator-sdk/alpha/cmd.go @@ -16,7 +16,6 @@ package alpha import ( "github.com/operator-framework/operator-sdk/cmd/operator-sdk/alpha/bundle" - "github.com/operator-framework/operator-sdk/cmd/operator-sdk/alpha/cleanup" "github.com/operator-framework/operator-sdk/cmd/operator-sdk/alpha/kubebuilder" "github.com/operator-framework/operator-sdk/cmd/operator-sdk/alpha/olm" @@ -32,7 +31,6 @@ func NewCmd() *cobra.Command { cmd.AddCommand( olm.NewCmd(), kubebuilder.NewCmd(), - cleanup.NewCmd(), bundle.NewCmd(), ) return cmd diff --git a/cmd/operator-sdk/cleanup/cmd.go b/cmd/operator-sdk/cleanup/cmd.go new file mode 100644 index 00000000000..f1f2fa1631f --- /dev/null +++ b/cmd/operator-sdk/cleanup/cmd.go @@ -0,0 +1,79 @@ +// Copyright 2020 The Operator-SDK Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package cleanup + +import ( + "path/filepath" + + olmcatalog "github.com/operator-framework/operator-sdk/internal/generate/olm-catalog" + olmoperator "github.com/operator-framework/operator-sdk/internal/olm/operator" + "github.com/operator-framework/operator-sdk/internal/util/projutil" + + log "github.com/sirupsen/logrus" + "github.com/spf13/cobra" +) + +type cleanupCmd struct { + // Common options. + kubeconfig string + namespace string + + // Run type. + olm bool + + // Run type-specific options. + olmArgs olmoperator.OLMCmd +} + +func NewCmd() *cobra.Command { + c := &cleanupCmd{} + cmd := &cobra.Command{ + Use: "cleanup", + Short: "Delete and clean up after a running Operator", + RunE: func(cmd *cobra.Command, args []string) error { + projutil.MustInProjectRoot() + + switch { + case c.olm: + c.olmArgs.KubeconfigPath = c.kubeconfig + c.olmArgs.OperatorNamespace = c.namespace + if c.olmArgs.ManifestsDir == "" { + operatorName := filepath.Base(projutil.MustGetwd()) + c.olmArgs.ManifestsDir = filepath.Join(olmcatalog.OLMCatalogDir, operatorName) + } + if err := c.olmArgs.Cleanup(); err != nil { + log.Fatalf("Failed to clean up operator using OLM: %v", err) + } + } + return nil + }, + } + + // Avoid sorting flags so we can group them according to run type. + cmd.Flags().SortFlags = false + + // Shared flags. + cmd.Flags().StringVar(&c.kubeconfig, "kubeconfig", "", + "The file path to kubernetes configuration file. Defaults to location "+ + "specified by $KUBECONFIG, or to default file rules if not set") + cmd.Flags().StringVar(&c.namespace, "namespace", "", + "The namespace where the operator watches for changes.") + + // 'run --olm' and related flags. + cmd.Flags().BoolVar(&c.olm, "olm", true, + "The operator to be run will be managed by OLM in a cluster.") + c.olmArgs.AddToFlagSet(cmd.Flags()) + return cmd +} diff --git a/cmd/operator-sdk/cli/cli.go b/cmd/operator-sdk/cli/cli.go index 80779ee6ced..3b24f0319a9 100644 --- a/cmd/operator-sdk/cli/cli.go +++ b/cmd/operator-sdk/cli/cli.go @@ -23,6 +23,7 @@ import ( "github.com/operator-framework/operator-sdk/cmd/operator-sdk/add" "github.com/operator-framework/operator-sdk/cmd/operator-sdk/alpha" "github.com/operator-framework/operator-sdk/cmd/operator-sdk/build" + "github.com/operator-framework/operator-sdk/cmd/operator-sdk/cleanup" "github.com/operator-framework/operator-sdk/cmd/operator-sdk/completion" execentrypoint "github.com/operator-framework/operator-sdk/cmd/operator-sdk/exec-entrypoint" "github.com/operator-framework/operator-sdk/cmd/operator-sdk/generate" @@ -64,6 +65,7 @@ func GetCLIRoot() *cobra.Command { root.AddCommand(add.NewCmd()) root.AddCommand(alpha.NewCmd()) root.AddCommand(build.NewCmd()) + root.AddCommand(cleanup.NewCmd()) root.AddCommand(completion.NewCmd()) root.AddCommand(execentrypoint.NewCmd()) root.AddCommand(generate.NewCmd()) diff --git a/doc/cli/operator-sdk.md b/doc/cli/operator-sdk.md index 5908250a25b..a33894caab6 100644 --- a/doc/cli/operator-sdk.md +++ b/doc/cli/operator-sdk.md @@ -17,6 +17,7 @@ An SDK for building operators with ease * [operator-sdk add](operator-sdk_add.md) - Adds a controller or resource to the project * [operator-sdk alpha](operator-sdk_alpha.md) - Run an alpha subcommand * [operator-sdk build](operator-sdk_build.md) - Compiles code and builds artifacts +* [operator-sdk cleanup](operator-sdk_cleanup.md) - Delete and clean up after a running Operator * [operator-sdk completion](operator-sdk_completion.md) - Generators for shell completions * [operator-sdk exec-entrypoint](operator-sdk_exec-entrypoint.md) - Runs a generic operator * [operator-sdk generate](operator-sdk_generate.md) - Invokes specific generator diff --git a/doc/cli/operator-sdk_alpha.md b/doc/cli/operator-sdk_alpha.md index dd0f41f1559..b5d2ef50534 100644 --- a/doc/cli/operator-sdk_alpha.md +++ b/doc/cli/operator-sdk_alpha.md @@ -16,6 +16,5 @@ Run an alpha subcommand * [operator-sdk](operator-sdk.md) - An SDK for building operators with ease * [operator-sdk alpha bundle](operator-sdk_alpha_bundle.md) - Work with operator bundle metadata and bundle images -* [operator-sdk alpha cleanup](operator-sdk_alpha_cleanup.md) - Delete and clean up after a running Operator * [operator-sdk alpha olm](operator-sdk_alpha_olm.md) - Manage the Operator Lifecycle Manager installation in your cluster diff --git a/doc/cli/operator-sdk_alpha_cleanup.md b/doc/cli/operator-sdk_cleanup.md similarity index 61% rename from doc/cli/operator-sdk_alpha_cleanup.md rename to doc/cli/operator-sdk_cleanup.md index 65564a412fd..19809b9a0cb 100644 --- a/doc/cli/operator-sdk_alpha_cleanup.md +++ b/doc/cli/operator-sdk_cleanup.md @@ -1,4 +1,4 @@ -## operator-sdk alpha cleanup +## operator-sdk cleanup Delete and clean up after a running Operator @@ -7,23 +7,24 @@ Delete and clean up after a running Operator Delete and clean up after a running Operator ``` -operator-sdk alpha cleanup [flags] +operator-sdk cleanup [flags] ``` ### Options ``` - --force-registry Force deletion of the in-cluster registry. - -h, --help help for cleanup - --include strings [olm only] Path to Kubernetes resource manifests, ex. Role, Subscription. These supplement or override defaults generated by run/cleanup - --install-mode string [olm only] InstallMode to create OperatorGroup with. Format: InstallModeType=[ns1,ns2[, ...]] + --kubeconfig string The file path to kubernetes configuration file. Defaults to location specified by $KUBECONFIG, or to default file rules if not set + --namespace string The namespace where the operator watches for changes. + --olm The operator to be run will be managed by OLM in a cluster. (default true) --manifests string [olm only] Directory containing package manifest and operator bundles. - --olm The operator to be deleted is managed by OLM in a cluster. (default true) --operator-version string [olm only] Version of operator to deploy + --install-mode string [olm only] InstallMode to create OperatorGroup with. Format: InstallModeType=[ns1,ns2[, ...]] + --include strings [olm only] Path to Kubernetes resource manifests, ex. Role, Subscription. These supplement or override defaults generated by run/cleanup --timeout duration [olm only] Time to wait for the command to complete before failing (default 2m0s) + -h, --help help for cleanup ``` ### SEE ALSO -* [operator-sdk alpha](operator-sdk_alpha.md) - Run an alpha subcommand +* [operator-sdk](operator-sdk.md) - An SDK for building operators with ease From fb6c9b7fa013630d58d1720d4e9e9cdcc87cf0f2 Mon Sep 17 00:00:00 2001 From: Eric Stroczynski Date: Mon, 20 Jan 2020 14:42:36 -0800 Subject: [PATCH 03/11] check run-type flags for run/cleanup, hide exec-entrypoint flag --- cmd/operator-sdk/cleanup/cmd.go | 7 +++- cmd/operator-sdk/exec-entrypoint/cmd.go | 7 ++-- cmd/operator-sdk/run/cmd.go | 10 ++++-- doc/cli/operator-sdk.md | 1 - doc/cli/operator-sdk_cleanup.md | 2 +- doc/cli/operator-sdk_exec-entrypoint.md | 22 ------------ .../operator-sdk_exec-entrypoint_ansible.md | 34 ------------------- doc/cli/operator-sdk_exec-entrypoint_helm.md | 31 ----------------- doc/cli/operator-sdk_run.md | 4 +-- 9 files changed, 21 insertions(+), 97 deletions(-) delete mode 100644 doc/cli/operator-sdk_exec-entrypoint.md delete mode 100644 doc/cli/operator-sdk_exec-entrypoint_ansible.md delete mode 100644 doc/cli/operator-sdk_exec-entrypoint_helm.md diff --git a/cmd/operator-sdk/cleanup/cmd.go b/cmd/operator-sdk/cleanup/cmd.go index f1f2fa1631f..935d51c9536 100644 --- a/cmd/operator-sdk/cleanup/cmd.go +++ b/cmd/operator-sdk/cleanup/cmd.go @@ -15,6 +15,7 @@ package cleanup import ( + "errors" "path/filepath" olmcatalog "github.com/operator-framework/operator-sdk/internal/generate/olm-catalog" @@ -43,6 +44,9 @@ func NewCmd() *cobra.Command { Use: "cleanup", Short: "Delete and clean up after a running Operator", RunE: func(cmd *cobra.Command, args []string) error { + if !c.olm { + return errors.New("exactly one run-type flag must be set: --olm") + } projutil.MustInProjectRoot() switch { @@ -73,7 +77,8 @@ func NewCmd() *cobra.Command { // 'run --olm' and related flags. cmd.Flags().BoolVar(&c.olm, "olm", true, - "The operator to be run will be managed by OLM in a cluster.") + "The operator to be run will be managed by OLM in a cluster. "+ + "Cannot be set with another run-type flag") c.olmArgs.AddToFlagSet(cmd.Flags()) return cmd } diff --git a/cmd/operator-sdk/exec-entrypoint/cmd.go b/cmd/operator-sdk/exec-entrypoint/cmd.go index 51b119f306d..350a1ee1d0e 100644 --- a/cmd/operator-sdk/exec-entrypoint/cmd.go +++ b/cmd/operator-sdk/exec-entrypoint/cmd.go @@ -21,17 +21,18 @@ import ( // NewCmd returns a command that contains subcommands to run specific // operator types. func NewCmd() *cobra.Command { - runCmd := &cobra.Command{ + cmd := &cobra.Command{ Use: "exec-entrypoint", Short: "Runs a generic operator", Long: `Runs a generic operator. This is intended to be used when running in a Pod inside a cluster. Developers wanting to run their operator locally should use "run --local" instead.`, + Hidden: true, } - runCmd.AddCommand( + cmd.AddCommand( newRunAnsibleCmd(), newRunHelmCmd(), ) - return runCmd + return cmd } diff --git a/cmd/operator-sdk/run/cmd.go b/cmd/operator-sdk/run/cmd.go index 33badb0e979..3c4d1184b0b 100644 --- a/cmd/operator-sdk/run/cmd.go +++ b/cmd/operator-sdk/run/cmd.go @@ -15,6 +15,7 @@ package run import ( + "errors" "fmt" "path/filepath" @@ -48,6 +49,9 @@ func NewCmd() *cobra.Command { Use: "run", Short: "Run an Operator in a variety of environments", RunE: func(cmd *cobra.Command, args []string) error { + if c.olm && c.local || !c.olm && !c.local { + return errors.New("exactly one run-type flag must be set: --olm, --local") + } projutil.MustInProjectRoot() switch { @@ -91,13 +95,15 @@ func NewCmd() *cobra.Command { // 'run --olm' and related flags. cmd.Flags().BoolVar(&c.olm, "olm", true, - "The operator to be run will be managed by OLM in a cluster.") + "The operator to be run will be managed by OLM in a cluster. "+ + "Cannot be set with another run-type flag") c.olmArgs.AddToFlagSet(cmd.Flags()) // 'run --local' and related flags. cmd.Flags().BoolVar(&c.local, "local", false, "The operator will be run locally by building the operator binary with "+ - "the ability to access a kubernetes cluster using a kubeconfig file.") + "the ability to access a kubernetes cluster using a kubeconfig file. "+ + "Cannot be set with another run-type flag.") c.localArgs.addToFlags(cmd.Flags()) switch projutil.GetOperatorType() { case projutil.OperatorTypeAnsible: diff --git a/doc/cli/operator-sdk.md b/doc/cli/operator-sdk.md index a33894caab6..719c462a064 100644 --- a/doc/cli/operator-sdk.md +++ b/doc/cli/operator-sdk.md @@ -19,7 +19,6 @@ An SDK for building operators with ease * [operator-sdk build](operator-sdk_build.md) - Compiles code and builds artifacts * [operator-sdk cleanup](operator-sdk_cleanup.md) - Delete and clean up after a running Operator * [operator-sdk completion](operator-sdk_completion.md) - Generators for shell completions -* [operator-sdk exec-entrypoint](operator-sdk_exec-entrypoint.md) - Runs a generic operator * [operator-sdk generate](operator-sdk_generate.md) - Invokes specific generator * [operator-sdk migrate](operator-sdk_migrate.md) - Adds source code to an operator * [operator-sdk new](operator-sdk_new.md) - Creates a new operator application diff --git a/doc/cli/operator-sdk_cleanup.md b/doc/cli/operator-sdk_cleanup.md index 19809b9a0cb..58cd26f3ce7 100644 --- a/doc/cli/operator-sdk_cleanup.md +++ b/doc/cli/operator-sdk_cleanup.md @@ -15,7 +15,7 @@ operator-sdk cleanup [flags] ``` --kubeconfig string The file path to kubernetes configuration file. Defaults to location specified by $KUBECONFIG, or to default file rules if not set --namespace string The namespace where the operator watches for changes. - --olm The operator to be run will be managed by OLM in a cluster. (default true) + --olm The operator to be run will be managed by OLM in a cluster. Cannot be set with another run-type flag (default true) --manifests string [olm only] Directory containing package manifest and operator bundles. --operator-version string [olm only] Version of operator to deploy --install-mode string [olm only] InstallMode to create OperatorGroup with. Format: InstallModeType=[ns1,ns2[, ...]] diff --git a/doc/cli/operator-sdk_exec-entrypoint.md b/doc/cli/operator-sdk_exec-entrypoint.md deleted file mode 100644 index 9042b049d88..00000000000 --- a/doc/cli/operator-sdk_exec-entrypoint.md +++ /dev/null @@ -1,22 +0,0 @@ -## operator-sdk exec-entrypoint - -Runs a generic operator - -### Synopsis - -Runs a generic operator. This is intended to be used when running -in a Pod inside a cluster. Developers wanting to run their operator locally -should use "run --local" instead. - -### Options - -``` - -h, --help help for exec-entrypoint -``` - -### SEE ALSO - -* [operator-sdk](operator-sdk.md) - An SDK for building operators with ease -* [operator-sdk exec-entrypoint ansible](operator-sdk_exec-entrypoint_ansible.md) - Runs as an ansible operator -* [operator-sdk exec-entrypoint helm](operator-sdk_exec-entrypoint_helm.md) - Runs as a helm operator - diff --git a/doc/cli/operator-sdk_exec-entrypoint_ansible.md b/doc/cli/operator-sdk_exec-entrypoint_ansible.md deleted file mode 100644 index 8d0e7bd1130..00000000000 --- a/doc/cli/operator-sdk_exec-entrypoint_ansible.md +++ /dev/null @@ -1,34 +0,0 @@ -## operator-sdk exec-entrypoint ansible - -Runs as an ansible operator - -### Synopsis - -Runs as an ansible operator. This is intended to be used when running -in a Pod inside a cluster. Developers wanting to run their operator locally -should use "up local" instead. - -``` -operator-sdk exec-entrypoint ansible [flags] -``` - -### Options - -``` - --ansible-verbosity int Ansible verbosity. Overridden by environment variable. (default 2) - -h, --help help for ansible - --inject-owner-ref The ansible operator will inject owner references unless this flag is false (default true) - --max-workers int Maximum number of workers to use. Overridden by environment variable. (default 1) - --reconcile-period duration Default reconcile period for controllers (default 1m0s) - --watches-file string Path to the watches file to use (default "./watches.yaml") - --zap-devel Enable zap development mode (changes defaults to console encoder, debug log level, and disables sampling) - --zap-encoder encoder Zap log encoding ('json' or 'console') - --zap-level level Zap log level (one of 'debug', 'info', 'error' or any integer value > 0) (default info) - --zap-sample sample Enable zap log sampling. Sampling will be disabled for integer log levels > 1 - --zap-time-encoding timeEncoding Sets the zap time format ('epoch', 'millis', 'nano', or 'iso8601') (default ) -``` - -### SEE ALSO - -* [operator-sdk exec-entrypoint](operator-sdk_exec-entrypoint.md) - Runs a generic operator - diff --git a/doc/cli/operator-sdk_exec-entrypoint_helm.md b/doc/cli/operator-sdk_exec-entrypoint_helm.md deleted file mode 100644 index 905225576cf..00000000000 --- a/doc/cli/operator-sdk_exec-entrypoint_helm.md +++ /dev/null @@ -1,31 +0,0 @@ -## operator-sdk exec-entrypoint helm - -Runs as a helm operator - -### Synopsis - -Runs as a helm operator. This is intended to be used when running -in a Pod inside a cluster. Developers wanting to run their operator locally -should use "up local" instead. - -``` -operator-sdk exec-entrypoint helm [flags] -``` - -### Options - -``` - -h, --help help for helm - --reconcile-period duration Default reconcile period for controllers (default 1m0s) - --watches-file string Path to the watches file to use (default "./watches.yaml") - --zap-devel Enable zap development mode (changes defaults to console encoder, debug log level, and disables sampling) - --zap-encoder encoder Zap log encoding ('json' or 'console') - --zap-level level Zap log level (one of 'debug', 'info', 'error' or any integer value > 0) (default info) - --zap-sample sample Enable zap log sampling. Sampling will be disabled for integer log levels > 1 - --zap-time-encoding timeEncoding Sets the zap time format ('epoch', 'millis', 'nano', or 'iso8601') (default ) -``` - -### SEE ALSO - -* [operator-sdk exec-entrypoint](operator-sdk_exec-entrypoint.md) - Runs a generic operator - diff --git a/doc/cli/operator-sdk_run.md b/doc/cli/operator-sdk_run.md index f922cac528d..93a565eabb8 100644 --- a/doc/cli/operator-sdk_run.md +++ b/doc/cli/operator-sdk_run.md @@ -15,13 +15,13 @@ operator-sdk run [flags] ``` --kubeconfig string The file path to kubernetes configuration file. Defaults to location specified by $KUBECONFIG, or to default file rules if not set --namespace string The namespace where the operator watches for changes. - --olm The operator to be run will be managed by OLM in a cluster. (default true) + --olm The operator to be run will be managed by OLM in a cluster. Cannot be set with another run-type flag (default true) --manifests string [olm only] Directory containing package manifest and operator bundles. --operator-version string [olm only] Version of operator to deploy --install-mode string [olm only] InstallMode to create OperatorGroup with. Format: InstallModeType=[ns1,ns2[, ...]] --include strings [olm only] Path to Kubernetes resource manifests, ex. Role, Subscription. These supplement or override defaults generated by run/cleanup --timeout duration [olm only] Time to wait for the command to complete before failing (default 2m0s) - --local The operator will be run locally by building the operator binary with the ability to access a kubernetes cluster using a kubeconfig file. + --local The operator will be run locally by building the operator binary with the ability to access a kubernetes cluster using a kubeconfig file. Cannot be set with another run-type flag. --operator-flags string [local only] The flags that the operator needs. Example: "--flag1 value1 --flag2=value2" --go-ldflags string [local only] Set Go linker options --enable-delve [local only] Start the operator using the delve debugger From 9d7e6f4f269d9c5e2183fcb95d9a6077d2c5fdf7 Mon Sep 17 00:00:00 2001 From: Eric Stroczynski Date: Mon, 20 Jan 2020 14:50:56 -0800 Subject: [PATCH 04/11] CHANGELOG.md: add run/cleanup additions and run change --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e8f06fa624..cd67206d5fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,12 +2,13 @@ ### Added -- Added [`run`](./doc/cli/operator-sdk_alpha_run.md) and [`cleanup`](./doc/cli/operator-sdk_alpha_cleanup.md) subcommands (under the `alpha` subcommand) to manage deployment/deletion of operators. These commands currently interact with OLM via an in-cluster registry-server created using an operator's on-disk manifests and managed by `operator-sdk`. ([#2402](https://github.com/operator-framework/operator-sdk/pull/2402)) +- Added the [`cleanup`](./doc/cli/operator-sdk_cleanup.md) subcommand and [`run --olm`](./doc/cli/operator-sdk_run.md) to manage deployment/deletion of operators. These commands currently interact with OLM via an in-cluster registry-server created using an operator's on-disk manifests and managed by `operator-sdk`. ([#2402](https://github.com/operator-framework/operator-sdk/pull/2402), [#2441](https://github.com/operator-framework/operator-sdk/pull/2441)) - Added [`bundle build`](./doc/cli/operator-sdk_alpha_bundle_build.md) (under the `alpha` subcommand) which builds, and optionally generates metadata for, [operator bundle images](https://github.com/openshift/enhancements/blob/ec2cf96/enhancements/olm/operator-registry.md). ([#2076](https://github.com/operator-framework/operator-sdk/pull/2076)) ### Changed - Changed error wrapping according to Go version 1.13+ [error handling](https://blog.golang.org/go1.13-errors). ([#2355](https://github.com/operator-framework/operator-sdk/pull/2355)) - Added retry logic to the cleanup function from the e2e test framework in order to allow it to be achieved in the scenarios where temporary network issues are faced. ([#2277](https://github.com/operator-framework/operator-sdk/pull/2277)) +- `run local` is now [`run --local`](./doc/cli/operator-sdk_run.md). All other functionality of the command is the same. ([#2441](https://github.com/operator-framework/operator-sdk/pull/2441)) ### Deprecated From ea2ab4c084df32d15b6b5edc7524c878420eae4b Mon Sep 17 00:00:00 2001 From: Eric Stroczynski Date: Tue, 21 Jan 2020 09:19:27 -0800 Subject: [PATCH 05/11] *: change all references of 'up local' to 'run --local' --- README.md | 5 ++--- cmd/operator-sdk/cli/cli.go | 2 +- cmd/operator-sdk/exec-entrypoint/ansible.go | 2 +- cmd/operator-sdk/exec-entrypoint/helm.go | 2 +- cmd/operator-sdk/main.go | 2 +- doc/ansible/user-guide.md | 4 ++-- doc/dev/testing/travis-build.md | 4 ++-- doc/helm/user-guide.md | 6 +++--- doc/proposals/kubebuilder-integration.md | 2 +- doc/user-guide.md | 2 +- doc/user/logging.md | 4 ++-- hack/tests/subcommand.sh | 4 ++-- test/e2e/_incluster-test-code/memcached_test.go | 4 +++- 13 files changed, 22 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index d6ee783f7c9..a3479d8e172 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ The following workflow is for a new **Helm** operator: - Alternatively [podman][podman_tool] `v1.2.0+` or [buildah][buildah_tool] `v1.7+` - [kubectl][kubectl_tool] version v1.12.0+. - Access to a Kubernetes v1.12.0+ cluster. -- Optional: [delve](https://github.com/go-delve/delve/tree/master/Documentation/installation) version 1.2.0+ (for `up local --enable-delve`). +- Optional: [delve](https://github.com/go-delve/delve/tree/master/Documentation/installation) version 1.2.0+ (for `run --local --enable-delve`). ## Quick Start @@ -134,7 +134,7 @@ $ kubectl delete -f deploy/crds/app.example.com_appservices_crd.yaml ``` **Note:** Follow the steps in the [Getting Started Repository][getting_started] to learn how to develop your Operator projects. - + ## Command Line Interface To learn more about the SDK CLI, see the [SDK CLI Reference][sdk_cli_ref], or run `operator-sdk [command] -h`. @@ -196,4 +196,3 @@ Operator SDK is under Apache 2.0 license. See the [LICENSE][license_file] file f [helm_user_guide]:./doc/helm/user-guide.md [faq]: ./doc/faq.md [getting_started]: https://github.com/operator-framework/getting-started/blob/master/README.md - diff --git a/cmd/operator-sdk/cli/cli.go b/cmd/operator-sdk/cli/cli.go index 3b24f0319a9..d085d3e7248 100644 --- a/cmd/operator-sdk/cli/cli.go +++ b/cmd/operator-sdk/cli/cli.go @@ -17,7 +17,7 @@ package cli import ( // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.) - // to ensure that `run` and `up local` can make use of them. + // to ensure that `exec-entrypoint` and `run` can make use of them. _ "k8s.io/client-go/plugin/pkg/client/auth" "github.com/operator-framework/operator-sdk/cmd/operator-sdk/add" diff --git a/cmd/operator-sdk/exec-entrypoint/ansible.go b/cmd/operator-sdk/exec-entrypoint/ansible.go index 1b15123ec10..75254220d9c 100644 --- a/cmd/operator-sdk/exec-entrypoint/ansible.go +++ b/cmd/operator-sdk/exec-entrypoint/ansible.go @@ -31,7 +31,7 @@ func newRunAnsibleCmd() *cobra.Command { Short: "Runs as an ansible operator", Long: `Runs as an ansible operator. This is intended to be used when running in a Pod inside a cluster. Developers wanting to run their operator locally -should use "up local" instead.`, +should use "run --local" instead.`, RunE: func(cmd *cobra.Command, args []string) error { logf.SetLogger(zap.Logger()) diff --git a/cmd/operator-sdk/exec-entrypoint/helm.go b/cmd/operator-sdk/exec-entrypoint/helm.go index c2fdd739fbe..92fb4e705d4 100644 --- a/cmd/operator-sdk/exec-entrypoint/helm.go +++ b/cmd/operator-sdk/exec-entrypoint/helm.go @@ -31,7 +31,7 @@ func newRunHelmCmd() *cobra.Command { Short: "Runs as a helm operator", Long: `Runs as a helm operator. This is intended to be used when running in a Pod inside a cluster. Developers wanting to run their operator locally -should use "up local" instead.`, +should use "run --local" instead.`, RunE: func(cmd *cobra.Command, args []string) error { logf.SetLogger(zap.Logger()) diff --git a/cmd/operator-sdk/main.go b/cmd/operator-sdk/main.go index 7e08d96f60f..2ce49918cdf 100644 --- a/cmd/operator-sdk/main.go +++ b/cmd/operator-sdk/main.go @@ -18,7 +18,7 @@ import ( "os" // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.) - // to ensure that `run` and `up local` can make use of them. + // to ensure that `exec-entrypoint` and `run --local` can make use of them. _ "k8s.io/client-go/plugin/pkg/client/auth" "github.com/operator-framework/operator-sdk/cmd/operator-sdk/cli" diff --git a/doc/ansible/user-guide.md b/doc/ansible/user-guide.md index 91217548e0b..ffbbd0fb2a4 100644 --- a/doc/ansible/user-guide.md +++ b/doc/ansible/user-guide.md @@ -292,7 +292,7 @@ Run the operator locally with the default Kubernetes config file present at `$HOME/.kube/config`: ```sh -$ operator-sdk up local +$ operator-sdk run --local INFO[0000] Go Version: go1.10 INFO[0000] Go OS/Arch: darwin/amd64 INFO[0000] operator-sdk Version: 0.0.5+git @@ -301,7 +301,7 @@ INFO[0000] operator-sdk Version: 0.0.5+git Run the operator locally with a provided Kubernetes config file: ```sh -$ operator-sdk up local --kubeconfig=config +$ operator-sdk run --local --kubeconfig=config INFO[0000] Go Version: go1.10 INFO[0000] Go OS/Arch: darwin/amd64 INFO[0000] operator-sdk Version: 0.0.5+git diff --git a/doc/dev/testing/travis-build.md b/doc/dev/testing/travis-build.md index 1923c7b3b6c..8517bee9eaa 100644 --- a/doc/dev/testing/travis-build.md +++ b/doc/dev/testing/travis-build.md @@ -46,7 +46,7 @@ The Go, Ansible, and Helm tests then differ in what tests they run. 4. Run [go e2e tests][go-e2e]. 1. Scaffold a project using `hack/tests/scaffolding/e2e-go-scaffold.sh` 2. Build `memcached-operator` image to be used in tests - 3. Run scaffolded project e2e tests using `operator-sdk up local` + 3. Run scaffolded project e2e tests using `operator-sdk run --local` 1. Run cluster test (namespace is auto-generated and deleted by test framework). 1. Deploy operator and required resources to the cluster. 2. Run the leader election test. @@ -68,7 +68,7 @@ The Go, Ansible, and Helm tests then differ in what tests they run. 3. Perform linting of the existing metrics. 4. Perform checks on each custom resource generated metric and makes sure the name, type, value, labels and metric are correct. 2. Run local test (namespace is auto-generated and deleted by test framework). - 1. Start operator using `up local` subcommand. + 1. Start operator using the `run --local` subcommand. 2. Run memcached scale test (described in step 4.3.1.3) 4. Run [TLS library tests][tls-tests]. 1. This test runs multiple simple tests of the operator-sdk's TLS library. The tests run in parallel and each tests runs in its own namespace. diff --git a/doc/helm/user-guide.md b/doc/helm/user-guide.md index aea95d899ca..4c7792072c4 100644 --- a/doc/helm/user-guide.md +++ b/doc/helm/user-guide.md @@ -61,7 +61,7 @@ If a custom repository URL is specified by `--helm-chart-repo`, the only support - ``: Fetch the helm chart named `chartName` in the helm chart repository specified by the `--helm-chart-repo` URL. -If `--helm-chart-version` is not set, the SDK will fetch the latest available version of the helm chart. Otherwise, it will fetch the specified version. The option `--helm-chart-version` is not used when `--helm-chart` itself refers to a specific version, for example when it is a local path or a URL. +If `--helm-chart-version` is not set, the SDK will fetch the latest available version of the helm chart. Otherwise, it will fetch the specified version. The option `--helm-chart-version` is not used when `--helm-chart` itself refers to a specific version, for example when it is a local path or a URL. **Note:** For more details and examples see the [Helm CLI reference doc][helm-reference-cli-doc]. @@ -217,7 +217,7 @@ Run the operator locally with the default Kubernetes config file present at `$HOME/.kube/config`: ```sh -$ operator-sdk up local +$ operator-sdk run --local INFO[0000] Go Version: go1.10.3 INFO[0000] Go OS/Arch: linux/amd64 INFO[0000] operator-sdk Version: v0.1.1+git @@ -226,7 +226,7 @@ INFO[0000] operator-sdk Version: v0.1.1+git Run the operator locally with a provided Kubernetes config file: ```sh -$ operator-sdk up local --kubeconfig= +$ operator-sdk run --local --kubeconfig= INFO[0000] Go Version: go1.10.3 INFO[0000] Go OS/Arch: linux/amd64 INFO[0000] operator-sdk Version: v0.2.0+git diff --git a/doc/proposals/kubebuilder-integration.md b/doc/proposals/kubebuilder-integration.md index 99e7737bd46..79f45feef27 100644 --- a/doc/proposals/kubebuilder-integration.md +++ b/doc/proposals/kubebuilder-integration.md @@ -142,7 +142,7 @@ Other SDK subcommands can be removed and replaced by their equivalent Makefile t - `operator-sdk generate k8s` ==> `make generate` - `operator-sdk generate crd` ==> `make manifests` - `operator-sdk build` ==> `make manager`, `make docker-build` -- `operator-sdk up local` ==> `make run` +- `operator-sdk run --local` ==> `make run` If any of the old subcommands above are invoked for a Go operator project, the output should be a deprecation error that highlights the equivalent replacement diff --git a/doc/user-guide.md b/doc/user-guide.md index 5a6b6d2c0d2..35164dcbedb 100644 --- a/doc/user-guide.md +++ b/doc/user-guide.md @@ -322,7 +322,7 @@ export OPERATOR_NAME=memcached-operator Run the operator locally with the default Kubernetes config file present at `$HOME/.kube/config`: ```sh -$ operator-sdk up local --namespace=default +$ operator-sdk run --local --namespace=default 2018/09/30 23:10:11 Go Version: go1.10.2 2018/09/30 23:10:11 Go OS/Arch: darwin/amd64 2018/09/30 23:10:11 operator-sdk Version: 0.0.6+git diff --git a/doc/user/logging.md b/doc/user/logging.md index 298593b05fd..6964259c51e 100644 --- a/doc/user/logging.md +++ b/doc/user/logging.md @@ -64,10 +64,10 @@ By using `sigs.k8s.io/controller-runtime/pkg/log`, your logger is propagated thr ### Setting flags when running locally -When running locally with `operator-sdk up local`, you can use the `--operator-flags` flag to pass additional flags to your operator, including the zap flags. For example: +When running locally with `operator-sdk run --local`, you can use the `--operator-flags` flag to pass additional flags to your operator, including the zap flags. For example: ```console -$ operator-sdk up local --operator-flags="--zap-level=debug --zap-encoder=console"` +$ operator-sdk run --local --operator-flags="--zap-level=debug --zap-encoder=console"` ``` ### Setting flags when deploying to a cluster diff --git a/hack/tests/subcommand.sh b/hack/tests/subcommand.sh index 7567ee2d0b7..51ac9d663cc 100755 --- a/hack/tests/subcommand.sh +++ b/hack/tests/subcommand.sh @@ -23,12 +23,12 @@ trap_add 'kubectl delete namespace test-memcached || true' EXIT operator-sdk test local ./test/e2e --namespace=test-memcached kubectl delete namespace test-memcached -# test operator in up local mode +# test operator in 'run --local' mode kubectl create namespace test-memcached operator-sdk test local ./test/e2e --up-local --namespace=test-memcached kubectl delete namespace test-memcached -# test operator in up local mode with kubeconfig +# test operator in 'run --local' mode with kubeconfig kubectl create namespace test-memcached operator-sdk test local ./test/e2e --up-local --namespace=test-memcached --kubeconfig $KUBECONFIG kubectl delete namespace test-memcached diff --git a/test/e2e/_incluster-test-code/memcached_test.go b/test/e2e/_incluster-test-code/memcached_test.go index 9fa3f2b3e10..a4ab3816487 100644 --- a/test/e2e/_incluster-test-code/memcached_test.go +++ b/test/e2e/_incluster-test-code/memcached_test.go @@ -217,7 +217,9 @@ func MemcachedLocal(t *testing.T) { if err != nil { t.Fatal(err) } - cmd := exec.Command("operator-sdk", "up", "local", "--namespace="+namespace) + cmd := exec.Command("operator-sdk", "run", + "--local", + "--namespace="+namespace) stderr, err := os.Create("stderr.txt") if err != nil { t.Fatalf("Failed to create stderr.txt: %v", err) From 984c2f80f915f7dfbc21a88f908d1444d27f5ade Mon Sep 17 00:00:00 2001 From: Eric Stroczynski Date: Tue, 21 Jan 2020 09:36:37 -0800 Subject: [PATCH 06/11] fix comment --- cmd/operator-sdk/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/operator-sdk/main.go b/cmd/operator-sdk/main.go index 2ce49918cdf..8335a3e206a 100644 --- a/cmd/operator-sdk/main.go +++ b/cmd/operator-sdk/main.go @@ -18,7 +18,7 @@ import ( "os" // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.) - // to ensure that `exec-entrypoint` and `run --local` can make use of them. + // to ensure that `exec-entrypoint` and `run` can make use of them. _ "k8s.io/client-go/plugin/pkg/client/auth" "github.com/operator-framework/operator-sdk/cmd/operator-sdk/cli" From 7afa99ddb17793ecd203ccf67a2efbf49ce1f7ab Mon Sep 17 00:00:00 2001 From: Eric Stroczynski Date: Tue, 21 Jan 2020 09:54:49 -0800 Subject: [PATCH 07/11] fix up cli docs --- cmd/operator-sdk/alpha/cmd.go | 8 +-- doc/cli/operator-sdk_alpha.md | 3 - doc/cli/operator-sdk_alpha_bundle.md | 23 ------- doc/cli/operator-sdk_alpha_bundle_create.md | 68 --------------------- doc/cli/operator-sdk_alpha_cleanup.md | 30 --------- doc/cli/operator-sdk_alpha_run.md | 34 ----------- 6 files changed, 1 insertion(+), 165 deletions(-) delete mode 100644 doc/cli/operator-sdk_alpha_bundle.md delete mode 100644 doc/cli/operator-sdk_alpha_bundle_create.md delete mode 100644 doc/cli/operator-sdk_alpha_cleanup.md delete mode 100644 doc/cli/operator-sdk_alpha_run.md diff --git a/cmd/operator-sdk/alpha/cmd.go b/cmd/operator-sdk/alpha/cmd.go index daa1b70c1c4..f4bbe5366df 100644 --- a/cmd/operator-sdk/alpha/cmd.go +++ b/cmd/operator-sdk/alpha/cmd.go @@ -17,9 +17,6 @@ package alpha import ( "github.com/operator-framework/operator-sdk/cmd/operator-sdk/alpha/kubebuilder" "github.com/operator-framework/operator-sdk/cmd/operator-sdk/alpha/olm" - "github.com/operator-framework/operator-sdk/cmd/operator-sdk/bundle" - "github.com/operator-framework/operator-sdk/cmd/operator-sdk/cleanup" - "github.com/operator-framework/operator-sdk/cmd/operator-sdk/run" "github.com/spf13/cobra" ) @@ -31,11 +28,8 @@ func NewCmd() *cobra.Command { } cmd.AddCommand( - olm.NewCmd(), kubebuilder.NewCmd(), - run.NewCmd(), - cleanup.NewCmd(), - bundle.NewCmd(), + olm.NewCmd(), ) return cmd } diff --git a/doc/cli/operator-sdk_alpha.md b/doc/cli/operator-sdk_alpha.md index 868f8d7e0c8..cf209d2b328 100644 --- a/doc/cli/operator-sdk_alpha.md +++ b/doc/cli/operator-sdk_alpha.md @@ -15,8 +15,5 @@ Run an alpha subcommand ### SEE ALSO * [operator-sdk](operator-sdk.md) - An SDK for building operators with ease -* [operator-sdk alpha bundle](operator-sdk_alpha_bundle.md) - Work with operator bundle metadata and bundle images -* [operator-sdk alpha cleanup](operator-sdk_alpha_cleanup.md) - Delete and clean up after a running Operator * [operator-sdk alpha olm](operator-sdk_alpha_olm.md) - Manage the Operator Lifecycle Manager installation in your cluster -* [operator-sdk alpha run](operator-sdk_alpha_run.md) - Run an Operator in a variety of environments diff --git a/doc/cli/operator-sdk_alpha_bundle.md b/doc/cli/operator-sdk_alpha_bundle.md deleted file mode 100644 index 5d9adfa7986..00000000000 --- a/doc/cli/operator-sdk_alpha_bundle.md +++ /dev/null @@ -1,23 +0,0 @@ -## operator-sdk alpha bundle - -Work with operator bundle metadata and bundle images - -### Synopsis - -Generate operator bundle metadata and build operator bundle images, which -are used to manage operators in the Operator Lifecycle Manager. - -More information on operator bundle images and metadata: -https://github.com/openshift/enhancements/blob/master/enhancements/olm/operator-bundle.md#docker - -### Options - -``` - -h, --help help for bundle -``` - -### SEE ALSO - -* [operator-sdk alpha](operator-sdk_alpha.md) - Run an alpha subcommand -* [operator-sdk alpha bundle create](operator-sdk_alpha_bundle_create.md) - Create an operator bundle image - diff --git a/doc/cli/operator-sdk_alpha_bundle_create.md b/doc/cli/operator-sdk_alpha_bundle_create.md deleted file mode 100644 index fdebfb78978..00000000000 --- a/doc/cli/operator-sdk_alpha_bundle_create.md +++ /dev/null @@ -1,68 +0,0 @@ -## operator-sdk alpha bundle create - -Create an operator bundle image - -### Synopsis - -The 'operator-sdk bundle create' command will build an operator -bundle image containing operator metadata and manifests, tagged with the -provided image tag. - -To write metadata and a bundle image Dockerfile to disk, set '--generate-only=true'. -Bundle metadata will be generated in /metadata, and the Dockerfile -in . This flag is useful if you want to build an operator's -bundle image manually or modify metadata before building an image. - -More information on operator bundle images and metadata: -https://github.com/openshift/enhancements/blob/master/enhancements/olm/operator-bundle.md#docker - -NOTE: bundle images are not runnable. - -``` -operator-sdk alpha bundle create [flags] -``` - -### Examples - -``` -The following invocation will build a test-operator bundle image using Docker. -This image will contain manifests for package channels 'stable' and 'beta': - -$ operator-sdk bundle create quay.io/example/test-operator:v0.1.0 \ - --directory ./deploy/olm-catalog/test-operator \ - --package test-operator \ - --channels stable,beta \ - --default-channel stable - -Assuming your operator has the same name as your operator and the only channel -is 'stable', the above command can be abbreviated to: - -$ operator-sdk bundle create quay.io/example/test-operator:v0.1.0 - -The following invocation will generate test-operator bundle metadata and -Dockerfile without building the image: - -$ operator-sdk bundle create \ - --generate-only \ - --directory ./deploy/olm-catalog/test-operator \ - --package test-operator \ - --channels stable,beta \ - --default-channel stable -``` - -### Options - -``` - -c, --channels strings The list of channels that bundle image belongs to (default [stable]) - -e, --default-channel string The default channel for the bundle image - -d, --directory string The directory where bundle manifests are located - -g, --generate-only Generate metadata and a Dockerfile on disk without building the bundle image - -h, --help help for create - -b, --image-builder string Tool to build container images. One of: [docker, podman, buildah] (default "docker") - -p, --package string The name of the package that bundle image belongs to. Set if package name differs from project name (default "operator-sdk") -``` - -### SEE ALSO - -* [operator-sdk alpha bundle](operator-sdk_alpha_bundle.md) - Work with operator bundle metadata and bundle images - diff --git a/doc/cli/operator-sdk_alpha_cleanup.md b/doc/cli/operator-sdk_alpha_cleanup.md deleted file mode 100644 index 560d11e1350..00000000000 --- a/doc/cli/operator-sdk_alpha_cleanup.md +++ /dev/null @@ -1,30 +0,0 @@ -## operator-sdk alpha cleanup - -Delete and clean up after a running Operator - -### Synopsis - -Delete and clean up after a running Operator - -``` -operator-sdk alpha cleanup [flags] -``` - -### Options - -``` - --kubeconfig string The file path to kubernetes configuration file. Defaults to location specified by $KUBECONFIG, or to default file rules if not set - --namespace string The namespace where the operator watches for changes. - --olm The operator to be run will be managed by OLM in a cluster. Cannot be set with another run-type flag (default true) - --manifests string [olm only] Directory containing package manifest and operator bundles. - --operator-version string [olm only] Version of operator to deploy - --install-mode string [olm only] InstallMode to create OperatorGroup with. Format: InstallModeType=[ns1,ns2[, ...]] - --include strings [olm only] Path to Kubernetes resource manifests, ex. Role, Subscription. These supplement or override defaults generated by run/cleanup - --timeout duration [olm only] Time to wait for the command to complete before failing (default 2m0s) - -h, --help help for cleanup -``` - -### SEE ALSO - -* [operator-sdk alpha](operator-sdk_alpha.md) - Run an alpha subcommand - diff --git a/doc/cli/operator-sdk_alpha_run.md b/doc/cli/operator-sdk_alpha_run.md deleted file mode 100644 index 3ebf0b2e0e7..00000000000 --- a/doc/cli/operator-sdk_alpha_run.md +++ /dev/null @@ -1,34 +0,0 @@ -## operator-sdk alpha run - -Run an Operator in a variety of environments - -### Synopsis - -Run an Operator in a variety of environments - -``` -operator-sdk alpha run [flags] -``` - -### Options - -``` - --kubeconfig string The file path to kubernetes configuration file. Defaults to location specified by $KUBECONFIG, or to default file rules if not set - --namespace string The namespace where the operator watches for changes. - --olm The operator to be run will be managed by OLM in a cluster. Cannot be set with another run-type flag (default true) - --manifests string [olm only] Directory containing package manifest and operator bundles. - --operator-version string [olm only] Version of operator to deploy - --install-mode string [olm only] InstallMode to create OperatorGroup with. Format: InstallModeType=[ns1,ns2[, ...]] - --include strings [olm only] Path to Kubernetes resource manifests, ex. Role, Subscription. These supplement or override defaults generated by run/cleanup - --timeout duration [olm only] Time to wait for the command to complete before failing (default 2m0s) - --local The operator will be run locally by building the operator binary with the ability to access a kubernetes cluster using a kubeconfig file. Cannot be set with another run-type flag. - --operator-flags string [local only] The flags that the operator needs. Example: "--flag1 value1 --flag2=value2" - --go-ldflags string [local only] Set Go linker options - --enable-delve [local only] Start the operator using the delve debugger - -h, --help help for run -``` - -### SEE ALSO - -* [operator-sdk alpha](operator-sdk_alpha.md) - Run an alpha subcommand - From 3cdc2cdea7e99df9dc377a16d37198a26ca39551 Mon Sep 17 00:00:00 2001 From: Eric Stroczynski Date: Tue, 21 Jan 2020 09:59:12 -0800 Subject: [PATCH 08/11] update changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ce06c05bea..66afe8a1cb8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,8 @@ - Changed error wrapping according to Go version 1.13+ [error handling](https://blog.golang.org/go1.13-errors). ([#2355](https://github.com/operator-framework/operator-sdk/pull/2355)) - Added retry logic to the cleanup function from the e2e test framework in order to allow it to be achieved in the scenarios where temporary network issues are faced. ([#2277](https://github.com/operator-framework/operator-sdk/pull/2277)) - Moved `olm-catalog gen-csv` to the `generate csv` subcommand. ([#2439](https://github.com/operator-framework/operator-sdk/pull/2439)) -- `up local` is now [`run --local`](./doc/cli/operator-sdk_run.md). All other functionality of the command is the same. ([#2441](https://github.com/operator-framework/operator-sdk/pull/2441)) +- `run ansible/helm` are now the hidden commands `exec-entrypoint ansible/helm`. All functionality of each subcommand is the same. ([#2441](https://github.com/operator-framework/operator-sdk/pull/2441)) +- `up local` is now [`run --local`](./doc/cli/operator-sdk_run.md). All functionality of this command is the same. ([#2441](https://github.com/operator-framework/operator-sdk/pull/2441)) ### Deprecated From 6fb3d61cbc9154b47a3afa9e0c7fc358cbdaf8c1 Mon Sep 17 00:00:00 2001 From: Eric Stroczynski Date: Tue, 21 Jan 2020 10:27:15 -0800 Subject: [PATCH 09/11] cmd/operator-sdk/{exec-entrypoint -> execentrypoint} --- cmd/operator-sdk/cli/cli.go | 2 +- .../{exec-entrypoint => execentrypoint}/ansible.go | 2 +- cmd/operator-sdk/{exec-entrypoint => execentrypoint}/cmd.go | 6 ++---- .../{exec-entrypoint => execentrypoint}/helm.go | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) rename cmd/operator-sdk/{exec-entrypoint => execentrypoint}/ansible.go (98%) rename cmd/operator-sdk/{exec-entrypoint => execentrypoint}/cmd.go (95%) rename cmd/operator-sdk/{exec-entrypoint => execentrypoint}/helm.go (98%) diff --git a/cmd/operator-sdk/cli/cli.go b/cmd/operator-sdk/cli/cli.go index 44bd6fb7309..9136feed50c 100644 --- a/cmd/operator-sdk/cli/cli.go +++ b/cmd/operator-sdk/cli/cli.go @@ -26,7 +26,7 @@ import ( "github.com/operator-framework/operator-sdk/cmd/operator-sdk/bundle" "github.com/operator-framework/operator-sdk/cmd/operator-sdk/cleanup" "github.com/operator-framework/operator-sdk/cmd/operator-sdk/completion" - execentrypoint "github.com/operator-framework/operator-sdk/cmd/operator-sdk/exec-entrypoint" + "github.com/operator-framework/operator-sdk/cmd/operator-sdk/execentrypoint" "github.com/operator-framework/operator-sdk/cmd/operator-sdk/generate" "github.com/operator-framework/operator-sdk/cmd/operator-sdk/migrate" "github.com/operator-framework/operator-sdk/cmd/operator-sdk/new" diff --git a/cmd/operator-sdk/exec-entrypoint/ansible.go b/cmd/operator-sdk/execentrypoint/ansible.go similarity index 98% rename from cmd/operator-sdk/exec-entrypoint/ansible.go rename to cmd/operator-sdk/execentrypoint/ansible.go index 75254220d9c..c43fef3fb76 100644 --- a/cmd/operator-sdk/exec-entrypoint/ansible.go +++ b/cmd/operator-sdk/execentrypoint/ansible.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package run +package execentrypoint import ( "github.com/operator-framework/operator-sdk/pkg/ansible" diff --git a/cmd/operator-sdk/exec-entrypoint/cmd.go b/cmd/operator-sdk/execentrypoint/cmd.go similarity index 95% rename from cmd/operator-sdk/exec-entrypoint/cmd.go rename to cmd/operator-sdk/execentrypoint/cmd.go index 350a1ee1d0e..e1d2c99ca80 100644 --- a/cmd/operator-sdk/exec-entrypoint/cmd.go +++ b/cmd/operator-sdk/execentrypoint/cmd.go @@ -12,11 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -package run +package execentrypoint -import ( - "github.com/spf13/cobra" -) +import "github.com/spf13/cobra" // NewCmd returns a command that contains subcommands to run specific // operator types. diff --git a/cmd/operator-sdk/exec-entrypoint/helm.go b/cmd/operator-sdk/execentrypoint/helm.go similarity index 98% rename from cmd/operator-sdk/exec-entrypoint/helm.go rename to cmd/operator-sdk/execentrypoint/helm.go index 92fb4e705d4..bac4f6e8335 100644 --- a/cmd/operator-sdk/exec-entrypoint/helm.go +++ b/cmd/operator-sdk/execentrypoint/helm.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package run +package execentrypoint import ( "github.com/operator-framework/operator-sdk/pkg/helm" From 80c5086df9f34b1cc8c51019fc0808b80fc7df85 Mon Sep 17 00:00:00 2001 From: Eric Stroczynski Date: Tue, 21 Jan 2020 11:17:05 -0800 Subject: [PATCH 10/11] fix ansible/helm entrypoint commands and cleanup/run command defaults --- cmd/operator-sdk/cleanup/cmd.go | 25 +++++++++++++++++-------- cmd/operator-sdk/run/cmd.go | 14 +++++++++++--- internal/scaffold/ansible/entrypoint.go | 2 +- internal/scaffold/helm/entrypoint.go | 2 +- 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/cmd/operator-sdk/cleanup/cmd.go b/cmd/operator-sdk/cleanup/cmd.go index 935d51c9536..89356f823e1 100644 --- a/cmd/operator-sdk/cleanup/cmd.go +++ b/cmd/operator-sdk/cleanup/cmd.go @@ -31,21 +31,29 @@ type cleanupCmd struct { kubeconfig string namespace string - // Run type. + // Cleanup type. olm bool - // Run type-specific options. + // Cleanup type-specific options. olmArgs olmoperator.OLMCmd } +// checkCleanupType ensures exactly one cleanup type has been selected. +func (c *cleanupCmd) checkCleanupType() error { + if !c.olm { + return errors.New("exactly one run-type flag must be set: --olm") + } + return nil +} + func NewCmd() *cobra.Command { c := &cleanupCmd{} cmd := &cobra.Command{ Use: "cleanup", Short: "Delete and clean up after a running Operator", RunE: func(cmd *cobra.Command, args []string) error { - if !c.olm { - return errors.New("exactly one run-type flag must be set: --olm") + if err := c.checkCleanupType(); err != nil { + return err } projutil.MustInProjectRoot() @@ -65,7 +73,7 @@ func NewCmd() *cobra.Command { }, } - // Avoid sorting flags so we can group them according to run type. + // Avoid sorting flags so we can group them according to cleanup type. cmd.Flags().SortFlags = false // Shared flags. @@ -75,10 +83,11 @@ func NewCmd() *cobra.Command { cmd.Flags().StringVar(&c.namespace, "namespace", "", "The namespace where the operator watches for changes.") - // 'run --olm' and related flags. + // 'cleanup --olm' and related flags. Set as default since this is the only + // cleanup type. cmd.Flags().BoolVar(&c.olm, "olm", true, - "The operator to be run will be managed by OLM in a cluster. "+ - "Cannot be set with another run-type flag") + "The operator to be cleaned up is managed by OLM in a cluster. "+ + "Cannot be set with another cleanup-type flag") c.olmArgs.AddToFlagSet(cmd.Flags()) return cmd } diff --git a/cmd/operator-sdk/run/cmd.go b/cmd/operator-sdk/run/cmd.go index 3c4d1184b0b..fab7a4aa74e 100644 --- a/cmd/operator-sdk/run/cmd.go +++ b/cmd/operator-sdk/run/cmd.go @@ -43,14 +43,22 @@ type runCmd struct { localArgs runLocalArgs } +// checkRunType ensures exactly one run type has been selected. +func (c *runCmd) checkRunType() error { + if c.olm && c.local || !c.olm && !c.local { + return errors.New("exactly one run-type flag must be set: --olm, --local") + } + return nil +} + func NewCmd() *cobra.Command { c := &runCmd{} cmd := &cobra.Command{ Use: "run", Short: "Run an Operator in a variety of environments", RunE: func(cmd *cobra.Command, args []string) error { - if c.olm && c.local || !c.olm && !c.local { - return errors.New("exactly one run-type flag must be set: --olm, --local") + if err := c.checkRunType(); err != nil { + return err } projutil.MustInProjectRoot() @@ -94,7 +102,7 @@ func NewCmd() *cobra.Command { "The namespace where the operator watches for changes.") // 'run --olm' and related flags. - cmd.Flags().BoolVar(&c.olm, "olm", true, + cmd.Flags().BoolVar(&c.olm, "olm", false, "The operator to be run will be managed by OLM in a cluster. "+ "Cannot be set with another run-type flag") c.olmArgs.AddToFlagSet(cmd.Flags()) diff --git a/internal/scaffold/ansible/entrypoint.go b/internal/scaffold/ansible/entrypoint.go index e960abed1dd..b993e994cfd 100644 --- a/internal/scaffold/ansible/entrypoint.go +++ b/internal/scaffold/ansible/entrypoint.go @@ -45,5 +45,5 @@ if ! whoami &>/dev/null; then fi fi -exec ${OPERATOR} run ansible --watches-file=/opt/ansible/watches.yaml $@ +exec ${OPERATOR} exec-entrypoint ansible --watches-file=/opt/ansible/watches.yaml $@ ` diff --git a/internal/scaffold/helm/entrypoint.go b/internal/scaffold/helm/entrypoint.go index 0ee9518d57d..6c5a771e1a3 100644 --- a/internal/scaffold/helm/entrypoint.go +++ b/internal/scaffold/helm/entrypoint.go @@ -46,5 +46,5 @@ if ! whoami &>/dev/null; then fi cd $HOME -exec ${OPERATOR} run helm --watches-file=$HOME/watches.yaml $@ +exec ${OPERATOR} exec-entrypoint helm --watches-file=$HOME/watches.yaml $@ ` From 3d9c89f38c597403404d13ce58d5047a01666763 Mon Sep 17 00:00:00 2001 From: Eric Stroczynski Date: Tue, 21 Jan 2020 11:44:46 -0800 Subject: [PATCH 11/11] fix docs --- doc/cli/operator-sdk_cleanup.md | 2 +- doc/cli/operator-sdk_run.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/cli/operator-sdk_cleanup.md b/doc/cli/operator-sdk_cleanup.md index 58cd26f3ce7..9ddde0d5996 100644 --- a/doc/cli/operator-sdk_cleanup.md +++ b/doc/cli/operator-sdk_cleanup.md @@ -15,7 +15,7 @@ operator-sdk cleanup [flags] ``` --kubeconfig string The file path to kubernetes configuration file. Defaults to location specified by $KUBECONFIG, or to default file rules if not set --namespace string The namespace where the operator watches for changes. - --olm The operator to be run will be managed by OLM in a cluster. Cannot be set with another run-type flag (default true) + --olm The operator to be cleaned up is managed by OLM in a cluster. Cannot be set with another cleanup-type flag (default true) --manifests string [olm only] Directory containing package manifest and operator bundles. --operator-version string [olm only] Version of operator to deploy --install-mode string [olm only] InstallMode to create OperatorGroup with. Format: InstallModeType=[ns1,ns2[, ...]] diff --git a/doc/cli/operator-sdk_run.md b/doc/cli/operator-sdk_run.md index 93a565eabb8..06d6380634e 100644 --- a/doc/cli/operator-sdk_run.md +++ b/doc/cli/operator-sdk_run.md @@ -15,7 +15,7 @@ operator-sdk run [flags] ``` --kubeconfig string The file path to kubernetes configuration file. Defaults to location specified by $KUBECONFIG, or to default file rules if not set --namespace string The namespace where the operator watches for changes. - --olm The operator to be run will be managed by OLM in a cluster. Cannot be set with another run-type flag (default true) + --olm The operator to be run will be managed by OLM in a cluster. Cannot be set with another run-type flag --manifests string [olm only] Directory containing package manifest and operator bundles. --operator-version string [olm only] Version of operator to deploy --install-mode string [olm only] InstallMode to create OperatorGroup with. Format: InstallModeType=[ns1,ns2[, ...]]