2019-02-22 08:49:56 -05:00
|
|
|
// Module included in the following assemblies:
|
|
|
|
|
//
|
2019-10-02 11:30:49 -04:00
|
|
|
// * cli_reference/openshift_cli/extending-cli-plugins.adoc
|
2019-02-22 08:49:56 -05:00
|
|
|
|
2023-10-30 08:48:20 -04:00
|
|
|
:_mod-docs-content-type: PROCEDURE
|
2019-05-13 08:55:00 +10:00
|
|
|
[id="cli-installing-plugins_{context}"]
|
2023-01-16 16:03:42 -05:00
|
|
|
= Installing and using CLI plugins
|
2019-02-22 08:49:56 -05:00
|
|
|
|
2023-06-21 11:11:14 -05:00
|
|
|
After you write a custom plugin for the
|
|
|
|
|
ifndef::openshift-rosa,openshift-dedicated[]
|
|
|
|
|
{product-title}
|
|
|
|
|
endif::openshift-rosa,openshift-dedicated[]
|
|
|
|
|
ifdef::openshift-rosa,openshift-dedicated[]
|
|
|
|
|
OpenShift
|
|
|
|
|
endif::openshift-rosa,openshift-dedicated[]
|
|
|
|
|
CLI, you must install
|
|
|
|
|
the plugin before use.
|
2019-02-22 08:49:56 -05:00
|
|
|
|
|
|
|
|
.Prerequisites
|
|
|
|
|
|
|
|
|
|
* You must have the `oc` CLI tool installed.
|
2023-01-16 16:03:42 -05:00
|
|
|
* You must have a CLI plugin file that begins with `oc-` or `kubectl-`.
|
2019-02-22 08:49:56 -05:00
|
|
|
|
|
|
|
|
.Procedure
|
|
|
|
|
|
2023-01-16 16:03:42 -05:00
|
|
|
. If necessary, update the plugin file to be executable.
|
2019-02-22 08:49:56 -05:00
|
|
|
+
|
2020-08-04 22:42:35 -04:00
|
|
|
[source,terminal]
|
2019-02-22 08:49:56 -05:00
|
|
|
----
|
|
|
|
|
$ chmod +x <plugin_file>
|
|
|
|
|
----
|
|
|
|
|
. Place the file anywhere in your `PATH`, such as `/usr/local/bin/`.
|
|
|
|
|
+
|
2020-08-04 22:42:35 -04:00
|
|
|
[source,terminal]
|
2019-02-22 08:49:56 -05:00
|
|
|
----
|
|
|
|
|
$ sudo mv <plugin_file> /usr/local/bin/.
|
|
|
|
|
----
|
2023-01-16 16:03:42 -05:00
|
|
|
. Run `oc plugin list` to make sure that the plugin is listed.
|
2019-02-22 08:49:56 -05:00
|
|
|
+
|
2020-08-04 22:42:35 -04:00
|
|
|
[source,terminal]
|
2019-02-22 08:49:56 -05:00
|
|
|
----
|
|
|
|
|
$ oc plugin list
|
2020-08-04 22:42:35 -04:00
|
|
|
----
|
|
|
|
|
+
|
|
|
|
|
.Example output
|
|
|
|
|
[source,terminal]
|
|
|
|
|
----
|
2023-01-16 16:03:42 -05:00
|
|
|
The following compatible plugins are available:
|
2019-02-22 08:49:56 -05:00
|
|
|
|
|
|
|
|
/usr/local/bin/<plugin_file>
|
|
|
|
|
----
|
|
|
|
|
+
|
2023-01-16 16:03:42 -05:00
|
|
|
If your plugin is not listed here, verify that the file begins with `oc-`
|
2019-02-22 08:49:56 -05:00
|
|
|
or `kubectl-`, is executable, and is on your `PATH`.
|
2023-01-16 16:03:42 -05:00
|
|
|
. Invoke the new command or option introduced by the plugin.
|
2019-02-22 08:49:56 -05:00
|
|
|
+
|
2023-01-16 16:03:42 -05:00
|
|
|
For example, if you built and installed the `kubectl-ns` plugin from the
|
|
|
|
|
link:https://github.com/kubernetes/sample-cli-plugin[Sample plugin repository],
|
2019-02-22 08:49:56 -05:00
|
|
|
you can use the following command to view the current namespace.
|
|
|
|
|
+
|
2020-08-04 22:42:35 -04:00
|
|
|
[source,terminal]
|
2019-02-22 08:49:56 -05:00
|
|
|
----
|
|
|
|
|
$ oc ns
|
|
|
|
|
----
|
|
|
|
|
+
|
2023-01-16 16:03:42 -05:00
|
|
|
Note that the command to invoke the plugin depends on the plugin file name.
|
|
|
|
|
For example, a plugin with the file name of `oc-foo-bar` is invoked by the `oc foo bar`
|
2019-02-22 08:49:56 -05:00
|
|
|
command.
|