4장. 서비스를 모니터링하도록 Cluster Observability Operator 구성
COO(Cluster Observability Operator)에서 관리하는 모니터링 스택을 구성하여 서비스에 대한 메트릭을 모니터링할 수 있습니다.
서비스 모니터링을 테스트하려면 다음 단계를 따르십시오.
- 서비스 엔드포인트를 정의하는 샘플 서비스를 배포합니다.
-
COO에서 서비스를 모니터링할 방법을 지정하는
ServiceMonitor
오브젝트를 생성합니다. -
MonitoringStack
오브젝트를 생성하여ServiceMonitor
오브젝트를 검색합니다.
4.1. Cluster Observability Operator의 샘플 서비스 배포
이 구성은 사용자 정의 ns1-coo
프로젝트에 prometheus-coo-example-app
이라는 샘플 서비스를 배포합니다. 서비스는 사용자 정의 버전
지표를 노출합니다.
사전 요구 사항
-
cluster-admin
클러스터 역할의 사용자로 또는 네임스페이스에 대한 관리 권한이 있는 사용자로 클러스터에 액세스할 수 있습니다.
프로세스
네임스페이스, 배포 및 서비스에 대한 다음 구성 세부 정보가 포함된
prometheus-coo-example-app.yaml
이라는 YAML 파일을 생성합니다.apiVersion: v1 kind: Namespace metadata: name: ns1-coo --- apiVersion: apps/v1 kind: Deployment metadata: labels: app: prometheus-coo-example-app name: prometheus-coo-example-app namespace: ns1-coo spec: replicas: 1 selector: matchLabels: app: prometheus-coo-example-app template: metadata: labels: app: prometheus-coo-example-app spec: containers: - image: ghcr.io/rhobs/prometheus-example-app:0.4.2 imagePullPolicy: IfNotPresent name: prometheus-coo-example-app --- apiVersion: v1 kind: Service metadata: labels: app: prometheus-coo-example-app name: prometheus-coo-example-app namespace: ns1-coo spec: ports: - port: 8080 protocol: TCP targetPort: 8080 name: web selector: app: prometheus-coo-example-app type: ClusterIP
- 파일을 저장합니다.
다음 명령을 실행하여 클러스터에 구성을 적용합니다.
$ oc apply -f prometheus-coo-example-app.yaml
다음 명령을 실행하고 출력을 관찰하여 포드가 실행 중인지 확인합니다.
$ oc -n ns1-coo get pod
출력 예
NAME READY STATUS RESTARTS AGE prometheus-coo-example-app-0927545cb7-anskj 1/1 Running 0 81m