2020-04-24 00:08:38 -04:00
|
|
|
// Module included in the following assemblies:
|
|
|
|
|
//
|
|
|
|
|
// * operators/operator_sdk/osdk-cli-reference.adoc
|
2018-11-20 09:27:37 -05:00
|
|
|
|
2020-04-24 00:08:38 -04:00
|
|
|
[id="osdk-cli-reference-run_{context}"]
|
|
|
|
|
= run
|
2018-11-20 09:27:37 -05:00
|
|
|
|
2020-04-24 00:08:38 -04:00
|
|
|
The `operator-sdk run` command provides options that can launch the Operator in
|
|
|
|
|
various environments.
|
2018-11-20 09:27:37 -05:00
|
|
|
|
2020-04-24 00:08:38 -04:00
|
|
|
.`run` arguments
|
2018-11-20 09:27:37 -05:00
|
|
|
[options="header",cols="1,3"]
|
|
|
|
|
|===
|
|
|
|
|
|Arguments |Description
|
|
|
|
|
|
|
|
|
|
|`--kubeconfig` (string)
|
|
|
|
|
|The file path to a Kubernetes configuration file. Defaults: `$HOME/.kube/config`
|
|
|
|
|
|
2020-04-24 00:08:38 -04:00
|
|
|
|`--local`
|
|
|
|
|
|The Operator is run locally by building the Operator binary
|
|
|
|
|
with the ability to access a Kubernetes cluster using a `kubeconfig` file.
|
|
|
|
|
|
2018-11-20 09:27:37 -05:00
|
|
|
|`--namespace` (string)
|
|
|
|
|
|The namespace where the Operator watches for changes. Default: `default`
|
|
|
|
|
|
|
|
|
|
|`--operator-flags`
|
2020-04-24 00:08:38 -04:00
|
|
|
|Flags that the local Operator may need. Example: `--flag1 value1 --flag2=value2`.
|
|
|
|
|
For use with the `--local` flag only.
|
2018-11-20 09:27:37 -05:00
|
|
|
|
|
|
|
|
|`-h, --help`
|
|
|
|
|
|Usage help output.
|
|
|
|
|
|===
|
|
|
|
|
|
2020-04-24 00:08:38 -04:00
|
|
|
[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.
|
|
|
|
|
|
2020-07-31 16:19:58 -06:00
|
|
|
For example:
|
|
|
|
|
|
|
|
|
|
[source,terminal]
|
2018-11-20 09:27:37 -05:00
|
|
|
----
|
2020-04-24 00:08:38 -04:00
|
|
|
$ operator-sdk run --local \
|
2018-11-20 09:27:37 -05:00
|
|
|
--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:
|
|
|
|
|
|
2020-07-31 16:19:58 -06:00
|
|
|
[source,terminal]
|
2018-11-20 09:27:37 -05:00
|
|
|
----
|
2020-04-24 00:08:38 -04:00
|
|
|
$ operator-sdk run --local --operator-flags "--resync-interval 10"
|
2018-11-20 09:27:37 -05:00
|
|
|
----
|
|
|
|
|
|
|
|
|
|
If you are planning on using a different namespace than the default, use the
|
2020-04-24 00:08:38 -04:00
|
|
|
`--namespace` flag to change where the Operator is watching for Custom Resources
|
|
|
|
|
(CRs) to be created:
|
2018-11-20 09:27:37 -05:00
|
|
|
|
2020-07-31 16:19:58 -06:00
|
|
|
[source,terminal]
|
2018-11-20 09:27:37 -05:00
|
|
|
----
|
2020-04-24 00:08:38 -04:00
|
|
|
$ operator-sdk run --local --namespace "testing"
|
2018-11-20 09:27:37 -05:00
|
|
|
----
|
|
|
|
|
|
|
|
|
|
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.
|