Use Custom Preemption Configurations
This guide demonstrates how to configure and verify Configurable Preemptions in Kueue. You will learn how to:
- Install the Alpha CRDs and enable the
ConfigurablePreemptionsandConfigurablePreemptionLimitsfeature gates. - Configure a dedicated Hero Workload Preemption policy for an access-restricted
ClusterQueue. - Configure a Topology Defragmentation policy for general-purpose workloads.
- Configure Priority Class and Time-Based candidate filters to protect intermediate tiers, short-running jobs during their initial execution window, or aging workloads.
- Configure Preemption Limits (
PreemptionLimit) to safely roll out new configurations, limit per-workload churn, and bound per-queue preemption rates. - Verify preemption outcomes and limit status via workload conditions, eviction stats,
PreemptionLimitstatus, and metrics.
Before you begin
Make sure the following conditions are met:
- A Kubernetes cluster is running.
- The
kubectlcommand-line tool has communication with your cluster. - Kueue is installed.
- You have permissions to install CRDs and manage cluster-scoped resources (
PreemptionConfig,PreemptionLimit, andClusterQueue).
Install the alpha APIs
PreemptionConfig and PreemptionLimit are Alpha APIs (kueue.x-k8s.io/v1alpha1). Kueue does not install their CRDs by default. Install them before enabling the feature gates.
If you installed Kueue with kubectl, apply the Alpha CRDs manifest:
kubectl apply --server-side -f https://github.com/kubernetes-sigs/kueue/releases/download/v0.21.0/alpha-crds.yaml
If you installed Kueue with Helm, set enableAlphaAPIs to true:
helm upgrade kueue https://github.com/kubernetes-sigs/kueue/releases/download/v0.21.0/kueue-0.21.0.tgz \
--namespace kueue-system \
--reuse-values \
--set enableAlphaAPIs=true
Enable the feature gates
Enable ConfigurablePreemptions in your kueue-manager-config (see Change the feature gates configuration). Enable ConfigurablePreemptionLimits as well if you plan to use PreemptionLimit resources (it requires ConfigurablePreemptions). Enabling PrioritizePreemptorWorkloads is also recommended for hero workload scenarios and for cross-queue topology defragmentation (or any PreemptionConfig that permits same-priority preemption across ClusterQueues): without it, evicted smaller workloads in other queues can be readmitted ahead of the waiting preemptor (for example, based on creation timestamp ordering), leading to repeated preemption loops (within a single ClusterQueue, keep the default BestEffortFIFO queueing strategy rather than StrictFIFO so the waiting preemptor remains at the head of its queue):
apiVersion: config.kueue.x-k8s.io/v1beta2
kind: Configuration
featureGates:
ConfigurablePreemptions: true
ConfigurablePreemptionLimits: true
PrioritizePreemptorWorkloads: true
Restart kueue-controller-manager after updating kueue-manager-config so the new feature gates take effect. If you installed Kueue with Helm, set these flags in controllerManager.featureGates in your Helm values instead so future upgrades retain them.
Configuration scenarios
Rather than combining multiple concerns into a single configuration, define distinct PreemptionConfig resources tailored to specific queue purposes and operational privileges, and pair them with PreemptionLimit guardrails to control disruption rates.
Protecting workloads across classical preemption and peer queues
Before configuring scenarios that exclude or protect specific workloads (using clusterQueueSelector, labelSelector, priorityClassSelector, timeConstraints, or PreemptionLimit), keep two interactions in mind:
- Disable classical and Fair Sharing preemption when relying on custom guardrails: In Alpha, candidates from
ClusterQueue.spec.preemptionare evaluated beforePreemptionConfigrules without checking yourPreemptionConfigselectors orPreemptionLimitresources. To prevent classical or Fair Sharing preemption from bypassing those guardrails, setspec.preemption.reclaimWithinCohort: Never,spec.preemption.withinClusterQueue: Never, and (if configured)spec.preemption.borrowWithinCohort.policy: Neveron the preemptingClusterQueue, as well as on any cohort peerClusterQueues that should not evict protected workloads via classical or Fair Sharing preemption. - Align peer
PreemptionConfigrules: Candidate rules are evaluated from the preemptingClusterQueue’s referencedPreemptionConfig, not the victim’s. Settingspec.preemptionpolicies toNeverdoes not block a peerClusterQueue’sPreemptionConfig(for example, a rule withscope: AnyClusterQueueorWithinCohortTree) from selecting workloads in your queue. To enforce a protection rule across queues, apply the matching exclusion selectors ortimeConstraintsin every peerPreemptionConfigthat can select workloads from the protected queue.
Scenario: Hero workload preemption (restricted queue)
In this scenario, a dedicated, access-restricted ClusterQueue is established for top-priority distributed workloads (“hero workloads”). When hero workloads lack quota or contiguous topology, they are permitted to preempt lower-priority workloads across the cluster while respecting protection labels on mission-critical queues.
Define the PreemptionConfig
apiVersion: kueue.x-k8s.io/v1alpha1
kind: PreemptionConfig
metadata:
name: "hero-workloads-preemption-config"
spec:
rules:
- name: "hero-preempt-lower-priority"
activationPolicy:
trigger: "Always"
candidateSelectors:
- scope: "AnyClusterQueue"
priority:
mode: "Base"
comparison: "LessThan"
clusterQueueSelector:
matchExpressions:
- key: "example.com/protection-tier"
operator: "NotIn"
values: ["mission-critical"]
How it works:
- Trigger:
Alwaysevaluates candidates unconditionally whenever configurable preemption runs. This allows the hero workload to preempt lower-priority workloads both to reclaim quota and to clear physical topology constraints under Topology-Aware Scheduling. - Scope:
AnyClusterQueuesearches across all queues in the cluster so physical topology domains (such as racks or blocks) can be unblocked cluster-wide. - Elevated privileges: Workloads in this queue can evict lower-priority workloads across queues even if those target workloads are running within their nominal quota (quota borrowing applies within the same cohort tree and respects configured borrowing and lending limits; evictions outside the cohort tree free physical node capacity under Topology-Aware Scheduling rather than quota).
- Protection guardrail:
clusterQueueSelectorensures thatClusterQueues labeledexample.com/protection-tier: mission-criticalare never selected for preemption.
Attach to the restricted ClusterQueue
Attach the PreemptionConfig to your dedicated hero ClusterQueue:
apiVersion: kueue.x-k8s.io/v1beta2
kind: ClusterQueue
metadata:
name: "hero-jobs-cq"
labels:
example.com/hero-queue: "true"
annotations:
kueue.x-k8s.io/preemption-config-name: "hero-workloads-preemption-config"
spec:
preemption:
reclaimWithinCohort: Never
withinClusterQueue: Never
# ... resource groups, flavors, and quotas ...
See Protecting workloads across classical preemption and peer queues for why spec.preemption is set to Never on hero-jobs-cq so clusterQueueSelector is strictly honored.
Scenario: Topology defragmentation (general queue)
In this scenario, large distributed jobs require contiguous physical topology (such as full host blocks or racks under Topology-Aware Scheduling). A large workload may have feasible quota, but cannot be scheduled because smaller workloads are fragmenting the physical topology.
Define the PreemptionConfig
apiVersion: kueue.x-k8s.io/v1alpha1
kind: PreemptionConfig
metadata:
name: "topology-defrag-preemption-config"
labels:
example.com/rollout-stage: "experimental"
spec:
rules:
- name: "preempt-lower-priority-within-cohort"
activationPolicy:
trigger: "InsufficientQuota"
candidateSelectors:
- scope: "WithinCohortTree"
priority:
mode: "Base"
comparison: "LessThan"
labelSelector:
matchExpressions:
- key: "example.com/workload-tier"
operator: "NotIn"
values: ["mission-critical"]
- name: "evict-smaller-jobs-for-topology"
activationPolicy:
trigger: "QuotaFeasibleAndInsufficientTopology"
candidateSelectors:
- scope: "AnyClusterQueue"
priority:
mode: "Base"
comparison: "LessThanOrEqual"
numericLabels:
- key: "example.com/node-count"
comparison: "LessThan"
labelSelector:
matchExpressions:
- key: "example.com/workload-tier"
operator: "NotIn"
values: ["mission-critical"]
How it works:
Rule
preempt-lower-priority-within-cohort:- Trigger:
InsufficientQuotaactivates when the incoming workload lacks sufficient quota to be admitted. - Scope:
WithinCohortTreerestricts quota reclamation to the cohort hierarchy (since borrowing outside the cohort tree is not permitted). - Protection guardrail:
labelSelectorprevents evicting lower-priority workloads labeledexample.com/workload-tier: mission-critical.
- Trigger:
Rule
evict-smaller-jobs-for-topology:- Trigger:
QuotaFeasibleAndInsufficientTopologyactivates only when quota is already feasible for the incoming job under at least one eligible flavor assignment (after classical or Fair Sharing preemption,Alwaysrules, and any applicableInsufficientQuotarules), but placement is blocked by physical topology constraints.
NoteQuotaFeasibleAndInsufficientTopologydoes not acquire missing quota; it only resolves topology fragmentation once quota feasibility has been satisfied. Combining this trigger with anInsufficientQuotarule ensures workloads can first reclaim quota and then defragment topology.- Scope:
AnyClusterQueuesearches across allClusterQueues in the cluster so topology can be unblocked across physical nodes regardless of cohort relationship. - Asymmetric defragmentation:
numericLabelswithcomparison: LessThanensures that a larger workload (for example,example.com/node-count: "32") can preempt smaller workloads (for example,example.com/node-count: "4"), but a 4-node workload cannot preempt a 32-node workload in return. OmittingfallbackValueensures unlabeled workloads are treated as incomparable and protected from eviction. - Protecting mission-critical workloads: Without explicit exclusion, defragmentation rules could evict smaller mission-critical workloads. The
labelSelectorprevents evicting workloads labeledexample.com/workload-tier: mission-critical.
- Trigger:
Attach to the ClusterQueue
apiVersion: kueue.x-k8s.io/v1beta2
kind: ClusterQueue
metadata:
name: "general-training-cq"
annotations:
kueue.x-k8s.io/preemption-config-name: "topology-defrag-preemption-config"
spec:
preemption:
reclaimWithinCohort: Never
withinClusterQueue: Never
# ... resource groups, flavors, and quotas ...
See Protecting workloads across classical preemption and peer queues for why spec.preemption is set to Never so labelSelector protections are not bypassed. Because evict-smaller-jobs-for-topology permits same-priority preemption (comparison: LessThanOrEqual) across queues, also enable PrioritizePreemptorWorkloads (and keep BestEffortFIFO on the ClusterQueue for same-queue victims) so evicted smaller workloads are not readmitted ahead of the waiting preemptor.
Scenario: Priority threshold for within-ClusterQueue preemption
In a shared ClusterQueue with multiple priority tiers (such as production-high, production-standard, batch-low, and dev-preemptible), you can restrict within-queue preemption so higher-priority workloads only preempt specific low-priority classes while protecting intermediate tiers such as production-standard:
apiVersion: kueue.x-k8s.io/v1alpha1
kind: PreemptionConfig
metadata:
name: "preempt-same-cq-low-priority"
spec:
rules:
- name: "preempt-same-cq-low-priority"
activationPolicy:
trigger: "InsufficientQuota"
candidateSelectors:
- scope: "WithinClusterQueue"
priority:
mode: "Base"
comparison: "LessThan"
priorityClassSelector:
sourceRef:
group: "kueue.x-k8s.io"
kind: "WorkloadPriorityClass"
nameExpressions:
- operator: "In"
values:
- "batch-low"
- "dev-preemptible"
How it works:
- Priority class allowlist (
priorityClassSelector): Combined withpriority(mode: Baseandcomparison: LessThan), only candidates in the sameClusterQueue(WithinClusterQueue) that have strictly lower base priority and reference aWorkloadPriorityClass(sourceRef) namedbatch-lowordev-preemptible(nameExpressionswithoperator: In) are eligible for preemption. Runningproduction-standardworkloads are protected even when aproduction-highworkload arrives. - ClusterQueue setup: Attach this config via
kueue.x-k8s.io/preemption-config-name: "preempt-same-cq-low-priority", and follow Protecting workloads across classical preemption and peer queues so classical preemption or peer rules do not bypasspriorityClassSelector.
Scenario: Time-based workload protection
You can use timeConstraints to protect older workloads (for example, workloads older than 15 minutes that are further along or nearing completion) from eviction, while requiring a minimum cumulative execution duration (for example, 2 minutes) before a workload becomes eligible for preemption:
apiVersion: kueue.x-k8s.io/v1alpha1
kind: PreemptionConfig
metadata:
name: "time-protected-preemption-config"
spec:
rules:
- name: "preempt-eligible-age-window"
activationPolicy:
trigger: "InsufficientQuota"
candidateSelectors:
- scope: "WithinClusterQueue"
priority:
mode: "Boosted"
comparison: "LessThan"
timeConstraints:
execution:
minSeconds: 120
sinceCreation:
maxSeconds: 900
How it works:
- Protect older workloads (
sinceCreation.maxSeconds: 900): Workloads created more than 15 minutes (900 seconds) ago are excluded from preemption candidates, protecting long-running or aging jobs against eviction. (You can also setmaxSecondsunderexecutionto protect workloads based on accumulated runtime instead of creation age.) - Minimum cumulative execution time (
execution.minSeconds: 120): A candidate must have accumulated at least 2 minutes (120 seconds) of total execution time in theAdmittedstate across admission cycles before it becomes eligible for preemption. Because this duration is cumulative across earlier admissions rather than reset on readmission, it protects a workload during its initial runtime, whereas a workload that already accumulated 2 minutes before an earlier eviction can be preempted immediately after readmission. If no candidates have met this threshold yet, Kueue automatically re-evaluates the pending workload once a candidate becomes eligible. - Relative age comparison: To preempt only workloads created more recently than the incoming preemptor, replace
maxSecondswithcomparison: "LessThan"undersinceCreation. - ClusterQueue setup: Attach this config via
kueue.x-k8s.io/preemption-config-name: "time-protected-preemption-config". Protection fromtimeConstraintsapplies only to candidates evaluated under aPreemptionConfigthat sets matchingtimeConstraints; see Protecting workloads across classical preemption and peer queues to ensure neither classical preemption nor peerPreemptionConfigrules bypass it.
Scenario: Rate-limiting configurable preemptions with PreemptionLimit
PreemptionLimit lets you place sliding-window rate limits on configurable preemptions. Ensure the ConfigurablePreemptionLimits feature gate is enabled (alongside ConfigurablePreemptions) before creating PreemptionLimit resources.
Safely roll out a new PreemptionConfig
Label the new PreemptionConfig (as shown with example.com/rollout-stage: "experimental" in topology-defrag-preemption-config above) and cap it to at most 1 preemption per hour while you observe cluster behavior:
apiVersion: kueue.x-k8s.io/v1alpha1
kind: PreemptionLimit
metadata:
name: "experimental-config-rollout-limit"
spec:
aggregation: "Global"
configSelector:
matchLabels:
example.com/rollout-stage: "experimental"
limit: 1
windowSeconds: 3600
As confidence grows, increase spec.limit, shorten spec.windowSeconds, or remove the rollout label from the PreemptionConfig.
Prevent repeated preemptions of the same workload
Limit each workload to at most 1 configurable preemption per day across all PreemptionConfig resources (configSelector: {}), while exempting hero queues labeled example.com/hero-queue: "true":
apiVersion: kueue.x-k8s.io/v1alpha1
kind: PreemptionLimit
metadata:
name: "limit-per-workload-churn"
spec:
aggregation: "ByPreempteeWorkload"
configSelector: {}
preemptorClusterQueueSelector:
matchExpressions:
- key: "example.com/hero-queue"
operator: "NotIn"
values: ["true"]
limit: 1
windowSeconds: 86400
Bound per-queue preemption rates
Give each tenant ClusterQueue an independent preemption budget (for example, at most 10 configurable preemptions per hour initiated by each queue labeled example.com/tenant-tier: "standard"):
apiVersion: kueue.x-k8s.io/v1alpha1
kind: PreemptionLimit
metadata:
name: "tenant-preemption-rate-limit"
spec:
aggregation: "ByPreemptorClusterQueue"
configSelector: {}
preemptorClusterQueueSelector:
matchLabels:
example.com/tenant-tier: "standard"
limit: 10
windowSeconds: 3600
To bound the rate of configurable preemptions targeting workloads in each ClusterQueue instead, use aggregation: "ByPreempteeClusterQueue" with preempteeClusterQueueSelector.
Because PreemptionLimit state is maintained in memory and can be briefly unpopulated right after a controller restart, upgrade, or leader failover until existing limits are loaded, do not rely solely on a PreemptionLimit with limit: 0 to strictly protect mission-critical queues (such as hero-jobs-cq). Exclude protected queues directly using clusterQueueSelector in your PreemptionConfig rules (as shown in Scenario: Hero workload preemption).
Common pitfalls
- Classical preemption or peer configs bypassing custom guardrails: Classical/Fair Sharing rules in
ClusterQueue.spec.preemptionand rules in peerClusterQueues’PreemptionConfigresources can evict workloads you intended to protect unless configured consistently. See Protecting workloads across classical preemption and peer queues. - Preemption flapping from symmetric rules or victim readmission: When defining rules across queues (with
WithinCohortTreeorAnyClusterQueue), ensure rules are strictly asymmetric (for example, usingpriority.comparison: LessThanornumericLabels.comparison: LessThan) to avoid cascading preemptions where workloads repeatedly evict each other. In addition, when aPreemptionConfigallows same-priority preemptions across queues (such as topology defragmentation) andPrioritizePreemptorWorkloadsis not enabled, preempted workloads from other queues can be readmitted ahead of the waiting preemptor (for example, by creation timestamp), causing repeated preemption loops; enablePrioritizePreemptorWorkloadsfor cross-queue protection, and keep the defaultBestEffortFIFOqueueing strategy (rather thanStrictFIFO) so same-queue victims do not jump ahead of the waiting preemptor. - Label propagation: Custom numeric labels or tier labels on Jobs are not copied to Kueue
Workloadresources unless added tointegrations.labelKeysToCopyin your Kueue Configuration. - Manual labeling for
PreemptionLimitselectors: Kueue does not automatically inject name or metadata labels ontoClusterQueueorPreemptionConfigobjects. Label those resources manually soconfigSelector,preemptorClusterQueueSelector, andpreempteeClusterQueueSelectormatch as intended. - Topology defragmentation requires quota feasibility: A workload blocked by both quota exhaustion and topology fragmentation cannot activate
QuotaFeasibleAndInsufficientTopologyuntil its quota requirement is satisfied by classical or Fair Sharing preemption,Alwaysrules, or anInsufficientQuotarule. - Controller restarts and leader failovers reset
PreemptionLimitstate: In Alpha,PreemptionLimitevent timestamps are kept strictly in memory. Restarting, upgrading, or failing over the Kueue controller resets active counts and can briefly leave limits unenforced until existingPreemptionLimitresources are loaded.
Verification and observability
To provide visibility into why a workload was preempted or throttled when custom rules and limits are used, Kueue tracks configurable preemption outcomes across workload status, PreemptionLimit status, and Prometheus metrics.
Eviction scheduling stats
Kueue records detailed eviction information in Workload.status.schedulingStats.evictions, populating underlyingCause with the name of the PreemptionConfig that triggered the preemption:
status:
schedulingStats:
evictions:
- count: 1
reason: Preempted
underlyingCause: "hero-workloads-preemption-config"
Status conditions
When a workload is preempted by a PreemptionConfig rule, Kueue sets two conditions in Workload.status.conditions. Both conditions share the same diagnostic message identifying the preemptor workload, the PreemptionConfig name, the rule name, and the selector index:
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"
If multiple selectors within a rule triggered the candidate’s preemption, their indices are concatenated with commas (for example, rule hero-preempt-lower-priority/0,1). If multiple rules contributed, they are separated with semicolons.
When a pending workload cannot be admitted because an active PreemptionLimit blocked preemption candidates, inspect its QuotaReserved condition (status: "False"). The message identifies the blocking PreemptionLimit name, its aggregation, and (when waiting for recorded events to expire can unblock it) the timestamp when the limit window elapses.
PreemptionLimit status
Inspect active sliding-window preemption counts reported on a PreemptionLimit (refreshed approximately once per minute):
kubectl get preemptionlimit experimental-config-rollout-limit -o yaml
The status section is similar to the following:
status:
window:
lastUpdateTime: "2026-11-23T12:00:00Z"
topAggregatedCounts:
- key: "Global"
value: 1
Metrics
Kueue exports Prometheus metrics for monitoring configurable preemptions and scheduling cycles:
kueue_preempted_workloads_total{reason="ConfigurablePreemption"}: Counts workloads preempted byPreemptionConfigrules, labeled bypreempting_cluster_queueandreason.kueue_evicted_workloads_total{reason="Preempted", underlying_cause="<PreemptionConfig name>"}: Counts evicted workloads per targetcluster_queue,reason, andunderlying_cause(populated with thePreemptionConfigname).kueue_admission_attempts_total{result="inadmissible"}: Counts scheduling cycles where no workload was admitted (labeled byresultandreplica_role, not by queue or reason). InspectWorkload.status.conditionsto determine whether a specific pending workload was blocked by quota, topology, or an activePreemptionLimit.
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.