Configurable Preemptions
Configurable Preemptions is an advanced capability intended for power users and cluster administrators. Custom preemption rules carry inherent operational risks: if rules are misconfigured or symmetric (for example, jobs can mutually preempt one another), they can trigger cascading preemptions and continuous job disruptions across the cluster. Use Preemption Limits (PreemptionLimit) to cap preemption rates and limit blast radius when rolling out new configurations.
Configurable Preemptions introduces a declarative mechanism to define when preemption should occur and which workloads are eligible for eviction. It complements Kueue’s existing Classic Preemption and Fair Sharing algorithms by enabling policies for complex operational scenarios, such as:
- Topology defragmentation: Allowing distributed workloads requiring specific physical topology domains (such as multi-node GPU or TPU training jobs under Topology-Aware Scheduling) to preempt smaller workloads that fragment the cluster, even when all workloads are within their nominal quotas.
- Mission-critical “hero” workloads: Allowing dedicated, access-restricted queues with elevated preemption privileges to evict workloads across queues even when those workloads are within nominal quota (quota borrowing applies within the same cohort tree and remains subject to configured borrowing and lending limits; evicting workloads outside the cohort tree frees physical node capacity under TAS rather than quota). When combined with the
PrioritizePreemptorWorkloadsfeature gate, hero jobs keep priority over otherClusterQueues while evictions complete and gain admission without extra cluster-wide modifications. - Granular priority, label, and time-based rules: Evaluating candidates by priority, priority class, custom labels, cumulative execution duration, or workload age.
- Preemption rate limiting: Bounding the rate of configurable preemptions with
PreemptionLimitacross global, queue, or individual workload scopes.
To use Configurable Preemptions, install the Alpha CRDs (PreemptionConfig and PreemptionLimit) and enable the ConfigurablePreemptions feature gate. To enforce PreemptionLimit resources, also enable the ConfigurablePreemptionLimits feature gate.
Architecture and API overview
Configurable Preemptions is driven by the cluster-scoped PreemptionConfig custom resource (kueue.x-k8s.io/v1alpha1, short name preempcfg; see the v1alpha1 API Reference). It contains a list of up to 64 named rules, each defining:
- Activation policy (
activationPolicy): The trigger that activates the rule during a scheduling cycle. - Candidate selectors (
candidateSelectors): Up to 32 criteria that identify which running workloads may be considered for preemption. LeavingcandidateSelectorsempty yields no candidates and disallows preemptions for that rule. - Preemptor selectors (
preemptorSelectorandpreemptorPriorityClassSelector) (Optional): Criteria that restrict which incoming workloads can activate the rule.
Here is a complete example of a PreemptionConfig resource:
apiVersion: kueue.x-k8s.io/v1alpha1
kind: PreemptionConfig
metadata:
name: "topology-defragmentation"
spec:
rules:
- name: "evict-smaller-jobs-for-large-topology"
activationPolicy:
trigger: "QuotaFeasibleAndInsufficientTopology"
candidateSelectors:
- scope: "AnyClusterQueue"
priority:
mode: "Base"
comparison: "LessThanOrEqual"
numericLabels:
- key: "example.com/node-count"
comparison: "LessThan"
fallbackValue: 0
clusterQueueSelector:
matchExpressions:
- key: "example.com/protection-tier"
operator: "NotIn"
values: ["infrastructure"]
Activation triggers
The activationPolicy.trigger field determines when a preemption rule becomes active during admission evaluation. Rules are evaluated incrementally in tier order: Always first, then InsufficientQuota, and finally QuotaFeasibleAndInsufficientTopology.
| Trigger | Description |
|---|---|
Always | Matching candidates are contributed unconditionally during configurable preemption evaluation. |
InsufficientQuota | Matching candidates are contributed only if preempting classical or Fair Sharing candidates and Always candidates does not yield sufficient quota to admit the incoming workload. |
QuotaFeasibleAndInsufficientTopology | Matching candidates are contributed only if quota is already feasible for the preemptor under at least one eligible flavor assignment (after classical or Fair Sharing preemption, Always rules, and applicable InsufficientQuota rules), but the workload cannot be admitted because no placement satisfies its physical topology requirements (see Topology-Aware Scheduling). |
Normally, a candidate must consume at least one flavor resource that needs preemption. When both the preemptor’s needed flavor and a candidate’s Topology-Aware Scheduling flavor use kubernetes.io/hostname as their lowest topology level and share physical nodes, candidate matching widens to include workloads holding TAS capacity on those shared nodes, regardless of which flavor or resource they consume (while still applying the rule’s candidateSelectors). Preempting those workloads frees physical node capacity in the preemptor’s topology. Overlapping topology domains are considered across all triggers, not only QuotaFeasibleAndInsufficientTopology.
Candidate selectors
Each rule specifies candidateSelectors to filter eligible preemption victims. Candidates resulting from multiple selectors within a rule (or across rules in the same trigger tier) are combined into a single deduplicated set. Within a single selector, all configured constraints are combined using logical AND (a candidate must satisfy every specified constraint).
Relational scope (scope)
Required. The scope defines the relational boundary between the preemptor and candidate workloads:
WithinLocalQueue: Candidate must belong to the exact sameLocalQueueas the preemptor (matching name and namespace).WithinClusterQueue: Candidate must belong to the exact sameClusterQueueas the preemptor.WithinParentCohort: Candidate belongs to aClusterQueuesharing the immediate parentCohort, or to the preemptor’s ownClusterQueue(even if standalone without a parentCohort).WithinCohortTree: Candidate belongs to anyClusterQueuewithin the same rootCohorthierarchy, or to the preemptor’s ownClusterQueue(even if standalone without a parentCohort).AnyClusterQueue: No relationship constraint; candidates can be selected from anyClusterQueuein the cluster.
Priority constraints (priority)
Optional. Defines priority comparison criteria against the incoming preemptor workload. If specified, both mode and comparison are required:
mode(Required):Base: Compares raw priority values assigned inWorkload.spec.priority.Boosted: Compares effective priority values adjusted by priority boosting (seepriorityBoostin the Workload spec).
comparison(Required):LessThan: Candidate priority < Preemptor priority.LessThanOrEqual: Candidate priority <= Preemptor priority.GreaterThan: Candidate priority > Preemptor priority.GreaterThanOrEqual: Candidate priority >= Preemptor priority.
Priority class selector (priorityClassSelector)
Optional. Filters candidate workloads by their priority class (Workload.spec.priorityClassRef, populated by Kueue for both WorkloadPriorityClass and Pod PriorityClass). When both sourceRef and nameExpressions are specified, a candidate must satisfy both:
sourceRef(Optional): Filters workloads by the APIgroupandkindof their priority class:group: kueue.x-k8s.ioandkind: WorkloadPriorityClass: Matches workloads using a KueueWorkloadPriorityClass.group: scheduling.k8s.ioandkind: PriorityClass: Matches workloads using a Kubernetes PodPriorityClass.- Workloads without a
priorityClassRefdo not match whensourceRefis set. If omitted, priority classes of either source match.
nameExpressions(Optional): A non-empty list of selector requirements (up to 16 items) matched againstWorkload.spec.priorityClassRef.name(all requirements must be satisfied):operator(Required):In: Candidate’sspec.priorityClassRef.namemust match one of the listedvalues(workloads without apriorityClassRefdo not match).NotIn: Candidate’sspec.priorityClassRef.namemust not match any of the listedvalues(workloads without apriorityClassRefalways match).
values(Required): A non-empty set of priority class names (up to 16 items).
When WorkloadPriorityClassDefaulting is enabled and a "default" WorkloadPriorityClass exists, or when a globalDefault Pod PriorityClass is configured, its name (for example, "default") can be used in nameExpressions to match or exclude workloads that do not explicitly specify a priority class.
Time constraints (timeConstraints)
Optional. Filters candidate workloads based on elapsed execution duration or workload age (see PreemptionConfigTimeConstraints). When specified, at least one of execution or sinceCreation must be set; if both are set, a candidate must satisfy both (logical AND):
execution(Optional): Filters candidates by cumulative execution duration, measured as total time spent in theAdmittedstate across admission cycles (the sum ofWorkload.status.accumulatedPastExecutionTimeSecondsand elapsed time since the currentAdmittedtransition, if currently admitted).sinceCreation(Optional): Filters candidates by workload age, measured fromWorkload.metadata.creationTimestampuntil preemption evaluation.
Each constraint (execution or sinceCreation) accepts the following fields (at least one must be set; multiple fields are ANDed, and minSeconds must be less than or equal to maxSeconds when both are specified):
minSeconds(Optional, integer >= 1): Minimum elapsed duration in seconds (inclusive) a candidate must have accumulated. Forexecution, this protects a workload during its initial cumulative runtime, though execution time accumulates across admission cycles and does not reset on readmission.maxSeconds(Optional, integer >= 1): Maximum elapsed duration in seconds (inclusive) a candidate may have accumulated. Useful for protecting older or long-running workloads nearing completion or SLA deadlines.comparison(Optional): Compares the candidate’s duration against the preemptor’s duration for the same metric (LessThan,LessThanOrEqual,GreaterThan,GreaterThanOrEqual). For example, settingsinceCreation.comparison: LessThanselects only candidates created more recently than the preemptor.
When a pending workload cannot be admitted only because candidates have not yet reached a lower time threshold (such as minSeconds), Kueue automatically re-evaluates the workload once a candidate becomes eligible.
Custom numeric labels (numericLabels)
Optional. A list of up to 32 numeric label constraints allowing candidate filtering based on integer workload labels (such as number of GPUs or TPUs, slice index, or node count). Multiple numeric label constraints in a selector are joined using an AND rule (all constraints must be satisfied):
key(Required): The workload label key containing strings that can be parsed as integers.comparison(Optional): How the candidate’s label value compares to the preemptor’s label value (LessThan,LessThanOrEqual,GreaterThan,GreaterThanOrEqual).fallbackValue(Optional): Integer value assumed if a workload does not have the label or the value cannot be parsed as an integer. Because Kubernetes label values cannot start with-, a negativefallbackValuemakes unlabeled workloads compare smaller than any labeled workload. If omitted, workloads lacking the label are treated as incomparable and excluded.minValue/maxValue(Optional, integer >= 0): Inclusive lower and upper boundaries for the candidate’s label value (minValue <= maxValue). If none ofcomparison,minValue, ormaxValueis set, the constraint checks only that the candidate has the label key with a valid integer value.
Custom labels from high-level jobs (such as Job, JobSet, or RayCluster) are not automatically copied to the Kueue Workload resource unless their keys are listed in integrations.labelKeysToCopy in your Kueue Configuration. Ensure your custom numeric label keys are configured for copying.
Label selectors (labelSelector and clusterQueueSelector)
Optional. Standard Kubernetes label selectors:
labelSelector: Filters candidateWorkloadmetadata.clusterQueueSelector: Filters targetClusterQueuemetadata.
Preemptor selectors
Optional. A rule can restrict which incoming (preempting) workloads are allowed to activate it. When both selectors are specified, an incoming workload must satisfy both (logical AND). If omitted, any incoming workload in the queue can trigger the rule:
preemptorSelector: A standard Kubernetes label selector filtering incomingWorkloadmetadata.preemptorPriorityClassSelector: Filters incoming workloads byWorkload.spec.priorityClassRefusingsourceRefandnameExpressions(with the same semantics aspriorityClassSelectorin candidate selectors).
Referencing PreemptionConfig on a ClusterQueue
Attach a PreemptionConfig to a ClusterQueue using the kueue.x-k8s.io/preemption-config-name annotation:
apiVersion: kueue.x-k8s.io/v1beta2
kind: ClusterQueue
metadata:
name: "distributed-training-cq"
annotations:
kueue.x-k8s.io/preemption-config-name: "topology-defragmentation"
spec:
preemption:
reclaimWithinCohort: LowerPriority
withinClusterQueue: LowerPriority
# ... remaining ClusterQueue fields ...
In Alpha, PreemptionConfig works alongside ClusterQueue.spec.preemption. Candidates selected by PreemptionConfig rules are appended after candidates selected by classical or Fair Sharing preemption.
Candidate evaluation order and classical preemption interaction
During preemption evaluation in the scheduler, candidates from ClusterQueue.spec.preemption and the referenced PreemptionConfig are evaluated in the following order:
- Classical or Fair Sharing candidates first: The globally configured classical or Fair Sharing preemption algorithm evaluates
ClusterQueue.spec.preemptionand yields its candidates in its usual order, unchanged. - Configurable candidates appended tier by tier: If classical or Fair Sharing candidates do not make the preemptor fit, Kueue appends candidates from
PreemptionConfigrules in trigger order:Always, thenInsufficientQuota(if quota still does not fit), thenQuotaFeasibleAndInsufficientTopology(if quota fits, but topology placement fails). Within each trigger tier, candidates are deduplicated and sorted using the default preemption candidate ordering. - No duplicate selection: Each workload is considered at most once during a preemption attempt, so a workload already selected by classical or Fair Sharing preemption is not selected again by
PreemptionConfigrules. Classical and Fair Sharing candidates are always evaluated before configurable candidates, though reverse-order backfilling can still restore an earlier classical or Fair Sharing candidate if a later configurable candidate alone makes the incoming workload fit. - Per-attempt behavior and minimal victim set: For classical preemption (which may run separate attempts with and without borrowing), configurable candidates are appended at the end of each attempt. For Fair Sharing, they are appended after all configured Fair Sharing strategies are tried. Once the preemptor fits, reverse-order backfilling runs across the selected candidates to keep the evicted set minimal.
- Selective control:
- To use only
PreemptionConfigrules and disable classical or Fair Sharing preemption candidates, setspec.preemption.reclaimWithinCohort: Never,spec.preemption.withinClusterQueue: Never, and (if configured)spec.preemption.borrowWithinCohort.policy: Neveron theClusterQueue. - To use only classical or Fair Sharing preemption, omit the
kueue.x-k8s.io/preemption-config-nameannotation.
- To use only
In Beta+, PreemptionConfig will achieve full feature parity with classical and Fair Sharing preemption. The strategies will become mutually exclusive via a formal API field on ClusterQueueSpec, and the Alpha annotation will be retired.
Preemption limits
Preemption Limits introduce sliding-window rate-limiting guardrails for Configurable Preemptions via the cluster-scoped PreemptionLimit custom resource (kueue.x-k8s.io/v1alpha1, short name preemplim; see the v1alpha1 API Reference). Administrators can use PreemptionLimit to roll out new PreemptionConfig rules incrementally, bound cluster-wide and per-ClusterQueue disruption rates, and prevent individual workloads from repeated evictions.
To enforce PreemptionLimit resources, install the Alpha CRDs and enable both the ConfigurablePreemptions and ConfigurablePreemptionLimits feature gates. When ConfigurablePreemptionLimits is disabled, PreemptionLimit resources are not enforced and Configurable Preemptions are not rate-limited.
In Alpha, PreemptionLimit applies only to preemptions triggered by PreemptionConfig rules. Classical and Fair Sharing preemptions configured through ClusterQueue.spec.preemption are not constrained by PreemptionLimit.
Here is an example PreemptionLimit that allows at most 10 configurable preemptions across the cluster in any 5-minute sliding window:
apiVersion: kueue.x-k8s.io/v1alpha1
kind: PreemptionLimit
metadata:
name: "global-preemption-rate-limit"
spec:
aggregation: "Global"
configSelector: {}
limit: 10
windowSeconds: 300
Aggregation levels (aggregation)
Required. The aggregation field sets the grouping key used to count issued (preemptor, preemptee) preemption events within the sliding window:
| Aggregation | Description | Status count key |
|---|---|---|
Global | Restricts the total number of matching configurable preemption events across the entire cluster. | "Global" |
ByPreemptorClusterQueue | Restricts the number of matching preemption events initiated by workloads from each preemptor ClusterQueue. | <ClusterQueue name> |
ByPreempteeClusterQueue | Restricts the number of matching preemption events targeting workloads running in each preemptee ClusterQueue. | <ClusterQueue name> |
ByPreempteeWorkload | Restricts how many times an individual Workload can be preempted within the window. | <namespace>/<workload-name> |
Selectors and sliding window
Each PreemptionLimit scopes which configurable preemptions it counts and constrains using these fields:
configSelector(Required): Standard KubernetesLabelSelectorselectingPreemptionConfigobjects by label. An empty selector ({}) matches allPreemptionConfigobjects.preemptorClusterQueueSelector(Optional): Standard KubernetesLabelSelectorselecting the preempting workload’sClusterQueue. If omitted, applies to preemptors from allClusterQueues.preempteeClusterQueueSelector(Optional): Standard KubernetesLabelSelectorselecting the target workload’sClusterQueue. If omitted, applies to preemptees in allClusterQueues.limit(Required, integer >= 0): Maximum number of issued(preemptor, preemptee)preemption events permitted per aggregation key within the sliding window. Settinglimit: 0disables matching configurable preemptions while the limit is active.windowSeconds(Required, integer1to604800): Duration of the sliding time window in seconds (from 1 second up to 7 days).
Kueue does not automatically add labels to ClusterQueue or PreemptionConfig resources. Administrators must label them manually to match PreemptionLimit selectors.
Enforcement behavior and operational caveats
- Multiple matching limits: If a candidate preemption matches multiple
PreemptionLimitresources, budget must be available in all of them for the candidate to be selected. - Already-evicted candidates: Candidates already marked as evicted (or with an eviction already in progress) do not consume limit budget and remain selectable even when an applicable limit is exhausted or set to
0. - Greedy candidate evaluation: Limits are checked greedily as candidates are scanned in order before reverse-order backfilling runs. Earlier candidates can consume remaining budget and cause later, larger candidates to be skipped even if backfilling would have kept only the larger candidate.
- Automatic re-evaluation when a window expires: When a workload is blocked by an exhausted
PreemptionLimit, Kueue automatically re-evaluates it once the oldest blocking event exits the sliding window (waiting does not unblock non-expiring blocks such aslimit: 0or a workload that alone requires more evictions thanspec.limit). - In-memory state across restarts and leader failovers: Preemption event timestamps are tracked in memory only (not persisted in etcd). Controller restarts, upgrades, or leader failovers reset active counters and can briefly leave limits unenforced until existing
PreemptionLimitresources are loaded. For strict protection of mission-critical workloads or queues, exclude them directly usinglabelSelectororclusterQueueSelectorin yourPreemptionConfigrules rather than relying solely on aPreemptionLimitwithlimit: 0. - Increasing
windowSeconds: Expired timestamps are periodically pruned based on the active window. IncreasingwindowSecondsdoes not restore events that were already pruned under the shorter window. - Entity tracking by name: Events are keyed by
ClusterQueuename or<namespace>/<workload-name>rather than UID. Deleting and recreating an object with the same name within the active window retains its recorded events. - Selector or aggregation changes reset counters: Modifying a
PreemptionLimit’saggregationor any selector (configSelector,preemptorClusterQueueSelector, orpreempteeClusterQueueSelector) resets its recorded in-memory counts. Changing onlylimitorwindowSecondspreserves previously recorded events.
Observability
To provide visibility into why a workload was preempted or blocked when custom rules and limits are used, Kueue surfaces configurable preemption details across workload status and PreemptionLimit status:
Eviction scheduling stats
Kueue records detailed eviction information in Workload.status.schedulingStats.evictions:
reason: Set toPreempted.underlyingCause: Identifies thePreemptionConfigname that caused the preemption.
Workload status conditions
When a workload is preempted by a PreemptionConfig rule, Kueue sets two conditions in Workload.status.conditions:
status:
conditions:
- type: Evicted
status: "True"
reason: Preempted
message: "Preempted by default/hero-job-xyz because of preemption config hero-workloads-preemption-config rule hero-preempt-lower-priority/0"
- type: Preempted
status: "True"
reason: ConfigurablePreemption
message: "Preempted by default/hero-job-xyz because of preemption config hero-workloads-preemption-config rule hero-preempt-lower-priority/0"
When a pending workload cannot be admitted because candidate selection is blocked by an active PreemptionLimit, its QuotaReserved condition (status: "False") message includes the blocking limit name, aggregation, and (when waiting for recorded events to expire can unblock it) the UTC timestamp when the limit window elapses (for example, preemptions blocked by PreemptionLimit <name> (aggregation <aggregation>) until <timestamp>, or without until <timestamp> for non-expiring blocks such as limit: 0).
PreemptionLimit status
Kueue periodically refreshes PreemptionLimit.status.window (approximately once per minute) with informational counts of recorded preemptions within the active sliding window:
status:
window:
lastUpdateTime: "2026-11-23T12:00:00Z"
topAggregatedCounts:
- key: "team-a-cq"
value: 3
topAggregatedCounts is capped at the top 100 aggregation keys to stay within CRD object size limits and is intended for observability only; scheduling enforces limits directly from the live in-memory state.
Preventing preemption flapping
When authoring preemption rules across queues (especially with AnyClusterQueue or WithinCohortTree), ensure that rules are strictly asymmetric: if Workload A can preempt Workload B, Workload B must not be able to preempt Workload A in return.
You can reduce flapping and bound disruption by:
- Requiring
priority.comparison: LessThan. - Enforcing
numericLabelswithcomparison: LessThanon job sizes. - Enabling the
PrioritizePreemptorWorkloadsfeature gate when rules allow same-priority preemption acrossClusterQueues (such as topology defragmentation), so evicted workloads from other queues are not readmitted ahead of the waiting preemptor (within the sameClusterQueue, keep the defaultBestEffortFIFOqueueing strategy so the waiting preemptor stays at the head of the queue;StrictFIFOdoes not keep preemptors sticky). - Protecting workloads during their initial cumulative execution time with
timeConstraints.execution.minSeconds(note that execution time accumulates across admission cycles and does not reset on readmission). - Restricting preemption rights to dedicated high-priority queues.
- Adding
PreemptionLimitguardrails (such asGlobal,ByPreempteeWorkload, or conservative rollout limits on newPreemptionConfigresources).
What’s next
- Follow the Use Custom Preemption Configurations guide for hands-on configuration steps and practical scenarios.
- Read Preemption to understand Classic Preemption and Fair Sharing algorithms.
- Read Topology-Aware Scheduling to see how physical network topology and defragmentation interact.
- Learn about Workload Priority Class to configure workload priorities.
- Inspect the full schemas for
PreemptionConfigandPreemptionLimitin the v1alpha1 API Reference.
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.