1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-06 15:46:57 +01:00
Files
openshift-docs/modules/olm-installing-from-operatorhub-using-cli.adoc
2020-10-02 14:23:45 +00:00

151 lines
4.4 KiB
Plaintext

// Module included in the following assemblies:
//
// * operators/user/olm-installing-operators-in-namespace.adoc
// * operators/admin/olm-adding-operators-to-cluster.adoc
// * post_installation_configuration/preparing-for-users.adoc
ifeval::["{context}" == "olm-installing-operators-in-namespace"]
:olm-user:
endif::[]
[id="olm-installing-operator-from-operatorhub-using-cli_{context}"]
= Installing from OperatorHub using the CLI
Instead of using the {product-title} web console, you can install an Operator
from OperatorHub using the CLI. Use the `oc` command to create or update a
Subscription object.
.Prerequisites
ifndef::olm-user[]
- Access to an {product-title} cluster using an account with
ifdef::openshift-enterprise,openshift-webscale,openshift-origin[]
`cluster-admin` permissions.
endif::[]
ifdef::openshift-dedicated[]
`dedicated-admins-cluster` permissions.
endif::[]
endif::[]
ifdef::olm-user[]
- Access to an {product-title} cluster using an account with Operator installation
permissions.
endif::[]
- Install the `oc` command to your local system.
.Procedure
. View the list of Operators available to the cluster from OperatorHub:
+
[source,terminal]
----
$ oc get packagemanifests -n openshift-marketplace
----
+
.Example output
[source,terminal]
----
NAME CATALOG AGE
3scale-operator Red Hat Operators 91m
advanced-cluster-management Red Hat Operators 91m
amq7-cert-manager Red Hat Operators 91m
...
couchbase-enterprise-certified Certified Operators 91m
crunchy-postgres-operator Certified Operators 91m
mongodb-enterprise Certified Operators 91m
...
etcd Community Operators 91m
jaeger Community Operators 91m
kubefed Community Operators 91m
...
----
+
Note the CatalogSource for your desired Operator.
. Inspect your desired Operator to verify its supported InstallModes and available
Channels:
+
[source,terminal]
----
$ oc describe packagemanifests <operator_name> -n openshift-marketplace
----
. An OperatorGroup is an OLM resource that selects target namespaces in which to
generate required RBAC access for all Operators in the same namespace as the
OperatorGroup.
+
The namespace to which you subscribe the Operator must have an OperatorGroup
that matches the InstallMode of the Operator, 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:
+
[source,terminal]
----
$ 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:
+
[source,terminal]
----
$ oc apply -f sub.yaml
----
+
At this point, 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.