Configurable Preemptions

Declarative, rule-based preemption policies and sliding-window preemption limits for custom candidate selection.
Feature state alpha since Kueue v0.20

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 PrioritizePreemptorWorkloads feature gate, hero jobs keep priority over other ClusterQueues 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 PreemptionLimit across 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. Leaving candidateSelectors empty yields no candidates and disallows preemptions for that rule.
  • Preemptor selectors (preemptorSelector and preemptorPriorityClassSelector) (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.

TriggerDescription
AlwaysMatching candidates are contributed unconditionally during configurable preemption evaluation.
InsufficientQuotaMatching candidates are contributed only if preempting classical or Fair Sharing candidates and Always candidates does not yield sufficient quota to admit the incoming workload.
QuotaFeasibleAndInsufficientTopologyMatching 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).

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 same LocalQueue as the preemptor (matching name and namespace).
  • WithinClusterQueue: Candidate must belong to the exact same ClusterQueue as the preemptor.
  • WithinParentCohort: Candidate belongs to a ClusterQueue sharing the immediate parent Cohort, or to the preemptor’s own ClusterQueue (even if standalone without a parent Cohort).
  • WithinCohortTree: Candidate belongs to any ClusterQueue within the same root Cohort hierarchy, or to the preemptor’s own ClusterQueue (even if standalone without a parent Cohort).
  • AnyClusterQueue: No relationship constraint; candidates can be selected from any ClusterQueue in 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 in Workload.spec.priority.
    • Boosted: Compares effective priority values adjusted by priority boosting (see priorityBoost in 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)

Feature state alpha since Kueue v0.21

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 API group and kind of their priority class:
    • group: kueue.x-k8s.io and kind: WorkloadPriorityClass: Matches workloads using a Kueue WorkloadPriorityClass.
    • group: scheduling.k8s.io and kind: PriorityClass: Matches workloads using a Kubernetes Pod PriorityClass.
    • Workloads without a priorityClassRef do not match when sourceRef is set. If omitted, priority classes of either source match.
  • nameExpressions (Optional): A non-empty list of selector requirements (up to 16 items) matched against Workload.spec.priorityClassRef.name (all requirements must be satisfied):
    • operator (Required):
      • In: Candidate’s spec.priorityClassRef.name must match one of the listed values (workloads without a priorityClassRef do not match).
      • NotIn: Candidate’s spec.priorityClassRef.name must not match any of the listed values (workloads without a priorityClassRef always 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)

Feature state alpha since Kueue v0.21

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 the Admitted state across admission cycles (the sum of Workload.status.accumulatedPastExecutionTimeSeconds and elapsed time since the current Admitted transition, if currently admitted).
  • sinceCreation (Optional): Filters candidates by workload age, measured from Workload.metadata.creationTimestamp until 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. For execution, 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, setting sinceCreation.comparison: LessThan selects 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 negative fallbackValue makes 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 of comparison, minValue, or maxValue is set, the constraint checks only that the candidate has the label key with a valid integer value.

Label selectors (labelSelector and clusterQueueSelector)

Optional. Standard Kubernetes label selectors:

  • labelSelector: Filters candidate Workload metadata.
  • clusterQueueSelector: Filters target ClusterQueue metadata.

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 incoming Workload metadata.
  • preemptorPriorityClassSelector: Filters incoming workloads by Workload.spec.priorityClassRef using sourceRef and nameExpressions (with the same semantics as priorityClassSelector in 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 ...

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:

  1. Classical or Fair Sharing candidates first: The globally configured classical or Fair Sharing preemption algorithm evaluates ClusterQueue.spec.preemption and yields its candidates in its usual order, unchanged.
  2. Configurable candidates appended tier by tier: If classical or Fair Sharing candidates do not make the preemptor fit, Kueue appends candidates from PreemptionConfig rules in trigger order: Always, then InsufficientQuota (if quota still does not fit), then QuotaFeasibleAndInsufficientTopology (if quota fits, but topology placement fails). Within each trigger tier, candidates are deduplicated and sorted using the default preemption candidate ordering.
  3. 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 PreemptionConfig rules. 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.
  4. 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.
  5. Selective control:
    • To use only PreemptionConfig rules and disable classical or Fair Sharing preemption candidates, set spec.preemption.reclaimWithinCohort: Never, spec.preemption.withinClusterQueue: Never, and (if configured) spec.preemption.borrowWithinCohort.policy: Never on the ClusterQueue.
    • To use only classical or Fair Sharing preemption, omit the kueue.x-k8s.io/preemption-config-name annotation.

Preemption limits

Feature state alpha since Kueue v0.21

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.

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:

AggregationDescriptionStatus count key
GlobalRestricts the total number of matching configurable preemption events across the entire cluster."Global"
ByPreemptorClusterQueueRestricts the number of matching preemption events initiated by workloads from each preemptor ClusterQueue.<ClusterQueue name>
ByPreempteeClusterQueueRestricts the number of matching preemption events targeting workloads running in each preemptee ClusterQueue.<ClusterQueue name>
ByPreempteeWorkloadRestricts 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 Kubernetes LabelSelector selecting PreemptionConfig objects by label. An empty selector ({}) matches all PreemptionConfig objects.
  • preemptorClusterQueueSelector (Optional): Standard Kubernetes LabelSelector selecting the preempting workload’s ClusterQueue. If omitted, applies to preemptors from all ClusterQueues.
  • preempteeClusterQueueSelector (Optional): Standard Kubernetes LabelSelector selecting the target workload’s ClusterQueue. If omitted, applies to preemptees in all ClusterQueues.
  • limit (Required, integer >= 0): Maximum number of issued (preemptor, preemptee) preemption events permitted per aggregation key within the sliding window. Setting limit: 0 disables matching configurable preemptions while the limit is active.
  • windowSeconds (Required, integer 1 to 604800): 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 PreemptionLimit resources, 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 as limit: 0 or a workload that alone requires more evictions than spec.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 PreemptionLimit resources are loaded. For strict protection of mission-critical workloads or queues, exclude them directly using labelSelector or clusterQueueSelector in your PreemptionConfig rules rather than relying solely on a PreemptionLimit with limit: 0.
  • Increasing windowSeconds: Expired timestamps are periodically pruned based on the active window. Increasing windowSeconds does not restore events that were already pruned under the shorter window.
  • Entity tracking by name: Events are keyed by ClusterQueue name 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’s aggregation or any selector (configSelector, preemptorClusterQueueSelector, or preempteeClusterQueueSelector) resets its recorded in-memory counts. Changing only limit or windowSeconds preserves 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 to Preempted.
  • underlyingCause: Identifies the PreemptionConfig name 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 numericLabels with comparison: LessThan on job sizes.
  • Enabling the PrioritizePreemptorWorkloads feature gate when rules allow same-priority preemption across ClusterQueues (such as topology defragmentation), so evicted workloads from other queues are not readmitted ahead of the waiting preemptor (within the same ClusterQueue, keep the default BestEffortFIFO queueing strategy so the waiting preemptor stays at the head of the queue; StrictFIFO does 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 PreemptionLimit guardrails (such as Global, ByPreempteeWorkload, or conservative rollout limits on new PreemptionConfig resources).

What’s next