// Module included in the following assemblies:
//
// * hardware_enablement/psap-node-feature-discovery-operator.adoc

:_mod-docs-content-type: PROCEDURE
[id="installing-the-node-feature-discovery-operator_{context}"]
= Installing the Node Feature Discovery Operator

The Node Feature Discovery (NFD) Operator orchestrates all resources needed to run the NFD daemon set. As a cluster administrator, you can install the NFD Operator by using the {product-title} CLI or the web console.

[id="install-operator-cli_{context}"]
== Installing the NFD Operator using the CLI

As a cluster administrator, you can install the NFD Operator using the CLI.

.Prerequisites

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

.Procedure

. Create a namespace for the NFD Operator.

.. Create the following `Namespace` custom resource (CR) that defines the `openshift-nfd` namespace, and then save the YAML in the `nfd-namespace.yaml` file. Set `cluster-monitoring` to `"true"`.
+
[source,yaml]
----
apiVersion: v1
kind: Namespace
metadata:
  name: openshift-nfd
  labels:
    name: openshift-nfd
    openshift.io/cluster-monitoring: "true"
----

.. Create the namespace by running the following command:
+
[source,terminal]
----
$ oc create -f nfd-namespace.yaml
----

. Install the NFD Operator in the namespace you created in the previous step by creating the following objects:

.. Create the following `OperatorGroup` CR and save the YAML in the `nfd-operatorgroup.yaml` file:
+
[source,yaml]
----
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
  generateName: openshift-nfd-
  name: openshift-nfd
  namespace: openshift-nfd
spec:
  targetNamespaces:
  - openshift-nfd
----

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

.. Create the following `Subscription` CR and save the YAML in the `nfd-sub.yaml` file:
+
.Example Subscription
[source,yaml]
----
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
  name: nfd
  namespace: openshift-nfd
spec:
  channel: "stable"
  installPlanApproval: Automatic
  name: nfd
  source: redhat-operators
  sourceNamespace: openshift-marketplace
----

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

.. Change to the `openshift-nfd` project:
+
[source,terminal]
----
$ oc project openshift-nfd
----

.Verification

* To verify that the Operator deployment is successful, run:
+
[source,terminal]
----
$ oc get pods
----
+
.Example output
[source,terminal]
----
NAME                                      READY   STATUS    RESTARTS   AGE
nfd-controller-manager-7f86ccfb58-vgr4x   2/2     Running   0          10m
----
+
A successful deployment shows a `Running` status.

[id="install-operator-web-console_{context}"]
== Installing the NFD Operator using the web console

As a cluster administrator, you can install the NFD Operator using the web console.

.Procedure

. In the {product-title} web console, click *Ecosystem* -> *Software Catalog*.

. Choose *Node Feature Discovery* from the list of available Operators, and then click *Install*.

. On the *Install Operator* page, select *A specific namespace on the cluster*, and then click *Install*. You do not need to create a namespace because it is created for you.

.Verification

To verify that the NFD Operator installed successfully:

. Navigate to the *Ecosystem* -> *Installed Operators* page.
. Ensure that *Node Feature Discovery* is listed in the *openshift-nfd* project with a *Status* of *InstallSucceeded*.
+
[NOTE]
====
During installation an Operator might display a *Failed* status. If the installation later succeeds with an *InstallSucceeded* message, you can ignore the *Failed* message.
====

.Troubleshooting

If the Operator does not appear as installed, troubleshoot further:

. Navigate to the *Ecosystem* -> *Installed Operators* page and inspect the *Operator Subscriptions* and *Install Plans* tabs for any failure or errors under *Status*.
. Navigate to the *Workloads* -> *Pods* page and check the logs for pods in the `openshift-nfd` project.
