// Module included in the following assemblies:
//
// * security/cert_manager_operator/cert-manager-operator-install.adoc

:_mod-docs-content-type: PROCEDURE
[id="cert-manager-install-cli_{context}"]
= Installing the {cert-manager-operator} by using the CLI

[role="_abstract"]
You can install the {cert-manager-operator} by using the command-line interface(CLI).

.Prerequisites

* You have access to the cluster with `cluster-admin` privileges.

.Procedure

. Create a new project named `cert-manager-operator` by running the following command:
+
[source, terminal]
----
$ oc new-project cert-manager-operator
----

. Create an `OperatorGroup` object:

.. Create a YAML file, for example, `operatorGroup.yaml`, with the following content:
+
[source, yaml]
----
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
  name: openshift-cert-manager-operator
  namespace: cert-manager-operator
spec:
  targetNamespaces:
  - "cert-manager-operator"
----

.. For {cert-manager-operator} v1.15.0 or later, create a YAML file with the following content:
+
[source, yaml]
----
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
  name: openshift-cert-manager-operator
  namespace: cert-manager-operator
spec:
  targetNamespaces: []
  spec: {}
----
+
[NOTE]
====
Starting from {cert-manager-operator} version 1.15.0, it is recommended to install the Operator using the `AllNamespaces` OLM `installMode`. Older versions can continue using the `SingleNamespace` or `OwnNamespace` OLM `installMode`. Support for `SingleNamespace` and `OwnNamespace` will be deprecated in future versions.
====

.. Create the `OperatorGroup` object by running the following command:
+
[source, terminal]
----
$ oc create -f operatorGroup.yaml
----

. Create a `Subscription` object:

.. Create a YAML file, for example, `subscription.yaml`, that defines the `Subscription` object:
+
[source, yaml]
----
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
  name: openshift-cert-manager-operator
  namespace: cert-manager-operator
spec:
  channel: stable-v1
  name: openshift-cert-manager-operator
  source: redhat-operators
  sourceNamespace: openshift-marketplace
  installPlanApproval: Automatic
----

.. Create the `Subscription` object by running the following command:
+
[source, terminal]
----
$ oc create -f subscription.yaml
----

.Verification

. Verify that the OLM subscription is created by running the following command:
+
[source, terminal]
----
$ oc get subscription -n cert-manager-operator
----
+
.Example output
[source, terminal]
----
NAME                              PACKAGE                           SOURCE             CHANNEL
openshift-cert-manager-operator   openshift-cert-manager-operator   redhat-operators   stable-v1
----

. Verify whether the Operator is successfully installed by running the following command:
+
[source, terminal]
----
$ oc get csv -n cert-manager-operator
----
+
.Example output
[source, terminal]
----
NAME                            DISPLAY                                       VERSION   REPLACES                        PHASE
cert-manager-operator.v1.13.0   cert-manager Operator for Red Hat OpenShift   1.13.0    cert-manager-operator.v1.12.1   Succeeded
----

. Verify that the status {cert-manager-operator} is `Running` by running the following command:
+
[source, terminal]
----
$ oc get pods -n cert-manager-operator
----
+
.Example output
[source, terminal]
----
NAME                                                        READY   STATUS    RESTARTS   AGE
cert-manager-operator-controller-manager-695b4d46cb-r4hld   2/2     Running   0          7m4s
----

. Verify that the status of cert-manager pods is `Running` by running the following command:
+
[source, terminal]
----
$ oc get pods -n cert-manager
----
+
.Example output
[source, terminal]
----
NAME                                       READY   STATUS    RESTARTS   AGE
cert-manager-58b7f649c4-dp6l4              1/1     Running   0          7m1s
cert-manager-cainjector-5565b8f897-gx25h   1/1     Running   0          7m37s
cert-manager-webhook-9bc98cbdd-f972x       1/1     Running   0          7m40s
----
