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

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?

unreserved

Total minus reserved

Yes (from cohort)

No — workloads here are always preemptable

unreserved-priority

0

Yes (from cohort)

Yes — can preempt lower-priority borrowing workloads (see below)

user-<name>

User’s reservation

No

Yes — reclaimWithinCohort: Any reclaims its protected quota

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 the nominalQuota matching the reservation

  • their user-<name> ClusterQueue has reclaimWithinCohort: Any and borrowWithinCohort: Never which 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: user1
Log in to the OpenShift CLI:

oc login --insecure-skip-tls-verify $(oc whoami --show-server) -u user1 -p %password%
  1. List all ClusterQueues with their key properties:

    oc get clusterqueues -o custom-columns=\
    NAME:.metadata.name,\
    COHORT:.spec.cohortName,\
    ADMITTED:.status.admittedWorkloads,\
    PENDING:.status.pendingWorkloads

    You should see only default, unreserved, and unreserved-priority ClusterQueues.

  2. Inspect the unreserved ClusterQueue:

    oc get clusterqueue unreserved -o yaml

    Key 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

  3. 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 .

  4. Verify the user ClusterQueue was created:

    oc get clusterqueues

    You should now see a user-user1 ClusterQueue alongside default, unreserved and unreserved-priority.

  5. Compare the preemption policies:

    oc get cq unreserved -o jsonpath='{.spec.preemption}' | jq .

    The unreserved CQ has reclaimWithinCohort: Never — it cannot preempt anyone.

    oc get cq user-user1 -o jsonpath='{.spec.preemption}' | jq .

    The user-user1 CQ has reclaimWithinCohort: Any — it can preempt unreserved workloads to reclaim its protected quota. This is the key difference that makes reservations work.

Verify

✓ Can list ClusterQueues and their Cohort membership
✓ Understand the preemption policy difference between unreserved and user-* queues

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: user1

  1. List ResourceFlavors:

    oc get resourceflavors

    You should see three flavors:

    ResourceFlavor Purpose

    gpu-pool

    The fake GPU nodes — used by all GPU ClusterQueues in this workshop

    default-flavor

    Created by the RHOAI operator (not used in this workshop)

    nvidia-gpu-flavor

    Created by the RHOAI operator (not used in this workshop)

  2. Inspect the gpu-pool ResourceFlavor:

    oc get resourceflavor gpu-pool -o yaml

    The key field is spec.nodeLabels:

    spec:
      nodeLabels:
        run.ai/simulated-gpu-node-pool: default

    This 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 the gpu-pool flavor. Every ClusterQueue in the unreserved Cohort references this flavor in its resourceGroups, so all GPU workloads — whether reserved or unreserved — are scheduled onto these labeled nodes.

  3. Check the Topology configuration:

    oc get topologies -A

    Topology 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.

Verify

✓ gpu-pool ResourceFlavor targets nodes with run.ai/simulated-gpu-node-pool: default
✓ All GPU ClusterQueues reference the gpu-pool flavor
✓ Topology configuration defines scheduling levels

Exercise 3: Trace a workload through admission

Acting as: user1

  1. 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-
  2. Watch the workload admission:

    oc -n user-user1 get workloads -w

    Press Ctrl+C after the workload is admitted - you should see ADMITTED: True in the output.

  3. Check which ClusterQueue admitted the workload:

    oc -n user-user1 get workloads -o custom-columns=\
    NAME:.metadata.name,\
    QUEUE:.spec.queueName,\
    ADMISSION:.status.admission.clusterQueue

    Unreserved workloads are admitted by the unreserved ClusterQueue.

  4. View the ClusterQueue usage after admission:

    oc get clusterqueue unreserved -o jsonpath='{.status.flavorsUsage}' | jq .

    You should see the workload with total=1 and borrowed=1 in the flavorsUsage array for the nvidia.com/gpu resource type.

    {
      "borrowed": "1",
      "name": "nvidia.com/gpu",
      "total": "1"
    }
  5. Clean up:

    oc -n user-user1 delete pod kueue-test

Verify

✓ Workload was admitted by the unreserved ClusterQueue
✓ ClusterQueue usage reflects the admitted workload
✓ Workload cleaned up

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: user1

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.

  1. 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.

  2. Compare with the unreserved ClusterQueue’s nominalQuota:

    oc get cq unreserved -o jsonpath='{range .spec.resourceGroups[0].flavors[0].resources[*]}{.name}: {.nominalQuota}{"\n"}{end}'

    The unreserved CQ has nominalQuota: 0 for every resource. It owns nothing — all its capacity comes from borrowing from the Cohort. Now compare with the user CQ user-user1 which is reserved:

    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 unreserved CQ user-user1

    nvidia.com/gpu

    7

    0

    1

    nvidia.com/mig-1g.23gb

    56

    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 unreserved also 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 has nominalQuota > 0. It reclaims resources that belong to the CQ but are being borrowed by others. With nominalQuota: 0, there is nothing to reclaim.

  • borrowWithinCohort: LowerPriority — useful when a CQ has nominalQuota: 0 and 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

unreserved

0

None — cannot preempt (nothing to reclaim, no priority preemption)

unreserved-priority

0

borrowWithinCohort: LowerPriority — preempts lower-priority borrowers

user-<name>

User’s reservation

reclaimWithinCohort: Any — reclaims its own protected quota from borrowers

  1. 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 gpu

    If you created a reservation in Exercise 1, the Cohort’s nvidia.com/gpu will show less than 8 — the booking app reduced it by the reserved amount to prevent double-counting.

  2. Check the WorkloadPriorityClasses:

    oc get workloadpriorityclasses

    Higher priority workloads are admitted first and can preempt lower priority ones (within preemption policy rules).

  3. user1: Cancel booking

    Acting as: user1
    Return to the OpenShift Console as user1.

  4. Navigate to GPU Booking > Bookings and click My Bookings.

  5. 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: Any to 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.