Use Custom Preemption Configurations

Set up and verify declarative preemption configurations, time-based candidate filters, and sliding-window preemption limits using PreemptionConfig and PreemptionLimit.
Feature state alpha since Kueue v0.20

This guide demonstrates how to configure and verify Configurable Preemptions in Kueue. You will learn how to:

  1. Install the Alpha CRDs and enable the ConfigurablePreemptions and ConfigurablePreemptionLimits feature gates.
  2. Configure a dedicated Hero Workload Preemption policy for an access-restricted ClusterQueue.
  3. Configure a Topology Defragmentation policy for general-purpose workloads.
  4. Configure Priority Class and Time-Based candidate filters to protect intermediate tiers, short-running jobs during their initial execution window, or aging workloads.
  5. Configure Preemption Limits (PreemptionLimit) to safely roll out new configurations, limit per-workload churn, and bound per-queue preemption rates.
  6. Verify preemption outcomes and limit status via workload conditions, eviction stats, PreemptionLimit status, and metrics.

Before you begin

Make sure the following conditions are met:

  • A Kubernetes cluster is running.
  • The kubectl command-line tool has communication with your cluster.
  • Kueue is installed.
  • You have permissions to install CRDs and manage cluster-scoped resources (PreemptionConfig, PreemptionLimit, and ClusterQueue).

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.preemption are evaluated before PreemptionConfig rules without checking your PreemptionConfig selectors or PreemptionLimit resources. To prevent classical or Fair Sharing preemption from bypassing those guardrails, set spec.preemption.reclaimWithinCohort: Never, spec.preemption.withinClusterQueue: Never, and (if configured) spec.preemption.borrowWithinCohort.policy: Never on the preempting ClusterQueue, as well as on any cohort peer ClusterQueues that should not evict protected workloads via classical or Fair Sharing preemption.
  • Align peer PreemptionConfig rules: Candidate rules are evaluated from the preempting ClusterQueue’s referenced PreemptionConfig, not the victim’s. Setting spec.preemption policies to Never does not block a peer ClusterQueue’s PreemptionConfig (for example, a rule with scope: AnyClusterQueue or WithinCohortTree) from selecting workloads in your queue. To enforce a protection rule across queues, apply the matching exclusion selectors or timeConstraints in every peer PreemptionConfig that 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: Always evaluates 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: AnyClusterQueue searches 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: clusterQueueSelector ensures that ClusterQueues labeled example.com/protection-tier: mission-critical are 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: InsufficientQuota activates when the incoming workload lacks sufficient quota to be admitted.
    • Scope: WithinCohortTree restricts quota reclamation to the cohort hierarchy (since borrowing outside the cohort tree is not permitted).
    • Protection guardrail: labelSelector prevents evicting lower-priority workloads labeled example.com/workload-tier: mission-critical.
  • Rule evict-smaller-jobs-for-topology:

    • Trigger: QuotaFeasibleAndInsufficientTopology activates only when quota is already feasible for the incoming job under at least one eligible flavor assignment (after classical or Fair Sharing preemption, Always rules, and any applicable InsufficientQuota rules), but placement is blocked by physical topology constraints.
    • Scope: AnyClusterQueue searches across all ClusterQueues in the cluster so topology can be unblocked across physical nodes regardless of cohort relationship.
    • Asymmetric defragmentation: numericLabels with comparison: LessThan ensures 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. Omitting fallbackValue ensures 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 labelSelector prevents evicting workloads labeled example.com/workload-tier: mission-critical.

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

Feature state alpha since Kueue v0.21

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 with priority (mode: Base and comparison: LessThan), only candidates in the same ClusterQueue (WithinClusterQueue) that have strictly lower base priority and reference a WorkloadPriorityClass (sourceRef) named batch-low or dev-preemptible (nameExpressions with operator: In) are eligible for preemption. Running production-standard workloads are protected even when a production-high workload 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 bypass priorityClassSelector.

Scenario: Time-based workload protection

Feature state alpha since Kueue v0.21

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 set maxSeconds under execution to 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 the Admitted state 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 maxSeconds with comparison: "LessThan" under sinceCreation.
  • ClusterQueue setup: Attach this config via kueue.x-k8s.io/preemption-config-name: "time-protected-preemption-config". Protection from timeConstraints applies only to candidates evaluated under a PreemptionConfig that sets matching timeConstraints; see Protecting workloads across classical preemption and peer queues to ensure neither classical preemption nor peer PreemptionConfig rules bypass it.

Scenario: Rate-limiting configurable preemptions with PreemptionLimit

Feature state alpha since Kueue v0.21

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.

Common pitfalls

  • Classical preemption or peer configs bypassing custom guardrails: Classical/Fair Sharing rules in ClusterQueue.spec.preemption and rules in peer ClusterQueues’ PreemptionConfig resources 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 WithinCohortTree or AnyClusterQueue), ensure rules are strictly asymmetric (for example, using priority.comparison: LessThan or numericLabels.comparison: LessThan) to avoid cascading preemptions where workloads repeatedly evict each other. In addition, when a PreemptionConfig allows same-priority preemptions across queues (such as topology defragmentation) and PrioritizePreemptorWorkloads is not enabled, preempted workloads from other queues can be readmitted ahead of the waiting preemptor (for example, by creation timestamp), causing repeated preemption loops; enable PrioritizePreemptorWorkloads for cross-queue protection, and keep the default BestEffortFIFO queueing strategy (rather than StrictFIFO) 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 Workload resources unless added to integrations.labelKeysToCopy in your Kueue Configuration.
  • Manual labeling for PreemptionLimit selectors: Kueue does not automatically inject name or metadata labels onto ClusterQueue or PreemptionConfig objects. Label those resources manually so configSelector, preemptorClusterQueueSelector, and preempteeClusterQueueSelector match as intended.
  • Topology defragmentation requires quota feasibility: A workload blocked by both quota exhaustion and topology fragmentation cannot activate QuotaFeasibleAndInsufficientTopology until its quota requirement is satisfied by classical or Fair Sharing preemption, Always rules, or an InsufficientQuota rule.
  • Controller restarts and leader failovers reset PreemptionLimit state: In Alpha, PreemptionLimit event timestamps are kept strictly in memory. Restarting, upgrading, or failing over the Kueue controller resets active counts and can briefly leave limits unenforced until existing PreemptionLimit resources 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 by PreemptionConfig rules, labeled by preempting_cluster_queue and reason.
  • kueue_evicted_workloads_total{reason="Preempted", underlying_cause="<PreemptionConfig name>"}: Counts evicted workloads per target cluster_queue, reason, and underlying_cause (populated with the PreemptionConfig name).
  • kueue_admission_attempts_total{result="inadmissible"}: Counts scheduling cycles where no workload was admitted (labeled by result and replica_role, not by queue or reason). Inspect Workload.status.conditions to determine whether a specific pending workload was blocked by quota, topology, or an active PreemptionLimit.