// Module included in the following assemblies:
//
// * operators/operator_sdk/osdk-cli-reference.adoc

[id="osdk-cli-reference-run_{context}"]
= run

The `operator-sdk run` command provides options that can launch the Operator in
various environments.

.`run` arguments
[options="header",cols="1,3"]
|===
|Arguments |Description

|`--kubeconfig` (string)
|The file path to a Kubernetes configuration file. Defaults: `$HOME/.kube/config`

|`--local`
|The Operator is run locally by building the Operator binary
with the ability to access a Kubernetes cluster using a `kubeconfig` file.

|`--namespace` (string)
|The namespace where the Operator watches for changes. Default: `default`

|`--operator-flags`
|Flags that the local Operator may need. Example: `--flag1 value1 --flag2=value2`.
For use with the `--local` flag only.

|`-h, --help`
|Usage help output.
|===

[id="osdk-cli-reference-run-local_{context}"]
== --local

The `--local` flag launches the Operator on the local machine by building
the Operator binary with the ability to access a Kubernetes cluster using a
`kubeconfig` file.

For example:

[source,terminal]
----
$ operator-sdk run --local \
  --kubeconfig "mycluster.kubecfg" \
  --namespace "default" \
  --operator-flags "--flag1 value1 --flag2=value2"
----

The following example uses the default `kubeconfig`, the default namespace
environment variable, and passes in flags for the Operator. To use the Operator
flags, your Operator must know how to handle the option. For example, for an
Operator that understands the `resync-interval` flag:

[source,terminal]
----
$ operator-sdk run --local --operator-flags "--resync-interval 10"
----

If you are planning on using a different namespace than the default, use the
`--namespace` flag to change where the Operator is watching for Custom Resources
(CRs) to be created:

[source,terminal]
----
$ operator-sdk run --local --namespace "testing"
----

For this to work, your Operator must handle the `WATCH_NAMESPACE`
environment variable. This can be accomplished using the
link:https://github.com/operator-framework/operator-sdk/blob/89bf021063d18b6769bdc551ed08fc37027939d5/pkg/util/k8sutil/k8sutil.go#L140[utility function]
`k8sutil.GetWatchNamespace` in your Operator.
