1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 12:46:18 +01:00
Files
openshift-docs/modules/olm-installing-from-operatorhub-using-cli.adoc
Alex Dellapenta 3cc341810e Fix -n flag typo
2019-11-12 17:49:27 +00:00

128 lines
4.1 KiB
Plaintext

// Module included in the following assemblies:
//
// * operators/olm-adding-operators-to-cluster.adoc
[id="olm-installing-operator-from-operatorhub-using-cli_{context}"]
= Installing from the OperatorHub using the CLI
Instead of using the {product-title} web console, you can install an Operator
from the OperatorHub using the CLI. Use the `oc` command to create or update a
Subscription object.
.Prerequisites
- Access to an {product-title} cluster using an account with `cluster-admin`
permissions.
- Install the *oc* command to your local system.
.Procedure
. View the list of Operators available to the cluster from the OperatorHub.
+
----
$ oc get packagemanifests -n openshift-marketplace
NAME CATALOG AGE
3scale-operator Red Hat Operators 91m
amq-online Red Hat Operators 91m
amq-streams Red Hat Operators 91m
...
couchbase-enterprise-certified Certified Operators 91m
mariadb Certified Operators 91m
mongodb-enterprise Certified Operators 91m
...
etcd Community Operators 91m
jaeger Community Operators 91m
kubefed Community Operators 91m
...
----
+
Note the CatalogSource(s) for your desired Operator(s).
. Inspect your desired Operator to verify its supported InstallModes and available
Channels:
+
----
$ oc describe packagemanifests <operator_name> -n openshift-marketplace
----
. The namespace to which you subscribe the Operator must have an OperatorGroup
that matches the Operator's InstallMode, either the `AllNamespaces` or
`SingleNamespace` mode. If the Operator you intend to install uses the
`AllNamespaces`, then the `openshift-operators` namespace already has an
appropriate OperatorGroup in place.
+
However, if the Operator uses the `SingleNamespace` mode and you do not already
have an appropriate OperatorGroup in place, you must create one.
+
[NOTE]
====
The web console version of this procedure handles the creation of the
OperatorGroup and Subscription objects automatically behind the scenes for you
when choosing `SingleNamespace` mode.
====
.. Create an OperatorGroup object YAML file, for example `operatorgroup.yaml`:
+
.Example OperatorGroup
[source,yaml]
----
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
name: <operatorgroup_name>
namespace: <namespace>
spec:
targetNamespaces:
- <namespace>
----
.. Create the OperatorGroup object:
+
----
$ oc apply -f operatorgroup.yaml
----
. Create a Subscription object YAML file to subscribe a namespace to an Operator,
for example `sub.yaml`:
+
.Example Subscription
[source,yaml]
----
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: <operator_name>
namespace: openshift-operators <1>
spec:
channel: alpha
name: <operator_name> <2>
source: redhat-operators <3>
sourceNamespace: openshift-marketplace <4>
----
<1> For `AllNamespaces` InstallMode usage, specify the `openshift-operators`
namespace. Otherwise, specify the relevant single namespace for
`SingleNamespace` InstallMode usage.
<2> Name of the Operator to subscribe to.
<3> Name of the CatalogSource that provides the Operator.
<4> Namespace of the CatalogSource. Use `openshift-marketplace` for the default
OperatorHub CatalogSources.
. Create the Subscription object:
+
----
$ oc apply -f sub.yaml
----
+
At this point, the OLM is now aware of the selected Operator. A
ClusterServiceVersion (CSV) for the Operator should appear in the target
namespace, and APIs provided by the Operator should be available for creation.
.Additional resources
* To install custom Operators to a cluster using the OperatorHub, you must first
upload your Operator artifacts to Quay.io, then add your own `OperatorSource` to
your cluster. Optionally, you can add Secrets to your Operator to provide
authentication. After, you can manage the Operator in your cluster as you would
any other Operator. For these steps, see link:https://github.com/operator-framework/community-operators/blob/master/docs/testing-operators.md[Testing Operators].