// Module included in the following assemblies:
// * edge_computing/image-based-upgrade/cnf-preparing-for-image-based-upgrade.adoc

:_mod-docs-content-type: PROCEDURE
[id="cnf-image-based-upgrade-installing-lifecycle-agent-using-cli_{context}"]
= Installing the {lcao} by using the CLI

You can use the OpenShift CLI (`oc`) to install the {lcao}.

.Prerequisites

* You have installed the OpenShift CLI (`oc`).
* You have logged in as a user with `cluster-admin` privileges.

.Procedure

. Create a `Namespace` object YAML file for the {lcao}:
+
[source,yaml]
----
apiVersion: v1
kind: Namespace
metadata:
  name: openshift-lifecycle-agent
  annotations:
    workload.openshift.io/allowed: management
----

.. Create the `Namespace` CR by running the following command:
+
[source,terminal]
----
$ oc create -f <namespace_filename>.yaml
----

. Create an `OperatorGroup` object YAML file for the {lcao}:
+
[source,yaml]
----
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
  name: openshift-lifecycle-agent
  namespace: openshift-lifecycle-agent
spec:
  targetNamespaces:
  - openshift-lifecycle-agent
----

.. Create the `OperatorGroup` CR by running the following command:
+
[source,terminal]
----
$ oc create -f <operatorgroup_filename>.yaml
----

. Create a `Subscription` CR for the {lcao}:
+
[source,yaml]
----
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
  name: openshift-lifecycle-agent-subscription
  namespace: openshift-lifecycle-agent
spec:
  channel: "stable"
  name: lifecycle-agent
  source: redhat-operators
  sourceNamespace: openshift-marketplace
----

.. Create the `Subscription` CR by running the following command:
+
[source,terminal]
----
$ oc create -f <subscription_filename>.yaml
----

.Verification

. To verify that the installation succeeded, inspect the CSV resource by running the following command:
+
[source,terminal]
----
$ oc get csv -n openshift-lifecycle-agent
----
+
.Example output
[source,terminal,subs="attributes+"]
----
NAME                              DISPLAY                     VERSION               REPLACES                           PHASE
lifecycle-agent.v{product-version}.0           Openshift Lifecycle Agent   {product-version}.0                Succeeded
----

. Verify that the {lcao} is up and running by running the following command:
+
[source,terminal]
----
$ oc get deploy -n openshift-lifecycle-agent
----

+
.Example output
[source,terminal]
----
NAME                                 READY   UP-TO-DATE   AVAILABLE   AGE
lifecycle-agent-controller-manager   1/1     1            1           14s
----