GPU DRA บน Kubernetes: ย้ายออกจาก NVIDIA device plugin แบบครบทุกขั้นตอน¶
Dynamic Resource Allocation เป็น GA แล้วใน Kubernetes 1.351 ส่วน DRA driver สำหรับ GPU ของ NVIDIA ก็ออก v0.4.1 เมื่อ 2026-06-302 แปลว่า extended resource แบบ nvidia.com/gpu ที่ device plugin ใช้มาตั้งแต่ปี 2017 มีตัวแทนอย่างเป็นทางการแล้ว การย้ายไม่ง่าย เพราะ resource model คนละแบบเลย (ใช้ claim แทน extended resource) แต่ได้ของคุ้มจริง: allocate GPU แบบมีโครงสร้าง, รู้ topology ของ NVLink เอง และใช้ API ชุดเดียวคุมทั้ง MIG, MPS, time-slicing และ Multi-Node NVLink
โพสต์นี้คือเส้นทางย้ายทั้งหมด ติดตั้ง driver, เขียน claim ตัวแรก, ย้าย workload ทีละตัว และรัน device plugin คู่กับ DRA ไปจนย้ายเสร็จ
API เปลี่ยนไปยังไง¶
device plugin ประกาศ GPU เป็น extended resource บน node:
apiVersion: v1
kind: Pod
metadata:
name: train-llm
spec:
containers:
- name: trainer
resources:
limits:
nvidia.com/gpu: 2 # implicit: any 2 GPUs on a schedulable node
DRA เปลี่ยนมาใช้ ResourceClaim ที่ pod ต้องอ้างถึงตรง ๆ:
apiVersion: v1
kind: Pod
metadata:
name: train-llm
spec:
resourceClaims:
- name: gpu-claim
containers:
- name: trainer
resources:
claims:
- name: gpu-claim
---
apiVersion: resource.k8s.io/v1
kind: ResourceClaim
metadata:
name: gpu-claim
spec:
devices:
requests:
- name: gpu
deviceClassName: gpu.nvidia.com
count: 2
ตรงนี้เปลี่ยนไปสามเรื่อง:
- Pod ไม่ได้ขอ GPU ตรง ๆ แล้ว แต่อ้างชื่อ claim แทน
- claim บอกว่าอยากได้ device แบบไหน (ผ่าน
DeviceClass) ไม่ได้ใช้ node selector - scheduler เป็นคนเลือก node จาก device ที่ว่างและตรงเงื่อนไข ไม่ใช่ปล่อยให้ kubelet ประกาศ
nvidia.com/gpu: 8แล้วลุ้นเอา
ถ้า workload รันบน node เดียว ความต่างดูแค่เปลี่ยน syntax แต่พอเป็น Multi-Node NVLink, MIG หรือแชร์ GPU ข้าม pod ความต่างอยู่ที่โครงสร้างเลย หลายอย่างเขียนใน DRA ได้ แต่ device plugin API ไม่มีทางเขียนออกมาได้
Prerequisite ที่ข้ามไม่ได้¶
DRA เป็น alpha ใน K8s 1.26, beta ใน 1.31 และ stable (GA) ใน 1.351 เวอร์ชันของ driver กับ cluster ต้องไปด้วยกันได้:
- Cluster — Kubernetes 1.35 ขึ้นไป feature gate
DynamicResourceAllocationเปิดเป็น default ตั้งแต่ 1.35 ถ้าเป็น 1.32-1.34 ต้องเปิดเองบนkube-apiserver,kube-controller-manager,kube-schedulerและkubelet12 - GPU Operator — v25.10.0 ขึ้นไป ถ้าอยากให้ operator ติดตั้งให้ ตัว stable ล่าสุดคือ v26.3.3 (2026-06-25)3 ระวังไว้ว่า GPU Operator ยังติดตั้ง device plugin เป็น default ไม่ใช่ DRA driver ต้อง opt in เอง
- NVIDIA DRA driver — release ล่าสุดคือ v0.4.1 (2026-06-30) ใช้กับ Kubernetes 1.32 ขึ้นไป2
- NVIDIA Container Toolkit — v1.19.1 ขึ้นไป (Helm chart ของ DRA driver ดึงมาให้เป็น dependency อยู่แล้ว)
- Helm 3 — ใช้ติดตั้ง
- GPU node — hardware ชุดเดิม DRA ไม่ได้เปลี่ยนอะไรในเครื่อง แค่เปลี่ยนวิธีที่ cluster ประกาศ GPU ออกไป
ก่อนเริ่มให้รันเช็กก่อน:
kubectl version --short
helm version --short
nvidia-smi --query-gpu=driver_version --format=csv,noheader
ถ้า nvidia-smi เห็น driver และ kubectl version ได้ 1.35 ขึ้นไป ก็พร้อมแล้ว ถ้ายังอยู่ 1.32-1.34 ต้องเปิด feature gate ทั้ง cluster ก่อน
ขั้นที่ 1: ติดตั้ง NVIDIA DRA driver¶
chart อยู่ที่ oci://registry.k8s.io/dra-driver-nvidia/charts/dra-driver-nvidia-gpu2:
helm install dra-driver-nvidia-gpu \
oci://registry.k8s.io/dra-driver-nvidia/charts/dra-driver-nvidia-gpu \
--version 0.4.1 \
--namespace dra-driver-nvidia-gpu \
--create-namespace
chart นี้ติดตั้งสองอย่าง:
- DaemonSet
gpu-kubelet-plugin— chart ปิดไว้เป็น default เพราะ README ของโปรเจกต์ยังบอกว่า feature ฝั่ง allocate GPU มีไว้ "for exploration and demonstration"2 อยากใช้ต้อง opt in ด้วยgpuResourcesEnabled=true - DaemonSet
compute-domain-kubelet-plugin— support อย่างเป็นทางการ ตัวนี้คุม Multi-Node NVLink ผ่าน IMEX primitive2
ตอนนี้ปล่อย gpuResourcesEnabled=false (ค่า default ของ chart) ไว้ก่อน เปิดแค่ ComputeDomain plugin เป็นทางที่ปลอดภัยที่สุด DRA control plane พร้อมใช้ และ pod ที่รันอยู่ไม่โดนกระทบ
เช็กว่าติดตั้งเรียบร้อย:
ต้องเห็น DeviceClass ชื่อ gpu.nvidia.com ขึ้นมาในรายการ
ขั้นที่ 2: ปล่อยให้ device plugin รันต่อไป¶
ส่วนนี้บล็อกส่วนใหญ่ไม่พูดถึง: อย่าเพิ่ง uninstall device plugin รันคู่กันไปตลอดช่วงย้าย เพราะ:
- workload เดิมที่ขอ
nvidia.com/gpu: Nยังทำงานได้ปกติ ระหว่างที่ทยอยย้ายทีละตัว - ถ้าฝั่ง DRA มีปัญหา pod ก็ยัง schedule ได้ production ไม่พัง
- ลอง A/B test workload ใหม่บน DRA ได้ก่อนตัดสินใจย้ายจริง
สองระบบนี้ไม่ชนกันที่ระดับ API (extended resource กับ ResourceClaim เป็นคนละ API) แต่ใช้ GPU ชุดเดียวกันข้างใต้ ถ้าเปิด allocate GPU ใน DRA driver (gpuResourcesEnabled=true) ตอนที่ device plugin ยังประกาศ GPU อยู่ จะเจอ GPU โดนนับซ้ำ ทั้งสองระบบบอกว่า GPU ตัวเดียวกันว่าง pod สองตัวลงไปที่ตัวเดียวกัน แล้วแย่ง memory กันเอง
เพราะฉะนั้นให้ device plugin รันต่อ และปิด allocate GPU ใน DRA driver ไว้ หลักของการย้ายคือ "ขึ้น claim ก่อน ค่อยถอด extended resource ทีหลังสุด"
ขั้นที่ 3: เขียน claim ตัวแรก¶
เริ่มจากเคสที่ง่ายที่สุด คือ container ตัวเดียวที่ขอ GPU เต็มหนึ่งตัว:
apiVersion: resource.k8s.io/v1
kind: ResourceClaimTemplate
metadata:
name: single-gpu-claim
spec:
devices:
requests:
- name: gpu
deviceClassName: gpu.nvidia.com
count: 1
apply แล้วเรียกใช้จาก pod:
apiVersion: v1
kind: Pod
metadata:
name: smoke-test
namespace: gpu-test
spec:
resourceClaimTemplates:
- metadata:
name: gpu-claim
spec:
devices:
requests:
- name: gpu
deviceClassName: gpu.nvidia.com
count: 1
containers:
- name: cuda-app
image: nvcr.io/nvidia/k8s/cuda-sample:nbody-cuda12.5.0
resources:
claims:
- name: gpu-claim
command: ["/cuda-sample/nbody"]
ถ้าใส่ ResourceClaimTemplate ไว้ใน Pod spec ทุก Pod จะได้ claim ใหม่ของตัวเอง ส่วน ResourceClaim แบบแยกเดี่ยว (เหมือนตัวอย่างแรก) หลาย pod ใช้ claim เดียวกันได้ และ claim จะคืน GPU ก็ต่อเมื่อสั่งลบเอง
รันเลย:
ใน log ต้องเห็น nbody simulation รันบน GPU 0 ส่วนชื่อ claim ของ Pod จะหน้าตาประมาณ gpu-test/smoke-test-gpu-claim เปิดดูข้างในได้แบบนี้:
ดูที่ .status.allocation.devices ตรงนั้นคือ UUID ของ GPU ตัวจริงที่ scheduler จัดให้
ขั้นที่ 4: ย้าย workload ทีละตัว¶
เริ่มจาก workload ที่เสี่ยงน้อยที่สุดก่อน เช่น dev cluster, batch job หรือ CI runner ตัวไหนก็ได้ที่ rollback 5 นาทีแล้วไม่มีใครเดือดร้อน
วิธีแปลง manifest:
ก่อน (device plugin):
หลัง (DRA):
spec:
resourceClaims:
- name: training-gpus # claim must exist in same namespace
containers:
- name: trainer
resources:
claims:
- name: training-gpus
---
apiVersion: resource.k8s.io/v1
kind: ResourceClaim
metadata:
name: training-gpus
namespace: ml-team
spec:
devices:
requests:
- name: gpu
deviceClassName: gpu.nvidia.com
count: 4
ทำตามลำดับนี้:
- สร้าง
ResourceClaim(หรือResourceClaimTemplate) - แก้ Pod spec (หรือ Deployment template) ให้อ้าง claim
- Apply
- เช็กว่า Pod schedule ได้ และ container มองเห็น GPU (รัน
nvidia-smiข้างใน) - ไปต่อ workload ถัดไป
ถ้ายังไม่มี rollback เตรียมไว้ อย่าแก้ manifest ของ Deployment ทับไปเลย ให้เพิ่ม claim กับจุดที่อ้าง claim ก่อน deploy ให้ผ่าน แล้วค่อยลบบรรทัด nvidia.com/gpu: N
ขั้นที่ 5: ลองแชร์ GPU ผ่าน claim¶
device plugin แชร์ GPU ได้สองแบบ คือ time-slicing (ตั้ง config ให้หลาย pod เข้า GPU ตัวเดียวกัน) กับ MPS (รันพร้อมกันได้จริง) DRA เขียนเรื่องแชร์อีกแบบ คือผ่าน list ของ consumers:
apiVersion: resource.k8s.io/v1
kind: ResourceClaimTemplate
metadata:
name: shared-gpu
spec:
devices:
requests:
- name: shared-gpu
deviceClassName: gpu.nvidia.com
count: 1
config:
- requests:
- name: shared-gpu
capacity:
requests: 4 # share 1 GPU across 4 consumer pods
ให้ pod สองตัวอ้าง claim template เดียวกัน แล้ว DRA driver จะแบ่ง GPU ให้แต่ละตัวใช้คนละส่วน ผลออกมาใกล้กับ time-slicing ของ device plugin แต่ไปเขียนไว้ใน API แทน config ระดับ node ข้อดีคือแชร์กันเป็นราย claim ไม่ใช่ทั้ง node บน node เดียวกัน GPU ตัวหนึ่งแชร์ให้ inference pod 4 ตัวได้ ส่วนอีกตัวยกให้ training job ใช้คนเดียว
สิ่งที่การแชร์ใน DRA ยังทำไม่ได้ ตอนนี้คือจำกัด memory ราย pod config time-slicing ของ device plugin แบ่ง memory เป็นสัดส่วนได้ แต่ DRA ยังไม่สนเรื่อง memory เลย ถ้าต้องกั้น memory ระหว่าง tenant ที่แชร์ GPU กันให้ขาด ไปใช้ MIG
ขั้นที่ 6: ลอง MIG ผ่าน DRA¶
ถ้าใช้ MIG (Multi-Instance GPU) กับ device plugin ต้องตั้ง config ระดับ node และมี extended resource แยกตาม profile เช่น nvidia.com/mig-1g.5gb ส่วน DRA แค่เลือก DeviceClass:
apiVersion: resource.k8s.io/v1
kind: ResourceClaim
metadata:
name: mig-slice
spec:
devices:
requests:
- name: mig
deviceClassName: mig.nvidia.com
config:
- requests:
- name: mig-profile
selector:
"nvidia.com/profile": "1g.10gb" # H100 10GB MIG slice
MIG kubelet plugin (ส่วนหนึ่งของ DRA driver ของ NVIDIA) เปิด profile ข้างล่างให้เอง Pod ได้ MIG instance ที่ CUDA มองเห็น ตรงกับ profile ที่ขอ hardware ชุดเดิม แต่ API สะอาดกว่า แถมรัน workload ที่ใช้ MIG กับไม่ใช้ MIG ปนกันบน node เดียวได้โดยไม่ต้อง restart อะไร
MIG และ feature allocate ขั้นสูงตัวอื่นจะใช้ได้ก็ต่อเมื่อเปิด allocate GPU ใน DRA driver (gpuResourcesEnabled=true) รอให้ย้าย workload ออกจาก device plugin ครบก่อน แล้วค่อยเปิด
ขั้นที่ 7: ลอง Multi-Node NVLink (feature พระเอก)¶
ส่วนนี้ device plugin ทำไม่ได้เลย rack GB200 NVL72 ของ NVIDIA ต้องให้ GPU ทุกตัวใน domain คุยกันผ่าน NVLink ได้ และใช้ IMEX primitive (channel) คุมการเข้าถึง GPU memory ข้าม node resource ComputeDomain ของ DRA เขียนเรื่องนี้ออกมาได้ตรง ๆ:
apiVersion: resource.nvidia.com/v1alpha1
kind: ComputeDomain
metadata:
name: gb200-training-domain
spec:
numNodes: 2 # span across 2 nodes
# Plus: channel configuration for IMEX
---
apiVersion: resource.k8s.io/v1
kind: ResourceClaimTemplate
metadata:
name: mnnvl-gpus
spec:
devices:
requests:
- name: compute-domain
deviceClassName: compute-domain.nvidia.com
พอ Pod อ้าง claim นี้ scheduler จะ:
- หา
ComputeDomainที่ยังมีที่ว่าง (หรือสร้างใหม่) - จอง GPU ให้ครบจำนวน กระจายไปตามจำนวน node ที่กำหนด
- ตั้ง IMEX channel ระหว่าง node
- ผูก GPU ทั้งหมดเข้ากับ Pod เป็น domain เดียวที่ NVLink-coherent
พอ Pod จบ ComputeDomain ก็รื้อทิ้ง ปล่อย IMEX channel และคืน GPU เข้า pool kubelet plugin ของ ComputeDomain support อย่างเป็นทางการตั้งแต่ v0.4.12 ส่วนฝั่ง allocate GPU ยังเป็น preview
จะใช้ feature นี้ได้จริงต้องมี GB200 (หรือ hardware รุ่นหลังที่ NVLink-coherent) ถ้าเป็น H100 หรือเก่ากว่า plugin compute-domain ติดตั้งได้ แต่จะไม่มีวัน match pod จะค้าง pending พร้อมข้อความ no devices available จนกว่าจะถอด claim ComputeDomain ออก
ขั้นที่ 8: ปลดระวาง device plugin¶
เมื่อทุก workload ใน cluster ย้ายมา DRA หมดแล้ว:
# 1. Verify no Pod still uses nvidia.com/gpu
kubectl get pods -A -o json | \
jq '.items[].spec.containers[].resources.limits
| select(."nvidia.com/gpu" != null)' | head
# 2. Uninstall GPU Operator's device plugin component
# OR uninstall the device plugin DaemonSet directly
kubectl delete daemonset -n nvidia-device-plugin nvidia-device-plugin
# 3. If using GPU Operator, disable device plugin in values
helm upgrade gpu-operator nvidia/gpu-operator \
--reuse-values \
--set devicePlugin.enabled=false
# 4. Enable GPU allocation in DRA driver if you want full feature set
helm upgrade dra-driver-nvidia-gpu \
oci://registry.k8s.io/dra-driver-nvidia/charts/dra-driver-nvidia-gpu \
--reuse-values \
--set gpuResourcesEnabled=true
ก่อนลบ DaemonSet เช็กให้ชัวร์ว่าไม่มีอะไรอ้าง nvidia.com/gpu เหลืออยู่ ถ้าหลุดไปสักจุด จะเห็น Pod schedule ได้ 0/N ซึ่งพลาดง่ายมากถ้าไม่ได้ grep หา
เมื่อไหร่ยังไม่ต้องไป DRA¶
DRA ไม่ใช่ upgrade ที่ได้มาฟรี กรณีที่อยู่กับ device plugin ต่อดีกว่า:
- Cluster ยังอยู่ K8s 1.31 หรือเก่ากว่า — DRA ในเวอร์ชันพวกนั้นยังเป็น alpha/beta เปิด feature gate ได้ก็จริง แต่จะเจอ bug ที่ยังไม่มีใครแก้ เพราะคนที่ใช้ใน production ส่วนใหญ่อยู่ 1.33+ หรือ 1.34+ กันแล้ว1
- ใช้ GPU เต็มตัวอย่างเดียว ไม่มี MIG ไม่มี MNNVL ไม่แชร์ — device plugin ก็ทำงานได้ดีอยู่แล้ว ต้นทุนการย้าย (แก้ spec ทุก workload ใหม่ สอนทีมเรื่อง claim) ไม่คุ้มกับแค่ได้ของที่เรียบร้อยขึ้น
- พึ่ง
gpu-feature-discoveryเยอะ และใช้ node label ที่ GFD สร้างให้ — GFD ยังใช้ได้ แต่พอมี DRA แล้ว label จะเหลือแค่ข้อมูลประกอบ scheduler ดูที่ claim ไม่ได้ดู label - มี custom scheduler หรือ operator ที่อ่าน extended resource
nvidia.com/gpuตรง ๆ — ตัวพวกนี้ต้องเขียนใหม่
ถ้าเป็น cluster ใหม่บน K8s 1.35+ ไม่ต้องลง device plugin เลย ติดตั้ง DRA driver ไปตั้งแต่แรก
เรื่องที่ผมยัง verify ไม่ได้¶
- GA ของ allocate GPU ใน NVIDIA DRA driver จะมาเมื่อไหร่ — release note ของ v0.4.1 ยังเขียนว่า feature ฝั่ง GPU มีไว้ "for exploration and demonstration" และไม่บอกวัน GA2
gpu-kubelet-pluginก็ปิดไว้เป็น default ช่วงกลางปี 2026 ให้ถือว่า claim ฝั่ง GPU ทั้งหมดยังเป็น preview - MIG ผ่าน DRA กั้น memory ราย tenant ได้จริงไหม — API เลือก MIG profile ราย claim ได้ แต่ผมยืนยันไม่ได้ว่า DRA driver คุม memory cap ราย instance ได้แบบเดียวกับที่ hardware MIG ทำเองหรือเปล่า
- DRA + Cluster Autoscaler — กลไก
ProvisioningRequestของ CA น่าจะใช้กับ DRA ได้ แต่ถึงกลางปี 2026 ผมยังหา walkthrough แบบ end-to-end ที่ provision GPU node ผ่าน DRA + CA ไม่เจอ - DRA + Karpenter — CRD
NodePoolของ Karpenter ยังไม่รองรับ DRA เองใน v1.13.0 (2026-06-10) ถ้าใช้ Karpenter ทำ GPU autoscaling ตอนนี้ต้องต่อเองหรือรอไปก่อน - ตัวเลขการใช้งานจริง — NVIDIA, Google Cloud (GKE รองรับ DRA แบบ GA) และ vendor ฝั่ง AI infra อีกไม่กี่เจ้ารันบน production แล้ว แต่ยังไม่มีใครเปิดตัวเลข deployment (จำนวน cluster, ขนาด GPU ที่ scale ออกไป) ให้ดู
สรุป¶
- DRA เป็น GA ใน Kubernetes 1.35 ถ้าเป็น 1.32-1.34 ใช้แค่ตอน test
- ติดตั้ง NVIDIA DRA driver ด้วย
gpuResourcesEnabled=falseก่อน รอย้าย workload ครบแล้วค่อยเปิดฝั่ง allocate GPU - ให้ device plugin รันต่อ ตลอดช่วงย้าย ถ้าระวังดี ๆ สองระบบไม่ชนกันที่ระดับ API
- ย้ายทีละ workload — ใส่ claim ก่อน แล้วค่อยถอด
nvidia.com/gpu - ComputeDomain (MNNVL) คือ feature พระเอก และ support อย่างเป็นทางการแล้ว ส่วน allocate GPU (MIG, การแชร์, time-slicing ผ่าน API) ยังเป็น preview
- cluster ใหม่บน K8s 1.35+ ไม่ต้องลง device plugin เลย การย้ายคุ้มก็ต่อเมื่อมี cluster เดิมอยู่แล้วเท่านั้น
การย้ายเป็นงานจริง manifest ของทุก workload ต้องแก้ แต่ API ชุดนี้คือสิ่งที่ควรมีตั้งแต่ปี 2018 แล้ว device plugin ยังมีคน maintain อยู่ ไม่ต้องรีบย้ายพรุ่งนี้ แต่ถ้ากำลังตั้ง cluster ใหม่ หรือวางแผนขึ้น K8s เวอร์ชันใหญ่ ให้สร้าง cluster ใหม่บน DRA ไปเลย
มีคำถามหรืออยากคุยต่อ? ติดต่อได้ที่ LinkedIn, X หรือทาง email
-
เอกสาร Kubernetes, "Dynamic Resource Allocation" (FEATURE STATE: Kubernetes v1.35 [stable], เปิดเป็น default), https://kubernetes.io/docs/concepts/scheduling-eviction/dynamic-resource-allocation/ ↩↩↩↩
-
NVIDIA, "DRA Driver for NVIDIA GPUs v0.4.1," https://github.com/NVIDIA/k8s-dra-driver/releases/tag/v0.4.1 ↩↩↩↩↩↩↩↩
-
NVIDIA GPU Operator v26.3.3 release, https://github.com/NVIDIA/gpu-operator/releases/tag/v26.3.3 ↩
Discussion
Have thoughts on this post? Share them below — questions, corrections, or your own experience are all welcome.