// Module included in the following assemblies:
//
// * operators/user/olm-installing-operators-in-namespace.adoc
// * operators/admin/olm-adding-operators-to-cluster.adoc

ifeval::["{context}" == "olm-installing-operators-in-namespace"]
:olm-user:
endif::[]

:_content-type: PROCEDURE
[id="olm-installing-specific-version-cli_{context}"]
= Installing a specific version of an Operator

You can install a specific version of an Operator by setting the cluster service version (CSV) in 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::[]
endif::[]

ifdef::olm-user[]
- Access to an {product-title} cluster using an account with Operator installation permissions
endif::[]

- OpenShift CLI (`oc`) installed

.Procedure

. Create a `Subscription` object YAML file that subscribes a namespace to an Operator with a specific version by setting the `startingCSV` field. Set the `installPlanApproval` field to `Manual` to prevent the Operator from automatically upgrading if a later version exists in the catalog.
+
For example, the following `sub.yaml` file can be used to install the Red Hat Quay Operator specifically to version 3.4.0:
+
.Subscription with a specific starting Operator version
[source,yaml]
----
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
  name: quay-operator
  namespace: quay
spec:
  channel: quay-v3.4
  installPlanApproval: Manual <1>
  name: quay-operator
  source: redhat-operators
  sourceNamespace: openshift-marketplace
  startingCSV: quay-operator.v3.4.0 <2>
----
<1> Set the approval strategy to `Manual` in case your specified version is superseded by a later version in the catalog. This plan prevents an automatic upgrade to a later version and requires manual approval before the starting CSV can complete the installation.
<2> Set a specific version of an Operator CSV.

. Create the `Subscription` object:
+
[source,terminal]
----
$ oc apply -f sub.yaml
----

. Manually approve the pending install plan to complete the Operator installation.
