Workload-Aware Scheduling
Kubernetes Workload-Aware Scheduling (WAS) lets the kube-scheduler place the
Pods of a Job as a group, for example all-or-nothing (gang scheduling). Kueue
and WAS act at different stages, so some configurations stop a Job from
starting or completing even after Kueue admits it. This page lists those
configurations for batch/v1 Jobs in Kubernetes v1.37 and Kueue v0.21.
These limitations apply on clusters where WAS is enabled (see
Requirements). Some of them also affect
Jobs that do not set spec.scheduling.
Compatibility at a glance
| If you use | Recommendation |
|---|---|
| Gang scheduling | Do not use partial admission. |
| WAS topology constraints with Kueue TAS | Use the same topology key in both, with kueue.x-k8s.io/podset-required-topology, or only one of them. |
| Elastic Jobs | Do not use partial scale-up. A pending scale-up can also block replacement Pods. |
Your own PodGroup | Do not set schedulingGroup in the Pod template. |
How Kueue and WAS work together
Kueue decides when a Job is admitted: it reserves quota and, with
Topology Aware Scheduling (TAS),
chooses a topology domain. With
partial admission, it can also lower
spec.parallelism. Then Kueue unsuspends the Job.
The Job controller creates a Kubernetes Workload and a PodGroup for the Job,
and once the Job is unsuspended, the kube-scheduler places its Pods according to
the PodGroup. These are scheduling.k8s.io objects, different from the Kueue
Workload. A Job with
spec.scheduling.schedulingPolicy.gang gets a gang PodGroup; any other Job
gets a Basic PodGroup. This applies to Jobs that have no controller owner
(for example, not created by a CronJob) and whose Pod template does not set
schedulingGroup.
Kueue does not read spec.scheduling. It does not know the gang’s minCount,
and TAS does not take WAS topology constraints into account.
Requirements
In Kubernetes v1.37, WAS requires the scheduling.k8s.io/v1beta1 API and the
GenericWorkload feature gate on the kube-apiserver, kube-controller-manager
and kube-scheduler. For the Job controller to create the Workload and
PodGroup from the Job, the WorkloadWithJob feature gate is also required on
the kube-apiserver and kube-controller-manager. Both gates are off by default.
Topology constraints also require the TopologyAwareWorkloadScheduling feature
gate on the kube-apiserver and kube-scheduler. Without the gate, the
kube-apiserver drops the constraints, and the kube-scheduler does not enforce
them.
Known limitations
Gang scheduling and partial admission
Do not combine gang scheduling with partial admission: if a Job sets
spec.scheduling.schedulingPolicy.gang, do not set the
kueue.x-k8s.io/job-min-parallelism annotation.
Partial admission can lower parallelism, which can break the gang in these ways:
- With an explicit
minCount, Kueue can admit fewer Pods thanminCount. The kube-apiserver rejects the update that unsuspends the Job. The Job stays suspended, and its KueueWorkloadreportsPodsReady=Falsewith reasonWaitForStart. The Job has no Warning event; the Kueue controller logs showminCount: Invalid value: ... must not be greater than parallelism. With the defaultwaitForPodsReadyconfiguration, theWorkloadis evicted and requeued. The failure can recur on readmission. - Without an explicit
minCount, partial admission can lowerparallelismbelowcompletions. The Job starts, but after some Pods succeed, the remaining Pods can stayPendingwith no scheduling events. ThePodGroupstill waits forminCountPods, and Pods that succeeded do not count. The KueueWorkloadreportsPodsReady=True, sowaitForPodsReadydoes not evict it. See the related gang scheduling issue kubernetes/kubernetes#142330.
In both cases, the Workload can hold quota without making progress.
WAS topology constraints and Kueue TAS
Use the same node label in schedulingConstraints.topology and in the
kueue.x-k8s.io/podset-required-topology annotation, for example
cloud.provider.com/topology-rack in both. Alternatively, use only one of them.
With kueue.x-k8s.io/podset-preferred-topology, TAS can split the Pods across
domains, which the WAS constraint does not allow.
If the WAS topology key is not a level of the Topology
used by TAS, Kueue chooses a domain without considering the WAS constraint. The
kube-scheduler may then find no placement in that domain, even when another
domain would satisfy both. The Job is admitted and holds quota, and its Pods
stay Pending with FailedScheduling events.
Elastic Jobs and scale-up
Do not use partial scale-up on
clusters where WorkloadWithJob is enabled. This applies to every Job that gets
a PodGroup (see How Kueue and WAS work together),
including Jobs that do not use gang scheduling.
The kube-scheduler does not schedule any Pod of a PodGroup, including a
Basic one, while another Pod of the same PodGroup still has a scheduling
gate. Elastic Jobs can leave some Pods gated
while Kueue allows others to run:
- With partial scale-up, the added Pods that fit in the quota are not scheduled until the quota for all added Pods is available.
- While a scale-up is waiting for quota, a replacement Pod, for example for a failed Pod, is not scheduled either. Avoiding partial scale-up does not prevent this.
An affected Pod stays Pending with condition PodScheduled=False and reason
SchedulingGated, although it has no scheduling gates, and has no scheduling
events.
User-managed PodGroups
Do not set spec.template.spec.schedulingGroup on a Job that Kueue manages; use
spec.scheduling instead, within the limitations on this page.
When this field is set, the Job controller does not create a PodGroup, and the
Pods must reference one that you create. Kueue cannot see the minCount of that
PodGroup, and it holds quota for the Job even if the PodGroup does not
exist.
What’s next
- Learn about All-or-nothing scheduling with Kueue.
- Learn how to run a Kubernetes Job with Kueue.
- Read KEP-5547: Integrate Workload APIs with Job Controller.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.