Enable preemption

更新时间:
复制 MD 格式

When cluster resources are tight, high-priority tasks may fail to run due to insufficient resources. After preemption is enabled, ACK Scheduler simulates resource availability and evicts low-priority pods to free compute resources so high-priority tasks can start quickly.

Before you begin

Read Pod priority and preemption to understand PriorityClass, priorityClassName, and how pod priority affects scheduling and eviction order.

How preemption works

When preemption is enabled, ACK Scheduler follows this procedure:

  1. Specify task priority: Add priorityClassName to pod configurations.

    System components such as kube-proxy and etcd typically use the system-node-critical PriorityClass. Most run as DaemonSets and are not evicted by default.
  2. Simulate preemption: When ACK Scheduler detects a pending pod that cannot be scheduled, it simulates whether evicting low-priority pods would free enough resources.

  3. Securely evict low-priority pods: After ACK Scheduler triggers preemption, kubelet evicts the identified pods, releasing resources for the high-priority pod.

  4. Reschedule evicted pods: Controllers such as Deployments recreate evicted pods and schedule them to other nodes. If resources remain insufficient, the pods stay pending.

Preemption policies

ACK Scheduler supports the following preemption policies, configurable with the PreemptionAlgorithm parameter.

Policy

Description

Default

The default Kubernetes preemption policy. Attempts direct scheduling first, then simulates eviction of low-priority pods when resources are insufficient. See Pod priority and preemption.

ElasticQuota

Preempts based on the ElasticQuotaTree. See ElasticQuota policy details.

Auto

Prioritizes ElasticQuota and falls back to Default when ElasticQuota does not take effect.

None

Disables preemption.

The following figure shows how the policy takes effect.

image

ElasticQuota policy details

When the ElasticQuota policy is active, ACK Scheduler performs preemption in three steps:

  1. Identify the preemption list: Unlike regular tasks, ACK Scheduler combines all pending pods in a gang into one preemption list. The gang is processed only if all pods can be scheduled through preemption. If any pod has high priority, the entire gang is treated as high-priority.

  2. Identify feasible nodes: ACK Scheduler determines candidate nodes:

    • If multiple pods in the gang require preemption, any node matching one pod is added to the candidate pool. ACK Scheduler then frees resources for the remaining pods.

    • If only one pod requires preemption, ACK Scheduler filters out Unschedulable nodes to identify those with insufficient or mismatched resources.

  3. Simulate preemption: ACK Scheduler filters preemption-eligible pods from feasible nodes. A pod is eligible if both conditions are met:

    ACK Scheduler then applies the ElasticQuotaTree rules:

    • If the preempting pod belongs to a Quota:

      • If current Quota usage is at or below its Min guarantee: The pod can preempt pods from other Quotas using resources above their Min guarantee.

      • If current Quota usage exceeds its Min guarantee: The pod can only preempt lower-priority pods within its own Quota (intra-quota preemption).

    • If the preempting pod does not belong to any Quota: Preemption is not allowed.

    After identifying the pods to preempt, ACK Scheduler simulates removing them and rescheduling the preempting pod. If simulation succeeds, the pods are evicted and rescheduled. If it fails, preemption is terminated.

Enable preemption

Customize the scheduler parameters and set preemptionAlgorithm to Default, ElasticQuota, Auto, or None. The default is Auto.

Next steps