// Module included in the following assemblies:
// * updating/updating_a_cluster/updating_disconnected_cluster/disconnected-update-osus.adoc

:_mod-docs-content-type: PROCEDURE
[id="update-service-install-cli_{context}"]
= Installing the OpenShift Update Service Operator by using the CLI

You can use the OpenShift CLI (`oc`) to install the OpenShift Update Service Operator.

.Procedure

. Create a namespace for the OpenShift Update Service Operator:

.. Create a `Namespace` object YAML file, for example, `update-service-namespace.yaml`, for the OpenShift Update Service Operator:
+
[source,yaml]
----
apiVersion: v1
kind: Namespace
metadata:
  name: openshift-update-service
  annotations:
    openshift.io/node-selector: ""
  labels:
    openshift.io/cluster-monitoring: "true" <1>
----
<1> Set the `openshift.io/cluster-monitoring` label to enable Operator-recommended cluster monitoring on this namespace.

.. Create the namespace:
+
[source,terminal]
----
$ oc create -f <filename>.yaml
----
+
For example:
+
[source,terminal]
----
$ oc create -f update-service-namespace.yaml
----

. Install the OpenShift Update Service Operator by creating the following objects:

.. Create an `OperatorGroup` object YAML file, for example, `update-service-operator-group.yaml`:
+
[source,yaml]
----
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
  name: update-service-operator-group
  namespace: openshift-update-service
spec:
  targetNamespaces:
  - openshift-update-service
----

.. Create an `OperatorGroup` object:
+
[source,terminal]
----
$ oc -n openshift-update-service create -f <filename>.yaml
----
+
For example:
+
[source,terminal]
----
$ oc -n openshift-update-service create -f update-service-operator-group.yaml
----

.. Create a `Subscription` object YAML file, for example, `update-service-subscription.yaml`:
+
.Example Subscription
[source,yaml]
----
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
  name: update-service-subscription
  namespace: openshift-update-service
spec:
  channel: v1
  installPlanApproval: "Automatic"
  source: "redhat-operators" <1>
  sourceNamespace: "openshift-marketplace"
  name: "cincinnati-operator"
----
<1> Specify the name of the catalog source that provides the Operator. For clusters that do not use a custom Operator Lifecycle Manager (OLM), specify `redhat-operators`. If your {product-title} cluster is installed in a disconnected environment, specify the name of the `CatalogSource` object created when you configured Operator Lifecycle Manager (OLM).

.. Create the `Subscription` object:
+
[source,terminal]
----
$ oc create -f <filename>.yaml
----
+
For example:
+
[source,terminal]
----
$ oc -n openshift-update-service create -f update-service-subscription.yaml
----
+
The OpenShift Update Service Operator is installed to the `openshift-update-service` namespace and targets the `openshift-update-service` namespace.

. Verify the Operator installation:
+
[source,terminal]
----
$ oc -n openshift-update-service get clusterserviceversions
----
+
.Example output
[source,terminal]
----
NAME                             DISPLAY                    VERSION   REPLACES   PHASE
update-service-operator.v4.6.0   OpenShift Update Service   4.6.0                Succeeded
...
----
+
If the OpenShift Update Service Operator is listed, the installation was successful. The version number might be different than shown.
