# Stackable Operator for Apache Spark

> Manage Apache Spark clusters on Kubernetes with Stackable Operator, featuring SparkApplication CRDs, history server, S3 integration, and demos for big data tasks.

-   [GitHub](https://github.com/stackabletech/spark-k8s-operator/)

-   [Feature Tracker](https://features.stackable.tech/unified)

-   [CRD documentation](https://crds.stackable.tech/spark-k8s-operator/26.7.0/)


This operator manages [Apache Spark](https://spark.apache.org/) applications on Kubernetes clusters. Apache Spark is a powerful open-source big data processing framework that allows for efficient and flexible distributed computing. Its in-memory processing and fault-tolerant architecture make it ideal for a variety of use cases, including batch processing, real-time streaming, machine learning, and graph processing.

## Getting started

Follow the [Getting started](https://docs.stackable.tech/home/stable/spark-k8s/getting_started/index.md) guide to get started with Apache Spark using the Stackable operator. The guide leads you through the installation of the operator and running your first Spark application on Kubernetes.

## How the operator works

This operator manages _SparkApplication_ custom resources which you use to define your applications. The operator creates the relevant Kubernetes resources for the job to run.

### Custom resources

The operator manages two custom resource kinds: The _SparkApplication_ and the _SparkHistoryServer_.

The SparkApplication resource is the main point of interaction with the operator. Unlike other Stackable operator custom resources, the SparkApplication does not have [roles](https://docs.stackable.tech/home/stable/concepts/stacklet/index.md). An exhaustive list of options is given in the [SparkApplication CRD reference](https://crds.stackable.tech/spark-k8s-operator/26.7.0/) .

The [SparkHistoryServer](https://docs.stackable.tech/home/stable/spark-k8s/usage-guide/history-server/index.md) has a single `node` role. It is used to deploy a [Spark history server](https://spark.apache.org/docs/latest/monitoring.html#viewing-after-the-fact) that displays application logs. Of course, your applications need to write their logs to the same location.

### Kubernetes resources

For every SparkApplication deployed to the cluster the operator creates a Job, A ServiceAccout and a few ConfigMaps.

![A diagram depicting the Kubernetes resources created by the operator](https://docs.stackable.tech/home/stable/spark-k8s/_images/spark_overview.drawio.svg)

The Job runs `spark-submit` in a Pod which then creates a Spark driver Pod. The driver creates its own Executors based on the configuration in the SparkApplication. The Job, driver and executors all use the same image, which is configured in the SparkApplication resource.

The two main ConfigMaps are the `<name>-driver-pod-template` and `<name>-executor-pod-template` which define how the driver and executor Pods should be created.

The Spark history server deploys like other Stackable-supported applications: A Statefulset is created for every role group. A role group can have multiple replicas (Pods). A ConfigMap supplies the necessary configuration, and there is a service to connect to.

### RBAC

The [Spark-Kubernetes RBAC documentation](https://spark.apache.org/docs/latest/running-on-kubernetes.html#rbac) describes what is needed for `spark-submit` jobs to run successfully: minimally a role/cluster-role to allow the driver pod to create and manage executor pods.

However, to add security each `spark-submit` job launched by the operator is assigned its own ServiceAccount.

During the operator installation, a cluster role named `spark-k8s-clusterrole` is created with pre-defined permissions.

When a new Spark application is submitted, the operator creates a new service account with the same name as the application and binds this account to the cluster role `spark-k8s-clusterrole` .

## Integrations

You can read and write data from [s3 buckets](https://docs.stackable.tech/home/stable/spark-k8s/usage-guide/s3/index.md), load [custom job dependencies](https://docs.stackable.tech/home/stable/spark-k8s/index.md). Spark also supports easy integration with Apache Kafka which is also supported [on the Stackable Data Platform](https://docs.stackable.tech/home/stable/kafka/index.md). Have a look at the demos below to see it in action.

## Demos

The [data-lakehouse-iceberg-trino-spark](https://docs.stackable.tech/home/stable/demos/data-lakehouse-iceberg-trino-spark/index.md) demo connects multiple components and datasets into a data Lakehouse. A Spark application with [structured streaming](https://spark.apache.org/docs/latest/structured-streaming-programming-guide.html) is used to stream data from Apache Kafka into the Lakehouse.

In the [spark-k8s-anomaly-detection-taxi-data](https://docs.stackable.tech/home/stable/demos/spark-k8s-anomaly-detection-taxi-data/index.md) demo Spark is used to read training data from S3 and train an anomaly detection model on the data. The model is then stored in a Trino table.

## Supported versions

The Stackable operator for Apache Spark on Kubernetes currently supports the Spark versions listed below. To use a specific Spark version in your SparkApplication, you have to specify an image - this is explained in the [Product image selection](https://docs.stackable.tech/home/stable/concepts/product-image-selection/index.md) documentation. The operator also supports running images from a custom registry or running entirely customized images; both of these cases are explained under [Product image selection](https://docs.stackable.tech/home/stable/concepts/product-image-selection/index.md) as well.

-   4.1.2 (Hadoop 3.4.3, Scala 2.13, Python 3.12, Java 21) (LTS)

-   4.1.1 (Hadoop 3.4.3, Scala 2.13, Python 3.12, Java 21) (Deprecated)

-   3.5.8 (HBase 2.6.6, Hadoop 3.4.3, Scala 2.12, Python 3.11, Java 17) (Deprecated)


Apache Spark 4.1.1 & 4.1.2 have the following known issues (as of July 2026):

-   Missing HBase compatibility (See: [https://issues.apache.org/jira/browse/HBASE-30178](https://issues.apache.org/jira/browse/HBASE-30178))


## Useful links

-   The [spark-k8s-operator](https://github.com/stackabletech/spark-k8s-operator/) GitHub repository

-   The operator feature overview in the [feature tracker](https://features.stackable.tech/unified)

-   The [SparkApplication](https://crds.stackable.tech/26.7.0/spark.stackable.tech/sparkapplication/v1alpha1/) and [SparkHistorServer](https://crds.stackable.tech/26.7.0/spark.stackable.tech/sparkhistoryserver/v1alpha1/) CRD documentation
