기본 개념

Workload는 완료될 때까지 실행되는 애플리케이션이며, Kueue에서 admission의 단위다. 때로는 job이라고도 불린다.

Workload는 하나 또는 여러 개의 Pod으로 구성될 수 있으며, 느슨하게 또는 밀접하게 결합되어 전체적으로 하나의 작업을 완료한다. 전형적인 워크로드는 Kubernetes batch/v1.Job으로 표현될 수 있다.

Kueue는 Job 객체를 직접 조작하지 않는다. 대신 임의의 워크로드의 리소스 요구사항을 나타내는 Workload 객체를 관리하고, 각 Job 객체에 대해 자동으로 Workload를 생성하여 결정과 상태를 동기화한다.

특징:

기본 구조

Workload 매니페스트 예시

apiVersion: kueue.x-k8s.io/v1beta1
kind: Workload
metadata:
  name: ml-training-job
  namespace: team-a
spec:
  active: true
  queueName: team-a-queue     # LocalQueue 이름
  priorityClassName: high-priority
  priority: 1000
  maximumExecutionTimeSeconds: 3600  # 최대 실행 시간
  podSets:
  - count: 3                  # Pod 개수
    name: main                # Pod set 이름
    template:
      spec:
        containers:
        - name: trainer
          image: tensorflow/tensorflow:latest-gpu
          args: ["python", "train.py"]
          resources:
            requests:
              cpu: "4"
              memory: "8Gi"
              nvidia.com/gpu: "1"
        restartPolicy: Never
  - count: 1                  # 매개변수 서버용 Pod set
    name: parameter-server
    template:
      spec:
        containers:
        - name: ps
          image: tensorflow/tensorflow:latest
          args: ["python", "parameter_server.py"]
          resources:
            requests:
              cpu: "2"
              memory: "4Gi"
        restartPolicy: Never

핵심 구성 요소

1. PodSets

spec.podSets 목록의 각 항목은 동질적인 Pod 집합을 나타낸다. name은 Workload에서 Pod의 역할을 나타내는 사람이 읽을 수 있는 식별자로, driver, worker, parameter-server 등을 사용할 수 있다.

spec:
  podSets:
  - count: 4
    name: worker              # 워커 노드들
    template:
      spec:
        containers:
        - name: worker
          image: distributed-trainer:latest
          resources:
            requests:
              nvidia.com/gpu: "1"
              cpu: "8"
              memory: "16Gi"
  - count: 1
    name: chief               # 마스터 노드
    template:
      spec:
        containers:
        - name: chief
          image: distributed-trainer:latest
          env:
          - name: ROLE
            value: "chief"
          resources:
            requests:
              cpu: "4"
              memory: "8Gi"

2. 리소스 계산

Kueue는 podSets의 리소스 요청을 사용하여 Workload가 사용하는 할당량을 계산하고 Workload를 언제 승인할지 결정한다. Workload의 총 리소스 사용량은 각 podSet의 리소스 요청의 합으로 계산된다. podSet의 리소스 사용량은 pod spec의 리소스 요청에 count를 곱한 값과 같다.

# 위 예시에서 총 리소스 사용량:
# GPU: (1 GPU × 4 workers) + (0 GPU × 1 chief) = 4 GPU
# CPU: (8 CPU × 4 workers) + (4 CPU × 1 chief) = 36 CPU
# Memory: (16Gi × 4 workers) + (8Gi × 1 chief) = 72Gi

3. 우선순위 관리

Workload의 우선순위는 ClusterQueue에서 승인 순서에 영향을 준다.