API Priority and Fairness
Kubernetes processes all resource management operations through its singular API endpoint. This makes the API a focal point for managing requests like creating namespaces, scaling applications, and updating deployments. In clusters supporting multiple tenants—with varying levels of application criticality—it is crucial to ensure that essential API requests receive higher priority. Consider a scenario with two tenants sharing a cluster. Tenant A (in namespace A) runs critical services that require rapid scaling, while Tenant B (in namespace B) handles less critical workloads. To avoid delays in request handling for Tenant A due to Tenant B’s traffic, Kubernetes allows configuring API priority and fairness settings.Configuring API Priority
You first define priority level configurations using the beta API fromflowcontrol.apiserver.k8s.io/v1beta3. In the configuration below, the “high-priority” level is allocated a higher assured concurrency than the “low-priority” level:
This configuration ensures that API requests from critical namespaces are prioritized, preserving the responsiveness of essential operations.
Pod Priority and Preemption
Beyond API request handling, Kubernetes also supports pod priority and preemption to manage node resource allocation (including CPU, memory, etc.). This mechanism guarantees that critical pods gain necessary resources, even under resource pressure, by preempting or evicting less critical pods when needed.
Configuring Pod Priority
Begin by defining priority classes that distinguish between critical and non-critical workloads. In the configuration below, the “high-priority” class is assigned a higher value, ensuring its pods are scheduled preferentially:Comparing API Priority and Pod Priority
Both API priority and pod priority serve crucial yet distinct roles within a Kubernetes cluster:-
API Priority and Fairness:
These settings control the flow and processing of Kubernetes API requests. They manage operations such as creating, updating, or fetching cluster resources and ensure that critical API interactions are not stalled by heavy traffic from lower priority sources. -
Pod Priority and Preemption:
These mechanisms focus on resource allocation at the node level. They prioritize scheduling for critical pods and allow the system to evict lower priority pods when essential resources are required.

Both mechanisms are integral for the stability and performance of multi-tenant clusters. It is important to carefully plan and test your configurations to ensure critical workloads receive the intended level of service.