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

:_mod-docs-content-type: PROCEDURE
[id="nfd-rules-using_{context}"]
= Using the NodeFeatureRule custom resource

Create a `NodeFeatureRule` object to label nodes if a set of rules match the conditions.

.Procedure

. Create a custom resource file named `nodefeaturerule.yaml` that contains the following text:
+
[source,yaml]
----
apiVersion: nfd.openshift.io/v1
kind: NodeFeatureRule
metadata:
  name: example-rule
spec:
  rules:
    - name: "example rule"
      labels:
        "example-custom-feature": "true"
      # Label is created if all of the rules below match
      matchFeatures:
        # Match if "veth" kernel module is loaded
        - feature: kernel.loadedmodule
          matchExpressions:
            veth: {op: Exists}
        # Match if any PCI device with vendor 8086 exists in the system
        - feature: pci.device
          matchExpressions:
            vendor: {op: In, value: ["8086"]}
----
+
This custom resource specifies that labelling occurs when the `veth` module is loaded and any PCI device with vendor code `8086` exists in the cluster.

. Apply the `nodefeaturerule.yaml` file to your cluster by running the following command:
+
[source,terminal]
----
$ oc apply -f https://raw.githubusercontent.com/kubernetes-sigs/node-feature-discovery/v0.13.6/examples/nodefeaturerule.yaml
----
The example applies the feature label on nodes with the `veth` module loaded and any PCI device with vendor code `8086` exists.
+
[NOTE]
====
A relabeling delay of up to 1 minute might occur.
====