运行 AppWrapper
本页面展示了在运行 AppWrapper 时,如何利用 Kueue 的调度和资源管理能力。
AppWrapper 提供了一种灵活且与工作负载无关的机制,使 Kueue 能够将一组 Kubernetes 资源作为一个单一的逻辑单元进行管理, 而无需这些资源的控制器具备任何 Kueue 特定的支持。
AppWrapper 旨在通过提供额外的自动故障检测和恢复机制来增强工作负载的健壮性。 AppWrapper 控制器会监控工作负载的健康状况, 如果主要资源控制器在指定的截止时间内未采取纠正措施,AppWrapper 控制器将协调工作负载级别的重试和资源删除, 以确保工作负载要么恢复到健康状态,要么被干净地从集群中移除,并释放其配额供其他工作负载使用。
本指南适用于对 Kueue 有基本了解的批用户。更多信息请参见 Kueue 概述。
开始之前
请查阅管理集群配额以了解 Kueue 的初始设置详情。
为简化设置,请确保你使用的是 Kueue v0.11.0 和 AppWrapper v1.1.1 及以上版本。
有关 AppWrapper Operator 的安装和配置详情,请参见 AppWrapper 快速入门指南。
AppWrapper 定义
在 Kueue 上运行 AppWrapper 时,请注意以下方面:
a. 队列选择
目标本地队列应在 AppWrapper 的 metadata.labels
部分指定。
metadata:
labels:
kueue.x-k8s.io/queue-name: user-queue
b. 配置资源需求
工作负载的资源需求通过组合每个 Wrapper 组件的资源需求来计算。
包含 PyTorchJob 的 AppWrapper 示例
AppWrapper 如下所示:
apiVersion: workload.codeflare.dev/v1beta2
kind: AppWrapper
metadata:
name: sample-appwrapper-pytorch-job
labels:
kueue.x-k8s.io/queue-name: user-queue
spec:
components:
- template:
apiVersion: "kubeflow.org/v1"
kind: PyTorchJob
metadata:
name: pytorch-simple
spec:
pytorchReplicaSpecs:
Master:
replicas: 1
restartPolicy: OnFailure
template:
spec:
containers:
- name: pytorch
image: docker.io/kubeflowkatib/pytorch-mnist-cpu:v1beta1-fc858d1
command:
- "python3"
- "/opt/pytorch-mnist/mnist.py"
- "--epochs=1"
resources:
requests:
cpu: 1
Worker:
replicas: 1
restartPolicy: OnFailure
template:
spec:
containers:
- name: pytorch
image: docker.io/kubeflowkatib/pytorch-mnist-cpu:v1beta1-fc858d1
command:
- "python3"
- "/opt/pytorch-mnist/mnist.py"
- "--epochs=1"
resources:
requests:
cpu: 1
包含 Deployment 的 AppWrapper 示例
AppWrapper 如下所示:
apiVersion: workload.codeflare.dev/v1beta2
kind: AppWrapper
metadata:
name: sample-appwrapper-deployment
labels:
kueue.x-k8s.io/queue-name: user-queue
spec:
suspend: true
components:
- podSets:
- path: "template.spec.template"
replicas: 3
template:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: registry.k8s.io/nginx-slim:0.27
ports:
- containerPort: 80
resources:
requests:
cpu: "100m"
反馈
这个页面有帮助吗?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.