노드 문제 감지기¶
Node Problem Detector는 줄여서 NPD라고 하며, Kubernetes 오픈소스 클러스터 노드 모니터링 플러그인으로 노드 장애 점검에 사용됩니다.
NPD 기능:
- 이벤트 정보를 생성해 APIServer에 보고합니다.
- 지표 정보를 감지해 Metrics로 출력합니다.
구성¶
사전 조건¶
- K8S 환경 설치
- DataKit 설치
NPD 설치¶
설치 문서를 참고할 수 있으며, 여기서는 yaml 방식으로 설치합니다.
-
관련 yaml 다운로드
-
실행
kubectl apply -f rbac.yaml
kubectl apply -f node-problem-detector-config.yaml
kubectl apply -f node-problem-detector.yaml
로그 이벤트 모드¶
기본 설치 후에는 추가 설정이 필요 없으며, Datakit은 기본적으로 Kubernetes 이벤트를 수집해 데이터 소스가 Kubernetes_events인 로그의 reason(tag)에 저장합니다.
지표 모드¶
이벤트 모드 외에도 NPD는 지표 출력도 지원합니다
준비 작업¶
DataKit에서 ServiceMonitor 활성화¶
Prometheus로 Pod/Service의 지표 자동 검색
다음은 ServiceMonitor 방식으로 NPD 지표 정보를 수집합니다
- node-problem-detector.yaml 조정
...
- name: node-problem-detector
command:
- /node-problem-detector
- --logtostderr
- --config.system-log-monitor=/config/kernel-monitor.json,/config/docker-monitor.json
- --address=0.0.0.0
- --prometheus-address=0.0.0.0
...
ports:
- containerPort: 20257
hostPort: 20257
name: man-port
npd-service.yaml생성
apiVersion: v1
kind: Service
metadata:
name: node-problem-detector
namespace: kube-system
labels:
app: node-problem-detector
spec:
selector:
app: node-problem-detector
ports:
- protocol: TCP
port: 20257
targetPort: 20257
name: metrics
npd-server-monitor.yaml생성
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: npd-server-metrics
labels:
app: node-problem-detector
namespace: kube-system
spec:
selector:
matchLabels:
app: node-problem-detector
endpoints:
- port: metrics
params:
measurement:
- node-problem-detector
- 실행
kubectl apply -f rbac.yaml
kubectl apply -f node-problem-detector-config.yaml
kubectl apply -f node-problem-detector.yaml
kubectl apply -f npd-service.yaml
kubectl apply -f npd-server-monitor.yaml
지표¶
problem_gauge¶
| 태그 | 설명 |
|---|---|
type="ConntrackFullProblem" |
노드 연결 추적 테이블 장애 |
| type="EmptyDirVolumeGroupStatusError" | 임시 볼륨 저장소 풀 장애 |
| type="MemoryProblem" | 노드 메모리 장애 |
| type="LocalPvVolumeGroupStatusError" | 노드의 영구 볼륨 저장소 풀 장애 |
| type="MountPointProblem" | 노드 마운트 지점 장애 |
| type="FDProblem" | 시스템 핵심 리소스인 FD 파일 핸들 수 장애 |
| type="DiskHung" | 노드 디스크에 I/O 정체가 있는지 여부 |
| type="DiskReadonly" | 노드 디스크가 읽기 전용인지 여부 |
| type="DiskProblem" | 노드 시스템 디스크 장애 |
| type="DiskSlow" | 노드 디스크에 느린 I/O 장애가 있는지 여부 |
| type="FrequentCRIRestart" | CRI가 자주 재시작됨 |
| type="FrequentDockerRestart" | Docker가 자주 재시작됨 |
| type="FrequentKubeletRestart" | Kubelet이 자주 재시작됨 |
| type="FrequentContainerdRestart" | Containerd가 자주 재시작됨 |
| type="NTPProblem" | ntpd 동기화 이상 |
| type="PIDProblem" | 시스템 핵심 리소스인 PID 프로세스 자원이 부족함 |
type="ResolvConfFileProblem" |
ResolvConf 설정 이상 |
| type="CNIProblem" | CNI(컨테이너 네트워크) 구성 요소 이상 |
| type="CRIProblem" | CRI(컨테이너 런타임 구성 요소)인 Docker 또는 Containerd의 실행 상태 이상 |
type="KUBEPROXYProblem" |
Kube-proxy 실행 이상 |
type="KUBELETProblem" |
Kubelet 상태 이상 |
| type="ScheduledEvent" | 노드에 호스트 예약 이벤트가 있는지 여부 |
| type="ProcessD" | 노드에 D 상태 프로세스가 있음 |
| type="ProcessZ" | 노드에 Z 상태 프로세스가 있음 |
로그¶
다음 목록에는 기본 설정에서 NPD가 감지할 수 있는 이벤트가 일부 포함되어 있으며, 이벤트는 데이터 소스가 Kubernetes_events인 로그에 기록됩니다:
| 원인 | 지속성 | 설명 |
|---|---|---|
DockerHung |
예 | Docker가 멈췄거나 응답하지 않음 |
ReadonlyFilesystem |
예 | 파일 시스템이 읽기 전용 모드로 마운트됨. 일반적으로 보호 메커니즘이며, 일부 경우 파일 시스템 손상을 방지합니다 |
CorruptDockerOverlay2 |
예 | Overlay2 저장 드라이버에 문제 있음 |
ContainerdUnhealthy |
예 | Containerd가 비정상 상태임 |
KubeletUnhealthy |
예 | Kubelet이 비정상 상태임 |
DockerUnhealthy |
예 | Docker가 비정상 상태임 |
OOMKilling |
아니오 | Kubernetes가 OOM으로 Pod를 종료함 |
TaskHung |
아니오 | 작업이 멈춤 |
UnregisterNetDevice |
아니오 | 네트워크 인터페이스 이상 |
KernelOops |
아니오 | 커널이 감지한 비정상 동작, 예: null 포인터, 장치 오류 |
Ext4Error |
아니오 | Ext4 파일 시스템 문제 |
Ext4Warning |
아니오 | Ext4 파일 시스템 문제 |
IOError |
아니오 | 버퍼 문제 |
MemoryReadError |
아니오 | 수정 가능한 메모리 오류이며, 자주 발생하면 메모리 하드웨어에 문제가 있을 수 있음 |
KubeletStart |
아니오 | Kubelet 시작, 자주 발생하면 Kubelet이 자주 재시작되는 것임 |
DockerStart |
아니오 | Docker 시작, 자주 발생하면 Docker가 자주 재시작되는 것임 |
ContainerdStart |
아니오 | Containerd 시작, 자주 발생하면 Containerd가 자주 재시작되는 것임 |
CorruptDockerImage |
아니오 | Docker registry가 사용하는 디렉터리가 비어 있지 않음 |
DockerContainerStartupFailure |
아니오 | Docker를 시작할 수 없음 |
ConntrackFull |
아니오 | 네트워크 연결 추적 수가 가득 차 NAT, 방화벽 등의 네트워크 기능에 영향을 줌 |
NTPIsDown |
아니오 | NTP 시간 동기화 이상 |