运行 Sandbox

将 Kueue 与 Sandbox 操作符集成。

此页面展示了在运行 Sandbox 时,如何利用 Kueue 的调度和资源管理能力。

本指南适用于对 Kueue 有基本了解的批处理用户。 欲了解更多信息,请参阅 Kueue 概述

Sandbox 操作符为运行 AI 代理工作负载提供隔离环境。 Kueue 通过普通 Pod 集成管理由 Sandbox 控制器创建的 Pod, 其中每个 Sandbox Pod 都表示为单个独立的普通 Pod。

在你开始之前

  1. 了解如何使用自定义管理器配置安装 Kueue

  2. 按照运行普通 Pod 中的步骤,了解如何启用和配置 pod 集成。

  3. 查阅管理集群配额,了解初始 Kueue 设置的详细信息。

  4. 安装 Sandbox Operator

Sandbox 定义

a. 队列选择

目标本地队列应在 Sandbox 配置的 spec.podTemplate.metadata.labels 部分中指定。

spec:
  podTemplate:
    metadata:
      labels:
        kueue.x-k8s.io/queue-name: user-queue

b. 配置资源需求

工作负载的资源需求可以在 spec.podTemplate.spec.containers 中配置。

spec:
  podTemplate:
    spec:
      containers:
      - resources:
          requests:
            cpu: "100m"
            memory: "200Mi"

示例 Sandbox

以下是一个示例 Sandbox:

apiVersion: agents.x-k8s.io/v1alpha1
kind: Sandbox
metadata:
  name: hello-world-kueue
spec:
  podTemplate:
    metadata:
      labels:
        kueue.x-k8s.io/queue-name: user-queue
    spec:
      containers:
      - name: hello
        image: busybox
        command: ["sleep"]
        args: ["6000"]
        resources:
          requests:
            cpu: "100m"
            memory: "200Mi"
      restartPolicy: Never

限制

  • Kueue 只会管理由 Sandbox Operator 创建的 Pod。
  • 每个 Sandbox Pod 都会创建一个新的 Workload 资源,并且必须等待 Kueue 的准入。