본문 바로가기
[GPUaaS]/GPUmgt

[NCP 실전] DCGM Exporter DaemonSet YAML 상세 해설

by METAVERSE STORY 2026. 1. 15.
반응형

 

 

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: dcgm-exporter
  namespace: monitoring
spec:
  selector:
    matchLabels:
      app: dcgm-exporter
  template:
    metadata:
      labels:
        app: dcgm-exporter
    spec:
      tolerations:
      - key: nvidia.com/gpu
        operator: Exists
        effect: NoSchedule
      containers:
      - name: dcgm-exporter
        image: nvcr.io/nvidia/k8s/dcgm-exporter:3.3.5-3.1.8
        ports:
        - containerPort: 9400
          name: metrics
        securityContext:
          privileged: true
        env:
        - name: DCGM_EXPORTER_LISTEN
          value: ":9400"
        volumeMounts:
        - name: pod-gpu-resources
          mountPath: /var/lib/kubelet/pod-resources
      volumes:
      - name: pod-gpu-resources
        hostPath:
          path: /var/lib/kubelet/pod-resources

 

 

🔍 DCGM Exporter DaemonSet YAML 상세 해설


1️⃣ apiVersion: apps/v1

 
apiVersion: apps/v1
  • DaemonSet 리소스의 API 버전
  • Kubernetes 1.16+에서 표준
  • NCP Kubernetes와 완전히 호환

2️⃣ kind: DaemonSet

 
kind: DaemonSet

의미

  • 각 노드당 1개 Pod를 자동 배포
  • 노드 추가 → Pod 자동 생성
  • 노드 삭제 → Pod 자동 제거

👉 GPU 오토스케일링 환경에서 필수


3️⃣ metadata (리소스 기본 정보)

 
metadata:
  name: dcgm-exporter
  namespace: monitoring
 
 

설명

  • name: DaemonSet 이름
  • namespace: Prometheus / Grafana와 같은 monitoring 네임스페이스

👉 모니터링 컴포넌트 관리용 네임스페이스 분리 (실무 권장)


4️⃣ spec.selector (DaemonSet과 Pod 연결 기준)

 
spec:
  selector:
    matchLabels:
      app: dcgm-exporter
 
 

역할

  • DaemonSet이 어떤 Pod를 관리할지 지정
  • template.metadata.labels와 반드시 동일해야 함

❗ 다르면 Pod 생성 안 됨


5️⃣ template.metadata.labels (Pod 라벨)

 
template:
  metadata:
    labels:
      app: dcgm-exporter
 
 

의미

  • 생성될 Pod의 라벨
  • Service / ServiceMonitor가 이 라벨을 기준으로 Pod를 찾음

👉 Prometheus 연동의 기준점


6️⃣ template.spec (Pod 실행 조건)

 
spec:

이 안에 GPU 노드에서만 실행되도록 하는 핵심 설정들이 들어 있음


7️⃣ tolerations (GPU 노드에 배포되도록 허용)

 
tolerations:
- key: nvidia.com/gpu
  operator: Exists
  effect: NoSchedule
 
 

왜 필요한가?

  • GPU 노드는 보통 이런 taint를 가짐:
 
nvidia.com/gpu=present:NoSchedule
  • 일반 Pod는 GPU 노드에 못 올라감
  • 이 toleration이 있어야 GPU 노드에 배포 가능

👉 없으면 Pod는 Pending 상태

 


8️⃣ containers (DCGM Exporter 컨테이너 정의)

 
containers:
- name: dcgm-exporter

설명

  • DaemonSet이 각 노드에서 실행할 컨테이너
  • 이름은 식별용

9️⃣ image (DCGM Exporter 이미지)

 
image: nvcr.io/nvidia/k8s/dcgm-exporter:3.3.5-3.1.8

의미

  • NVIDIA 공식 이미지 (NVIDIA Container Registry)
  • 3.3.5 → DCGM Exporter 버전
  • 3.1.8 → DCGM 라이브러리 버전

👉 Driver와의 호환성 검증된 버전


🔟 ports (메트릭 노출 포트)

 
ports:
- containerPort: 9400
  name: metrics
 
 

설명

  • Prometheus가 수집하는 포트
  • 기본 DCGM Exporter 포트 = 9400
  • name: metrics → Service / ServiceMonitor에서 참조

 


1️⃣1️⃣ securityContext.privileged: true

 
securityContext:
  privileged: true
 
 

매우 중요 ⭐⭐⭐⭐⭐

  • DCGM은 GPU 디바이스 파일 접근 필요
  • /dev/nvidia* 접근
  • 권한 없으면 메트릭 수집 불가

👉 NCP에서는 필수 옵션

 


1️⃣2️⃣ env: DCGM_EXPORTER_LISTEN

 
env:
- name: DCGM_EXPORTER_LISTEN
  value: ":9400"
 

의미

  • DCGM Exporter가 어디에서 대기할지
  • :9400 → 모든 인터페이스에서 9400 포트 리슨

👉 외부 Service가 접근 가능

 


1️⃣3️⃣ volumeMounts (kubelet GPU 리소스 접근)

 
volumeMounts:
- name: pod-gpu-resources
  mountPath: /var/lib/kubelet/pod-resources
 
 

왜 필요한가?

  • Kubernetes가 관리하는 GPU 할당 정보
  • 어떤 Pod가 GPU를 쓰는지 DCGM이 인식

👉 GPU Pod별 메트릭 수집 핵심

 


1️⃣4️⃣ volumes.hostPath (노드 파일 시스템 마운트)

 
volumes:
- name: pod-gpu-resources
  hostPath:
    path: /var/lib/kubelet/pod-resources
 
 

의미

  • 노드의 실제 디렉터리를 컨테이너에 마운트
  • kubelet이 생성하는 GPU 리소스 정보 위치

👉 Device Plugin과 연동되는 지점

 


🧠 이 YAML이 만들어내는 실제 결과

 
GPU 노드 1대  → dcgm-exporter Pod 1개
GPU 노드 5대  → dcgm-exporter Pod 5개
 
 
  • 노드 자동 추가 → 자동 배포
  • Prometheus 자동 수집
  • Grafana 자동 반영

 


⚠️ 이 YAML에서 빠지면 안 되는 TOP 3

항목 이유
DaemonSet 오토스케일링 대응
tolerations GPU 노드 배포
privileged GPU 메트릭 수집

🔑 핵심 한 문장

“이 DaemonSet은 ‘GPU 노드가 늘어나도 손댈 게 없는’
자동 GPU 모니터링을 만드는 최소 구성이다.”

 

 

반응형

댓글