Module 4: Kueue Concepts
Kueue is a Kubernetes-native job queueing system that manages resource quotas, fair sharing, and workload preemption. In this workshop environment, Kueue controls how GPU resources are shared between users with reservations and those using the unreserved pool.
In this module, you’ll explore the Kueue resource hierarchy, understand how Cohorts enable resource sharing, and trace a workload through the admission process.
Learning objectives
By the end of this module, you’ll be able to:
-
Describe the Kueue resource hierarchy: ResourceFlavor, ClusterQueue, LocalQueue, Cohort
-
Explain how the unreserved Cohort enables borrowing and reclaiming
-
Submit a workload and trace its admission through Kueue
-
Identify when and why workloads are queued vs. admitted
Kueue resource hierarchy
The workshop cluster configures Kueue resources in a flat Cohort model:
Cohort: unreserved
├── ClusterQueue: unreserved (borrows from cohort, no preemption rights)
├── ClusterQueue: unreserved-priority (can preempt low-priority borrowing workloads)
├── ClusterQueue: user-alice (protected nominalQuota, can reclaim from cohort)
└── ClusterQueue: user-bob (protected nominalQuota, can reclaim from cohort)
All ClusterQueues share resources through the unreserved Cohort. The key difference is in their preemption policies:
| ClusterQueue | nominalQuota | Borrow? | Preempt? |
|---|---|---|---|
|
Total minus reserved |
Yes (from cohort) |
No — workloads here are always preemptable |
|
0 |
Yes (from cohort) |
Yes — can preempt lower-priority borrowing workloads (see below) |
|
User’s reservation |
No |
Yes — |
What is the difference between reclaiming and borrowing?
Borrowing: A ClusterQueue uses GPU/resource quota from another ClusterQueue in the same Cohort when its own quota is exhausted. The borrowing queue gets extra capacity it doesn’t own.
Reclaiming: The queue that owns the quota takes it back from a borrower. When the owner needs its resources, it preempts workloads that were borrowing them.
In short: borrowing is "can I use your unused quota?", reclaiming is "I need my quota back."
What is low-priority borrowing?
The unreserved-priority ClusterQueue exists for workloads that need to preempt other unreserved work — without having a reservation. It has nominalQuota: 0 (no guaranteed resources), so all its resources are borrowed from the Cohort. The difference from the regular unreserved queue is its preemption policy:
preemption:
borrowWithinCohort:
policy: LowerPriority
maxPriorityThreshold: 100
This means: "when I am borrowing from the Cohort, I can preempt other borrowing workloads — but only those with a priority value of 100 or below." A workload using the high-priority WorkloadPriorityClass (value 10000) submitted to unreserved-priority can preempt regular unreserved workloads (which have no priority class, defaulting to 0). But it still cannot preempt workloads running under a user reservation — those are protected by nominalQuota, not borrowing.
This is useful for batch scheduling scenarios where certain unreserved jobs (e.g., urgent training runs) should jump ahead of background workloads without needing a full reservation.
What is protected quota?
When you make a reservation, the app creates Kueue resources that give your workloads protected quota — they cannot be preempted by unreserved workloads.
We have configured reservation guarantees to ensure that user reservations are not preempted by unreserved workloads. This is a design choice to ensure that users can reserve GPUs for their own use and not have them taken away by other users whilst allowing unreserved workloads to run when resources are available.
The Booking App’s design is achieved through the use of Kueue’s Cohort model:
-
the Cohort (which is named
unreserved) initially owns all the resources in the cluster -
all unreserved workloads are borrowing (their ClusterQueue has
nominalQuota: 0). -
when a user makes a reservation, the Cohort is reduced by the amount of the reservation
-
a user ClusterQueue
user-<name>is created for the user with thenominalQuotamatching the reservation -
their
user-<name>ClusterQueue hasreclaimWithinCohort: AnyandborrowWithinCohort: Neverwhich means it can preempt any workload borrowing from the cohort but never borrow itself
Preemption works because the booking app actively shrinks the Cohort’s capacity when quota is allocated. The unreserved CQ has 0 nominal quota (no guaranteed resources) and borrows from the Cohort. When the Cohort shrinks, the unreserved workloads are over their allocation, and the user CQ reclaims.
With this design, we can complement the Kueue Cohort model with other CQ’s. One example (not covered in this workshop), is a Multi-Kueue environment. We have a CQ cluster-queue where batch workloads are assigned by a HUB Cluster (ACM) to SPOKE GPU enabled clusters. Unreserved workloads can then use the setting borrowWithinCohort: LowerPriority to preempt lower priority unreserved workloads - whilst preserving the reservation guarantees for users.
Exercise 1: Explore ClusterQueues
|
Acting as:
|
-
List all ClusterQueues with their key properties:
oc get clusterqueues -o custom-columns=\ NAME:.metadata.name,\ COHORT:.spec.cohortName,\ ADMITTED:.status.admittedWorkloads,\ PENDING:.status.pendingWorkloadsYou should see only
default,unreserved, andunreserved-priorityClusterQueues. -
Inspect the
unreservedClusterQueue:oc get clusterqueue unreserved -o yamlKey fields to note in the YAML output:
-
spec.cohortName: unreserved— joins the shared Cohort -
spec.resourceGroups— defines flavors and nominal quotas -
spec.preemption— no reclaim rights
-
-
Now create a reservation so we can compare a user ClusterQueue with the unreserved one. In the OpenShift Console, navigate to GPU Booking > Bookings, select today’s date, and reserve 1 Full GPU.
Wait for the Reservation Sync to create the user ClusterQueue .
-
Verify the user ClusterQueue was created:
oc get clusterqueuesYou should now see a
user-user1ClusterQueue alongsidedefault,unreservedandunreserved-priority. -
Compare the preemption policies:
oc get cq unreserved -o jsonpath='{.spec.preemption}' | jq .The
unreservedCQ hasreclaimWithinCohort: Never— it cannot preempt anyone.oc get cq user-user1 -o jsonpath='{.spec.preemption}' | jq .The
user-user1CQ hasreclaimWithinCohort: Any— it can preempt unreserved workloads to reclaim its protected quota. This is the key difference that makes reservations work.
Exercise 2: Explore ResourceFlavors and Topology
A ResourceFlavor tells Kueue which nodes can satisfy a particular type of resource. Each ClusterQueue references one or more flavors in its resourceGroups — this is how Kueue matches GPU workloads to the right nodes.
|
Acting as: |
-
List ResourceFlavors:
oc get resourceflavorsYou should see three flavors:
ResourceFlavor Purpose gpu-poolThe fake GPU nodes — used by all GPU ClusterQueues in this workshop
default-flavorCreated by the RHOAI operator (not used in this workshop)
nvidia-gpu-flavorCreated by the RHOAI operator (not used in this workshop)
-
Inspect the
gpu-poolResourceFlavor:oc get resourceflavor gpu-pool -o yamlThe key field is
spec.nodeLabels:spec: nodeLabels: run.ai/simulated-gpu-node-pool: defaultThis label selector is how Kueue knows which nodes have fake GPUs. When the GPU Config plugin labels worker nodes with
run.ai/simulated-gpu-node-pool=default, those nodes become part of thegpu-poolflavor. Every ClusterQueue in theunreservedCohort references this flavor in itsresourceGroups, so all GPU workloads — whether reserved or unreserved — are scheduled onto these labeled nodes. -
Check the Topology configuration:
oc get topologies -ATopology defines zone and hostname levels for pod spreading across nodes. We are using the default topology configuration which means that pods will be spread across nodes in the same zone and hostname.
You can use Topology to enable Topology Aware Scheduling by providing a model that represents the hierarchy of your organizational units (such as zones, blocks, and racks) along with node labels.
Exercise 3: Trace a workload through admission
|
Acting as: |
-
Submit a GPU workload to the unreserved queue:
helm template gpu-deploy oci://quay.io/eformat/gpu-test-workloads -n user-user1 \ --set kind=Pod \ --set name=kueue-test \ --set replicas=1 \ --set gpuCount=1 \ --set gpuResourceType=nvidia.com/gpu \ --set reserved=false \ | oc -n user-user1 apply -f- -
Watch the workload admission:
oc -n user-user1 get workloads -wPress
Ctrl+Cafter the workload is admitted - you should seeADMITTED: Truein the output. -
Check which ClusterQueue admitted the workload:
oc -n user-user1 get workloads -o custom-columns=\ NAME:.metadata.name,\ QUEUE:.spec.queueName,\ ADMISSION:.status.admission.clusterQueueUnreserved workloads are admitted by the
unreservedClusterQueue. -
View the ClusterQueue usage after admission:
oc get clusterqueue unreserved -o jsonpath='{.status.flavorsUsage}' | jq .You should see the workload with
total=1andborrowed=1in theflavorsUsagearray for thenvidia.com/gpuresource type.{ "borrowed": "1", "name": "nvidia.com/gpu", "total": "1" } -
Clean up:
oc -n user-user1 delete pod kueue-test
Exercise 4: Understand the Cohort model
The Cohort is the key to resource sharing. All ClusterQueues in the same Cohort share a single pool of resources.
|
Acting as: |
Cohort resources are ADDITIVE to CQ resources
A critical detail of Kueue’s design: the total capacity available to a ClusterQueue is its own nominalQuota plus what it can borrow from the Cohort. They are additive, not overlapping. This has important implications for how you configure the system.
-
Inspect the Cohort’s resource totals:
oc get cohort unreserved -o jsonpath='{range .spec.resourceGroups[0].flavors[0].resources[*]}{.name}: {.nominalQuota}{"\n"}{end}'You should see that it owns 7/8 GPUs in the cluster and all the MIG partitions.
-
Compare with the
unreservedClusterQueue’s nominalQuota:oc get cq unreserved -o jsonpath='{range .spec.resourceGroups[0].flavors[0].resources[*]}{.name}: {.nominalQuota}{"\n"}{end}'The
unreservedCQ hasnominalQuota: 0for every resource. It owns nothing — all its capacity comes from borrowing from the Cohort. Now compare with the user CQuser-user1which isreserved:oc get cq user-user1 -o jsonpath='{range .spec.resourceGroups[0].flavors[0].resources[*]}{.name}: {.nominalQuota}{"\n"}{end}'With 1 GPU reserved, the three sources of quota look like this:
Resource Cohort CQ unreservedCQ user-user1nvidia.com/gpu7
0
1
nvidia.com/mig-1g.23gb56
0
0
The cluster has 8 physical GPUs. The Cohort holds 7, the user CQ holds 1 — total is 8. Because Cohort and CQ quotas are additive, the booking app must reduce the Cohort by exactly the reserved amount. If the CQ
unreservedalso had a non-zero nominalQuota, that would be added on top — accidentally inflating the total beyond what the cluster actually has. The booking app avoids this by keeping all unreserved CQs at zero and putting the real capacity exclusively in the Cohort.
Why this matters for preemption
The additive model determines which preemption policies work:
-
reclaimWithinCohort: Any— only useful when a CQ hasnominalQuota > 0. It reclaims resources that belong to the CQ but are being borrowed by others. WithnominalQuota: 0, there is nothing to reclaim. -
borrowWithinCohort: LowerPriority— useful when a CQ hasnominalQuota: 0and needs to preempt other borrowers. Since everything is borrowed, preemption happens between borrowers based on priority.
This is why the booking app uses different preemption policies for different queue types:
| ClusterQueue | nominalQuota | Preemption strategy |
|---|---|---|
|
0 |
None — cannot preempt (nothing to reclaim, no priority preemption) |
|
0 |
|
|
User’s reservation |
|
-
Verify the Cohort shrinks when a reservation exists:
oc get cohort unreserved -o jsonpath='{range .spec.resourceGroups[0].flavors[0].resources[*]}{.name}: {.nominalQuota}{"\n"}{end}' | grep gpuIf you created a reservation in Exercise 1, the Cohort’s
nvidia.com/gpuwill show less than 8 — the booking app reduced it by the reserved amount to prevent double-counting. -
Check the WorkloadPriorityClasses:
oc get workloadpriorityclassesHigher priority workloads are admitted first and can preempt lower priority ones (within preemption policy rules).
-
user1: Cancel booking
Acting as:
user1
Return to the OpenShift Console as user1. -
Navigate to GPU Booking > Bookings and click My Bookings.
-
Click Cancel All to remove the GPU reservation, then click Confirm.
Verify
✓ Understand that Cohort and CQ nominalQuotas are additive
✓ Unreserved CQs have nominalQuota: 0 — all capacity is in the Cohort
✓ Reservation reduces Cohort quota to prevent capacity inflation
✓ Preemption strategy depends on whether the CQ has nominalQuota or not
✓ WorkloadPriorityClasses control admission order
Module summary
What you accomplished:
-
Explored the Kueue resource hierarchy: ResourceFlavors, ClusterQueues, LocalQueues, Cohorts
-
Understood the flat Cohort model with protected user quotas and shared unreserved pool
-
Traced a workload from submission to Kueue admission
-
Learned how reservations dynamically adjust Cohort quotas
Key takeaways:
-
Kueue provides fair, quota-based GPU scheduling without custom controllers
-
The Cohort model allows unused reserved capacity to be borrowed by unreserved workloads
-
User ClusterQueues have
reclaimWithinCohort: Anyto preempt unreserved workloads when needed -
ResourceFlavors map Kueue quotas to physical (or simulated) GPU nodes
Next: Module 5 puts it all together with preemption testing — see what happens when reserved workloads claim resources from unreserved ones.
