// Module included in the following assemblies:
//
// * scalability_and_performance/node-observability-operator.adoc

:_mod-docs-content-type: PROCEDURE
[id="node-observability-scripting-cr_{context}"]
= Creating the Node Observability custom resource for scripting

[role="_abstract"]
You must create and run the `NodeObservability` custom resource (CR) before you run the scripting. When you run the `NodeObservability` CR, it enables the agent in scripting mode on the compute nodes matching the `nodeSelector` label. 

.Prerequisites
* You have installed the Node Observability Operator.
* You have installed the {oc-first}.
* You have access to the cluster with `cluster-admin` privileges.

.Procedure

. Log in to the {product-title} cluster by running the following command:
+
[source,terminal]
----
$ oc login -u kubeadmin https://<host_name>:6443
----

. Switch to the `node-observability-operator` namespace by running the following command:
+
[source,terminal]
----
$ oc project node-observability-operator
----

. Create a file named `nodeobservability.yaml` that contains the following content:
+
[source,yaml]
----
    apiVersion: nodeobservability.olm.openshift.io/v1alpha2
    kind: NodeObservability
    metadata:
      name: cluster
    spec:
      nodeSelector:
        kubernetes.io/hostname: <node_hostname>
      type: scripting
----
+
where:
+
`cluster`:: You must specify the name as `cluster` because there should be only one `NodeObservability` CR per cluster.
`<node_hostname>`:: Specify the nodes on which the Node Observability agent must be deployed.
`scripting`:: To deploy the agent in scripting mode, you must set the type to `scripting`.


. Create the `NodeObservability` CR by running the following command:
+
[source,terminal]
----
$ oc apply -f nodeobservability.yaml
----

+
.Example output
[source,terminal]
----
nodeobservability.olm.openshift.io/cluster created
----

. Review the status of the `NodeObservability` CR by running the following command:
+
[source,terminal]
----
$ oc get nob/cluster -o yaml | yq '.status.conditions'
----

+
.Example output
[source,terminal]
----
conditions:
  conditions:
  - lastTransitionTime: "2022-07-05T07:33:54Z"
    message: 'DaemonSet node-observability-ds ready: true NodeObservabilityScripting
      ready: true'
    reason: Ready
    status: "True"
    type: Ready
----

+
The `NodeObservability` CR run is completed when the `reason` is `Ready` and `status` is `"True"`.