// Module included in the following assemblies:
//
// * nodes/nodes/eco-self-node-remediation-operator.adoc

:_mod-docs-content-type: PROCEDURE
[id="installing-self-node-remediation-operator-using-cli_{context}"]
= Installing the Self Node Remediation Operator by using the CLI

You can use the OpenShift CLI (`oc`) to install the Self Node Remediation Operator.

You can install the Self Node Remediation Operator in your own namespace or in the `openshift-operators` namespace.

To install the Operator in your own namespace, follow the steps in the procedure.

To install the Operator in the `openshift-operators` namespace, skip to step 3 of the procedure because the steps to create a new `Namespace` custom resource (CR) and an `OperatorGroup` CR are not required.

.Prerequisites

* Install the OpenShift CLI (`oc`).
* Log in as a user with `cluster-admin` privileges.

.Procedure

. Create a `Namespace` custom resource (CR) for the Self Node Remediation Operator:
.. Define the `Namespace` CR and save the YAML file, for example, `self-node-remediation-namespace.yaml`:
+
[source,yaml]
----
apiVersion: v1
kind: Namespace
metadata:
  name: self-node-remediation
----
.. To create the `Namespace` CR, run the following command:
+
[source,terminal]
----
$ oc create -f self-node-remediation-namespace.yaml
----

. Create an `OperatorGroup` CR:
.. Define the `OperatorGroup` CR and save the YAML file, for example, `self-node-remediation-operator-group.yaml`:
+
[source,yaml]
----
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
  name: self-node-remediation-operator
  namespace: self-node-remediation
----
.. To create the `OperatorGroup` CR, run the following command:
+
[source,terminal]
----
$ oc create -f self-node-remediation-operator-group.yaml
----

. Create a `Subscription` CR:
.. Define the `Subscription` CR and save the YAML file, for example, `self-node-remediation-subscription.yaml`:
+
[source,yaml]
----
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
    name: self-node-remediation-operator
    namespace: self-node-remediation <1>
spec:
    channel: stable
    installPlanApproval: Manual <2>
    name: self-node-remediation-operator
    source: redhat-operators
    sourceNamespace: openshift-marketplace
    package: self-node-remediation
----
<1> Specify the `Namespace` where you want to install the Self Node Remediation Operator. To install the Self Node Remediation Operator in the `openshift-operators` namespace, specify `openshift-operators` in the `Subscription` CR.
<2> 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.

.. To create the `Subscription` CR, run the following command:
+
[source,terminal]
----
$ oc create -f self-node-remediation-subscription.yaml
----

.Verification

. Verify that the installation succeeded by inspecting the CSV resource:
+
[source,terminal]
----
$ oc get csv -n self-node-remediation
----
+
.Example output
[source,terminal]
----
NAME                               DISPLAY                          VERSION   REPLACES   PHASE
self-node-remediation.v.0.4.0      Self Node Remediation Operator   v.0.4.0              Succeeded
----

. Verify that the Self Node Remediation Operator is up and running:
+
[source,terminal]
----
$ oc get deploy -n self-node-remediation
----
+
.Example output
[source,terminal]
----
NAME                                        READY   UP-TO-DATE   AVAILABLE   AGE
self-node-remediation-controller-manager    1/1     1            1           28h
----

. Verify that the Self Node Remediation Operator created the `SelfNodeRemediationConfig` CR:
+
[source,terminal]
----
$ oc get selfnoderemediationconfig -n self-node-remediation
----
+
.Example output
[source,terminal]
----
NAME                           AGE
self-node-remediation-config   28h
----
. Verify that each self node remediation pod is scheduled and running on each worker node:
+
[source,terminal]
----
$ oc get daemonset -n self-node-remediation
----
+
.Example output
[source,terminal]
----
NAME                      DESIRED  CURRENT  READY  UP-TO-DATE  AVAILABLE  NODE SELECTOR  AGE
self-node-remediation-ds  3        3        3      3           3          <none>         28h
----
+
[NOTE]
====
This command is unsupported for the control plane nodes.
====