---
title: "How Kueue schedules Spark jobs fairly on Red Hat OpenShift AI"
description: "Kubernetes schedules individual pods but does not decide which Spark application should receive a team’s quota first, so concurrent submissions can leave driver pods stuck and pipelines racing for nodes. Kueue intercepts a SparkApplication before the Kubeflow Spark operator creates driver or executor pods, creating a Workload and admitting it only when declared CPU and memory fit ClusterQueue quota. The walkthrough builds a self-managed queue for the spark-team-a project with a ClusterQueue reserving 3 CPUs and 4 GiB, then submits a SparkApplication carrying the kueue.x-k8s.io/queue-name label. A second copy remains suspended while the first consumes the quota and is admitted automatically after the first completes. Preemption deletes all driver and executor pods, losing in-memory state, shuffle data, and ephemeral files, while quota is reserved from declared requests rather than runtime utilization."
---

# How Kueue schedules Spark jobs fairly on Red Hat OpenShift AI

[Red Hat](https://yomu.fyi/company/red-hat) · Vedant Deshpande · Nov 4, 2026

**Type:** Tutorial

## Summary

Kubernetes schedules individual pods but does not decide which Spark application should receive a team’s quota first, so concurrent submissions can leave driver pods stuck and pipelines racing for nodes. Kueue intercepts a SparkApplication before the Kubeflow Spark operator creates driver or executor pods, creating a Workload and admitting it only when declared CPU and memory fit ClusterQueue quota. The walkthrough builds a self-managed queue for the spark-team-a project with a ClusterQueue reserving 3 CPUs and 4 GiB, then submits a SparkApplication carrying the kueue.x-k8s.io/queue-name label. A second copy remains suspended while the first consumes the quota and is admitted automatically after the first completes. Preemption deletes all driver and executor pods, losing in-memory state, shuffle data, and ephemeral files, while quota is reserved from declared requests rather than runtime utilization.

## Context

The article addresses Spark workloads on Red Hat OpenShift AI where multiple teams submit applications and compete for finite resources. It separates Kueue’s application-level admission from the Kubernetes scheduler’s pod placement and from the Spark operator’s pod creation. The demonstration uses a self-managed queue hierarchy for the spark-team-a project, with a ClusterQueue reserving 3 CPUs and 4 GiB. The sample application requests a driver and two executors at 1 CPU and 512m each, so one application fits and a second waits.

## Approach / What changed

Install the Red Hat build of Kueue operator from OperatorHub and enable cluster monitoring for openshift-kueue-operator. Patch the DataScienceCluster so sparkoperator is Managed and kueue is Unmanaged, avoiding the deprecated embedded Kueue distribution. Add SparkApplication to spec.config.integrations.frameworks in the Kueue CR and apply RBAC that lets Kueue manage SparkApplication finalizers. Create the spark-team-a project, label the namespace kueue.openshift.io/managed=true and team=data-platform, then create a ResourceFlavor, ClusterQueue with 3 CPU and 4 GiB nominal quota, and LocalQueue. Submit SparkApplications with the kueue.x-k8s.io/queue-name label.

## Takeaways

- Preemption is a restart, not a pause: suspension causes the Spark operator to delete every driver and executor pod, so in-memory state, shuffle data, and ephemeral files are lost, and Kueue does not checkpoint the application.
- An unlabeled SparkApplication can bypass the queue: the kueue.openshift.io/managed=true namespace label activates Kueue webhooks, but each application still needs a kueue.x-k8s.io/queue-name label.
- Quota is reserved from declared requests, not runtime consumption: a driver requesting 1 CPU but idling at 100m still holds 1 CPU, so explicit coreRequest values for driver and executors are required.

## FAQ

### What happens to a running SparkApplication when Kueue preempts it?

Kueue suspends the application, and the Spark operator deletes every driver and executor pod. In-memory state, shuffle data, and ephemeral files are lost, and Kueue does not checkpoint the application. Re-admission starts a new driver from scratch.

### Why can an unlabeled SparkApplication bypass the queue?

The kueue.openshift.io/managed=true namespace label activates Kueue webhooks, but the application still needs a kueue.x-k8s.io/queue-name label. Without that label, the app can bypass the queue.

### How does Kueue calculate quota for a Spark application?

Kueue reserves quota from the Workload's declared requests, not from runtime consumption. A driver requesting 1 CPU but idling at 100m still holds 1 CPU of quota. Explicit coreRequest values for driver and executors keep the quota math accurate.

**Tags:** [Apache Spark](https://yomu.fyi/topic/apache-spark), [Kubernetes](https://yomu.fyi/topic/kubernetes), [Kueue](https://yomu.fyi/topic/kueue), [OpenShift AI](https://yomu.fyi/topic/openshift-ai), [Scheduling](https://yomu.fyi/topic/scheduling)

- Source: [Red Hat](https://developers.redhat.com/articles/2026/11/04/how-kueue-schedules-spark-jobs-fairly-on-red-hat-openshift-ai)
- Source URL: https://developers.redhat.com/articles/2026/11/04/how-kueue-schedules-spark-jobs-fairly-on-red-hat-openshift-ai
- Ingested by Yomu: 2026-11-04T15:00:13.974Z

[Read original post](https://developers.redhat.com/articles/2026/11/04/how-kueue-schedules-spark-jobs-fairly-on-red-hat-openshift-ai)
