Using the Node Observability Operator
The Node Observability Operator collects and stores CRI-O and Kubelet profiling or metrics from scripts of compute nodes.
With the Node Observability Operator, you can query the profiling data, enabling analysis of performance trends in CRI-O and Kubelet. It supports debugging performance-related issues and executing embedded scripts for network metrics by using the run field in the custom resource definition. To enable CRI-O and Kubelet profiling or scripting, you can configure the type field in the custom resource definition.
The Node Observability Operator is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.
For more information about the support scope of Red Hat Technology Preview features, see Technology Preview Features Support Scope.
Workflow of the Node Observability Operator
The following workflow outlines on how to query the profiling data using the Node Observability Operator:
- Install the Node Observability Operator in the OpenShift Container Platform cluster.
- Create a NodeObservability custom resource to enable the CRI-O profiling on the worker nodes of your choice.
- Run the profiling query to generate the profiling data.
Installing the Node Observability Operator
The Node Observability Operator is not installed in OpenShift Container Platform by default. You can install the Node Observability Operator by using the OpenShift Container Platform CLI or the web console.
Installing the Node Observability Operator using the CLI
You can install the Node Observability Operator by using the OpenShift CLI (oc).
Prerequisites
- You have installed the OpenShift CLI (oc).
- You have access to the cluster with
cluster-adminprivileges.
Procedure
-
Confirm that the Node Observability Operator is available by running the following command:
$ oc get packagemanifests -n openshift-marketplace node-observability-operatorExample outputNAME CATALOG AGEnode-observability-operator Red Hat Operators 9h -
Create the
node-observability-operatornamespace by running the following command:$ oc new-project node-observability-operator -
Create an
OperatorGroupobject YAML file:cat <<EOF | oc apply -f -apiVersion: operators.coreos.com/v1kind: OperatorGroupmetadata:name: node-observability-operatornamespace: node-observability-operatorspec:targetNamespaces: []EOF -
Create a
Subscriptionobject YAML file to subscribe a namespace to an Operator:cat <<EOF | oc apply -f -apiVersion: operators.coreos.com/v1alpha1kind: Subscriptionmetadata:name: node-observability-operatornamespace: node-observability-operatorspec:channel: alphaname: node-observability-operatorsource: redhat-operatorssourceNamespace: openshift-marketplaceEOF
Verification
-
View the install plan name by running the following command:
$ oc -n node-observability-operator get sub node-observability-operator -o yaml | yq '.status.installplan.name'Example outputinstall-dt54w -
Verify the install plan status by running the following command:
$ oc -n node-observability-operator get ip <install_plan_name> -o yaml | yq '.status.phase'<install_plan_name>is the install plan name that you obtained from the output of the previous command.Example outputCOMPLETE -
Verify that the Node Observability Operator is up and running:
$ oc get deploy -n node-observability-operatorExample outputNAME READY UP-TO-DATE AVAILABLE AGEnode-observability-operator-controller-manager 1/1 1 1 40h
Installing the Node Observability Operator using the web console
You can install the Node Observability Operator from the OpenShift Container Platform web console.
Prerequisites
- You have access to the cluster with
cluster-adminprivileges. - You have access to the OpenShift Container Platform web console.
Procedure
- Log in to the OpenShift Container Platform web console.
- In the Administrator’s navigation panel, select Ecosystem → Software Catalog.
- In the All items field, enter Node Observability Operator and select the Node Observability Operator tile.
- Click Install.
- On the Install Operator page, configure the following settings:
- In the Update channel area, click alpha.
- In the Installation mode area, click A specific namespace on the cluster.
- From the Installed Namespace list, select node-observability-operator from the list.
- In the Update approval area, select Automatic.
- Click Install.
Verification
- In the Administrator’s navigation panel, expand Ecosystem → Installed Operators.
- Verify that the Node Observability Operator is listed in the Operators list.
Requesting CRI-O and Kubelet profiling data using the Node Observability Operator
Creating a Node Observability custom resource to collect CRI-O and Kubelet profiling data.
Creating the Node Observability custom resource
You must create and run the NodeObservability custom resource (CR) before you run the profiling query. When you run the NodeObservability CR, it creates the necessary machine config and machine config pool CRs to enable the CRI-O profiling on the worker nodes matching the nodeSelector.
If CRI-O profiling is not enabled on the worker nodes, the NodeObservabilityMachineConfig resource gets created. Worker nodes matching the nodeSelector specified in NodeObservability CR restarts. This might take 10 or more minutes to complete.
Kubelet profiling is enabled by default.
The CRI-O unix socket of the node is mounted on the agent pod, which allows the agent to communicate with CRI-O to run the pprof request. Similarly, the kubelet-serving-ca certificate chain is mounted on the agent pod, which allows secure communication between the agent and node’s kubelet endpoint.
Prerequisites
- You have installed the Node Observability Operator.
- You have installed the OpenShift CLI (oc).
- You have access to the cluster with
cluster-adminprivileges.
Procedure
-
Log in to the OpenShift Container Platform CLI by running the following command:
$ oc login -u kubeadmin https://<HOSTNAME>:6443 -
Switch back to the
node-observability-operatornamespace by running the following command:$ oc project node-observability-operator -
Create a CR file named
nodeobservability.yamlthat contains the following text:apiVersion: nodeobservability.olm.openshift.io/v1alpha2kind: NodeObservabilitymetadata:name: clusterspec:nodeSelector:kubernetes.io/hostname: <node_hostname>type: crio-kubeletwhere:
cluster- You must specify the name as
clusterbecause there should be only oneNodeObservabilityCR per cluster. <node_hostname>- Specify the nodes on which the Node Observability agent must be deployed.
-
Run the
NodeObservabilityCR:oc apply -f nodeobservability.yamlExample outputnodeobservability.olm.openshift.io/cluster created -
Review the status of the
NodeObservabilityCR by running the following command:$ oc get nob/cluster -o yaml | yq '.status.conditions'Example outputconditions:conditions:- lastTransitionTime: "2022-07-05T07:33:54Z"message: 'DaemonSet node-observability-ds ready: true NodeObservabilityMachineConfigready: true'reason: Readystatus: "True"type: ReadyNodeObservabilityCR run is completed when the reason isReadyand the status isTrue.
Running the profiling query
To run the profiling query, you must create a NodeObservabilityRun resource. The profiling query is a blocking operation that fetches CRI-O and Kubelet profiling data for a duration of 30 seconds. After the profiling query is complete, you must retrieve the profiling data inside the container file system /run/node-observability directory. The lifetime of data is bound to the agent pod through the emptyDir volume, so you can access the profiling data while the agent pod is in the running status.
You can request only one profiling query at any point of time.
Prerequisites
- You have installed the Node Observability Operator.
- You have created the
NodeObservabilitycustom resource (CR). - You have access to the cluster with
cluster-adminprivileges.
Procedure
-
Create a
NodeObservabilityRunresource file namednodeobservabilityrun.yamlthat contains the following text:apiVersion: nodeobservability.olm.openshift.io/v1alpha2kind: NodeObservabilityRunmetadata:name: nodeobservabilityrunspec:nodeObservabilityRef:name: cluster -
Trigger the profiling query by running the
NodeObservabilityRunresource:$ oc apply -f nodeobservabilityrun.yaml -
Review the status of the
NodeObservabilityRunby running the following command:$ oc get nodeobservabilityrun nodeobservabilityrun -o yaml | yq '.status.conditions'Example outputconditions:- lastTransitionTime: "2022-07-07T14:57:34Z"message: Ready to start profilingreason: Readystatus: "True"type: Ready- lastTransitionTime: "2022-07-07T14:58:10Z"message: Profiling query donereason: Finishedstatus: "True"type: FinishedThe profiling query is complete once the status is
Trueand type isFinished. -
Retrieve the profiling data from the container’s
/run/node-observabilitypath by running the following bash script:for a in $(oc get nodeobservabilityrun nodeobservabilityrun -o yaml | yq .status.agents[].name); doecho "agent ${a}"mkdir -p "/tmp/${a}"for p in $(oc exec "${a}" -c node-observability-agent -- bash -c "ls /run/node-observability/*.pprof"); dof="$(basename ${p})"echo "copying ${f} to /tmp/${a}/${f}"oc exec "${a}" -c node-observability-agent -- cat "${p}" > "/tmp/${a}/${f}"donedone
Node Observability Operator scripting
Scripting allows you to run pre-configured bash scripts, using the current Node Observability Operator and Node Observability Agent.
These scripts monitor key metrics like CPU load, memory pressure, and worker node issues. They also collect sar reports and custom performance metrics.
Creating the Node Observability custom resource for scripting
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 OpenShift CLI (
oc). - You have access to the cluster with
cluster-adminprivileges.
Procedure
-
Log in to the OpenShift Container Platform cluster by running the following command:
$ oc login -u kubeadmin https://<host_name>:6443 -
Switch to the
node-observability-operatornamespace by running the following command:$ oc project node-observability-operator -
Create a file named
nodeobservability.yamlthat contains the following content:apiVersion: nodeobservability.olm.openshift.io/v1alpha2kind: NodeObservabilitymetadata:name: clusterspec:nodeSelector:kubernetes.io/hostname: <node_hostname>type: scriptingwhere:
cluster- You must specify the name as
clusterbecause there should be only oneNodeObservabilityCR 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
NodeObservabilityCR by running the following command:$ oc apply -f nodeobservability.yamlExample outputnodeobservability.olm.openshift.io/cluster created -
Review the status of the
NodeObservabilityCR by running the following command:$ oc get nob/cluster -o yaml | yq '.status.conditions'Example outputconditions:conditions:- lastTransitionTime: "2022-07-05T07:33:54Z"message: 'DaemonSet node-observability-ds ready: true NodeObservabilityScriptingready: true'reason: Readystatus: "True"type: ReadyThe
NodeObservabilityCR run is completed when thereasonisReadyandstatusis"True".
Configuring Node Observability Operator scripting
You can configure the Node Observability Operator to run pre-configured scripts for collecting metrics data from compute nodes.
Prerequisites
- You have installed the Node Observability Operator.
- You have created the
NodeObservabilitycustom resource (CR). - You have access to the cluster with
cluster-adminprivileges.
Procedure
-
Create a file named
nodeobservabilityrun-script.yamlthat contains the following content:apiVersion: nodeobservability.olm.openshift.io/v1alpha2kind: NodeObservabilityRunmetadata:name: nodeobservabilityrun-scriptnamespace: node-observability-operatorspec:nodeObservabilityRef:name: clustertype: scriptingwarningYou can request only the following scripts:
metrics.shnetwork-metrics.sh(usesmonitor.sh)
-
Trigger the scripting by creating the
NodeObservabilityRunresource with the following command:$ oc apply -f nodeobservabilityrun-script.yaml -
Review the status of the
NodeObservabilityRunscripting by running the following command:$ oc get nodeobservabilityrun nodeobservabilityrun-script -o yaml | yq '.status.conditions'Example outputStatus:Agents:Ip: 10.128.2.252Name: node-observability-agent-n2fpmPort: 8443Ip: 10.131.0.186Name: node-observability-agent-wcc8pPort: 8443Conditions:Conditions:Last Transition Time: 2023-12-19T15:10:51ZMessage: Ready to start profilingReason: ReadyStatus: TrueType: ReadyLast Transition Time: 2023-12-19T15:11:01ZMessage: Profiling query doneReason: FinishedStatus: TrueType: FinishedFinished Timestamp: 2023-12-19T15:11:01ZStart Timestamp: 2023-12-19T15:10:51ZThe scripting is complete once
StatusisTrueandTypeisFinished. -
Retrieve the scripting data from the root path of the container by running the following bash script:
#!/bin/bashRUN=$(oc get nodeobservabilityrun --no-headers | awk '{print $1}')for a in $(oc get nodeobservabilityruns.nodeobservability.olm.openshift.io/${RUN} -o json | jq .status.agents[].name); doecho "agent ${a}"agent=$(echo ${a} | tr -d "\"\'\`")base_dir=$(oc exec "${agent}" -c node-observability-agent -- bash -c "ls -t | grep node-observability-agent" | head -1)echo "${base_dir}"mkdir -p "/tmp/${agent}"for p in $(oc exec "${agent}" -c node-observability-agent -- bash -c "ls ${base_dir}"); dof="/${base_dir}/${p}"echo "copying ${f} to /tmp/${agent}/${p}"oc exec "${agent}" -c node-observability-agent -- cat ${f} > "/tmp/${agent}/${p}"donedone
Additional resources