运行 Argo Workflow

将 Kueue 与 Argo Workflow 集成。

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

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

目前,Kueue 不直接支持 Argo Workflow 的 Workflow 资源, 但你可以利用 Kueue 管理普通 Pod 的能力来集成它们。

开始之前

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

  2. 遵循运行普通 Pod 中的步骤来学习如何启用和配置 pod 集成。

  3. 安装 Argo Workflow

Workflow 定义

a. 针对单个本地队列

如果你希望整个工作流针对单个本地队列, 应在 Workflow 配置的 spec.podMetadata 部分指定它。

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: hello-world-
spec:
  entrypoint: whalesay
  podMetadata:
    labels:
      kueue.x-k8s.io/queue-name: user-queue # All pods will target user-queue
  templates:
    - name: whalesay
      container:
        image: docker/whalesay
        command: [ cowsay ]
        args: [ "hello world" ]
        resources:
          limits:
            memory: 32Mi
            cpu: 100m

b. 针对每个模板的不同本地队列

如果你希望针对工作流的每一步使用不同的本地队列, 可以在 Workflow 配置的 spec.templates[].metadata 部分定义队列。

在这个例子中,hello1hello2a 将针对 user-queue, 而 hello2b 将针对 user-queue-2

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: steps-
spec:
  entrypoint: hello-hello-hello

  templates:
  - name: hello-hello-hello
    steps:
    - - name: hello1            # hello1 is run before the following steps
        template: whalesay
        arguments:
          parameters:
          - name: message
            value: "hello1"
    - - name: hello2a           # double dash => run after previous step
        template: whalesay
        arguments:
          parameters:
          - name: message
            value: "hello2a"
      - name: hello2b           # single dash => run in parallel with previous step
        template: whalesay-queue-2
        arguments:
          parameters:
          - name: message
            value: "hello2b"

  - name: whalesay
    metadata:
      labels:
        kueue.x-k8s.io/queue-name: user-queue # Pods from this template will target user-queue
    inputs:
      parameters:
      - name: message
    container:
      image: docker/whalesay
      command: [cowsay]
      args: ["{{inputs.parameters.message}}"]

  - name: whalesay-queue-2
    metadata:
      labels:
        kueue.x-k8s.io/queue-name: user-queue-2 # Pods from this template will target user-queue-2
    inputs:
      parameters:
      - name: message
    container:
      image: docker/whalesay
      command: [cowsay]
      args: ["{{inputs.parameters.message}}"]

c. 限制

  • Kueue 仅管理由 Argo Workflow 创建的 Pod。它不会以任何方式管理 Argo Workflow 资源。
  • Workflow 中的每个 Pod 都将创建一个新的 Workload 资源,并且必须等待 Kueue 的准入。
  • 没有办法确保 Workflow 在开始前完成。如果多步骤工作流中的某一步没有可用配额, Argo Workflow 将运行所有之前的步骤并等待配额变为可用。
  • Kueue 不理解 Argo Workflow 的 suspend 标志,也不会管理它。
  • Kueue 不管理 suspendhttpresource 模板类型,因为它们不创建 Pod。