16.4. Node Observability Operator 스크립팅
스크립팅을 사용하면 현재 Node Observability Operator 및 Node Observability Agent를 사용하여 사전 구성된 bash 스크립트를 실행할 수 있습니다.
이 스크립트는 CPU 부하, 메모리 부족, 작업자 노드 문제와 같은 주요 지표를 모니터링합니다. 또한 sar 보고서 및 사용자 지정 성능 메트릭을 수집합니다.
16.4.1. 스크립팅을 위한 노드 Observability 사용자 정의 리소스 생성 링크 복사링크가 클립보드에 복사되었습니다!
스크립팅을 실행하기 전에 NodeObservability CR(사용자 정의 리소스)을 생성하고 실행해야 합니다. NodeObservability CR을 실행하면 nodeSelector 레이블과 일치하는 컴퓨팅 노드에서 에이전트가 스크립팅 모드로 활성화됩니다.
사전 요구 사항
- Node Observability Operator가 설치되어 있습니다.
-
OpenShift CLI(
oc)가 설치되어 있습니다. -
cluster-admin권한이 있는 클러스터에 액세스할 수 있습니다.
프로세스
다음 명령을 실행하여 OpenShift Container Platform 클러스터에 로그인합니다.
$ oc login -u kubeadmin https://<host_name>:6443다음 명령을 실행하여
node-observability-operator네임스페이스로 전환합니다.$ oc project node-observability-operator다음 콘텐츠가 포함된
nodeobservability.yaml파일을 생성합니다.apiVersion: nodeobservability.olm.openshift.io/v1alpha2 kind: NodeObservability metadata: name: cluster1 spec: nodeSelector: kubernetes.io/hostname: <node_hostname>2 type: scripting3 다음 명령을 실행하여
NodeObservabilityCR을 생성합니다.$ oc apply -f nodeobservability.yaml출력 예
nodeobservability.olm.openshift.io/cluster created다음 명령을 실행하여
NodeObservabilityCR의 상태를 검토합니다.$ oc get nob/cluster -o yaml | yq '.status.conditions'출력 예
conditions: conditions: - lastTransitionTime: "2022-07-05T07:33:54Z" message: 'DaemonSet node-observability-ds ready: true NodeObservabilityScripting ready: true' reason: Ready status: "True" type: Ready이유는Ready이고상태가"True"인 경우NodeObservabilityCR 실행이 완료됩니다.
16.4.2. 노드 Observability Operator 스크립팅 구성 링크 복사링크가 클립보드에 복사되었습니다!
사전 요구 사항
- Node Observability Operator가 설치되어 있습니다.
-
NodeObservabilityCR(사용자 정의 리소스)을 생성했습니다. -
cluster-admin권한이 있는 클러스터에 액세스할 수 있습니다.
프로세스
다음 콘텐츠가 포함된
nodeobservabilityrun-script.yaml파일을 생성합니다.apiVersion: nodeobservability.olm.openshift.io/v1alpha2 kind: NodeObservabilityRun metadata: name: nodeobservabilityrun-script namespace: node-observability-operator spec: nodeObservabilityRef: name: cluster type: scripting중요다음 스크립트만 요청할 수 있습니다.
-
metrics.sh -
network-metrics.sh(monitor.sh사용)
-
다음 명령으로
NodeObservabilityRun리소스를 생성하여 스크립팅을 트리거합니다.$ oc apply -f nodeobservabilityrun-script.yaml다음 명령을 실행하여
NodeObservabilityRun스크립팅의 상태를 검토합니다.$ oc get nodeobservabilityrun nodeobservabilityrun-script -o yaml | yq '.status.conditions'출력 예
Status: Agents: Ip: 10.128.2.252 Name: node-observability-agent-n2fpm Port: 8443 Ip: 10.131.0.186 Name: node-observability-agent-wcc8p Port: 8443 Conditions: Conditions: Last Transition Time: 2023-12-19T15:10:51Z Message: Ready to start profiling Reason: Ready Status: True Type: Ready Last Transition Time: 2023-12-19T15:11:01Z Message: Profiling query done Reason: Finished Status: True Type: Finished Finished Timestamp: 2023-12-19T15:11:01Z Start Timestamp: 2023-12-19T15:10:51ZStatus가True이고Type이 완료되면 스크립팅이완료됩니다.다음 bash 스크립트를 실행하여 컨테이너의 루트 경로에서 스크립팅 데이터를 검색합니다.
#!/bin/bash RUN=$(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); do echo "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}"); do f="/${base_dir}/${p}" echo "copying ${f} to /tmp/${agent}/${p}" oc exec "${agent}" -c node-observability-agent -- cat ${f} > "/tmp/${agent}/${p}" done done