<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://openlakehouse.io/w/index.php?action=history&amp;feed=atom&amp;title=Spark_on_Kubernetes</id>
	<title>Spark on Kubernetes - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://openlakehouse.io/w/index.php?action=history&amp;feed=atom&amp;title=Spark_on_Kubernetes"/>
	<link rel="alternate" type="text/html" href="https://openlakehouse.io/w/index.php?title=Spark_on_Kubernetes&amp;action=history"/>
	<updated>2026-12-06T00:14:02Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://openlakehouse.io/w/index.php?title=Spark_on_Kubernetes&amp;diff=192&amp;oldid=prev</id>
		<title>Open Lakehouse Wiki sync: Sync from open-lakehouse/wiki@7c9abaa</title>
		<link rel="alternate" type="text/html" href="https://openlakehouse.io/w/index.php?title=Spark_on_Kubernetes&amp;diff=192&amp;oldid=prev"/>
		<updated>2026-11-25T00:52:55Z</updated>

		<summary type="html">&lt;p&gt;Sync from open-lakehouse/wiki@7c9abaa&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Infobox concept&lt;br /&gt;
| name            = Spark on Kubernetes&lt;br /&gt;
| also_known_as   = Spark K8s, Kubernetes scheduler backend for Spark&lt;br /&gt;
| field           = Cluster management for distributed data processing&lt;br /&gt;
| introduced      = Spark 2.3.0 (experimental); generally available in Spark 3.1.1&lt;br /&gt;
| key_parts       = Driver pod, executor pods, container image, service account, pod templates, volumes&lt;br /&gt;
| implementations = [[Apache Spark]], [[Kubernetes Operator for Apache Spark]]&lt;br /&gt;
| related         = [[Spark-submit|spark-submit]], [[Executor]], [[Spark on YARN]], [[Spark standalone cluster manager]]&lt;br /&gt;
}}&lt;br /&gt;
{{Verified|2026-11-23|the v4.3.0 tag of apache/spark (docs/running-on-kubernetes.md, docs/configuration.md, docs/job-scheduling.md), the Spark 2.3.0 and 3.1.1 release notes, SPARK-18278, SPARK-33005 and the Apache Spark Kubernetes Operator 1.1.0 release}}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Spark on Kubernetes&amp;#039;&amp;#039;&amp;#039; is the mode of [[Apache Spark]] in which Kubernetes is the cluster manager: the Spark driver and each [[executor]] run as Kubernetes pods, and Spark asks the Kubernetes API server for executor pods directly through its native Kubernetes scheduler backend.&amp;lt;ref name=&amp;quot;k8s&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/running-on-kubernetes.html |title=Running Spark on Kubernetes (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; Applications are submitted with [[Spark-submit|spark-submit]] using a &amp;lt;code&amp;gt;k8s://&amp;lt;/code&amp;gt; master URL, or declaratively through the [[Kubernetes Operator for Apache Spark]], a separate Apache Spark subproject that uses the same scheduler backend.&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt; Spark 4.3.0 documents Kubernetes 1.34 or newer as a prerequisite.&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How does Spark run on Kubernetes? ==&lt;br /&gt;
When an application is submitted in cluster mode, Spark creates the driver inside a Kubernetes pod. The driver then creates executor pods, connects to them and runs the application code. When the application finishes, the executor pods terminate and are cleaned up, while the driver pod stays in the &amp;quot;completed&amp;quot; state, keeping its logs, until it is garbage collected or deleted; a completed driver pod uses no compute or memory resources.&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kubernetes, not Spark, schedules the driver and executor pods onto nodes. Spark talks to the Kubernetes API through the fabric8 Kubernetes client, and node selectors can restrict pods to a subset of nodes.&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt; Spark launches executor pods in rounds; &amp;lt;code&amp;gt;spark.kubernetes.allocation.batch.size&amp;lt;/code&amp;gt; (default 20) is the number of pods launched in each round.&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The driver needs permission to manage its executors. The service account used by the driver pod must be allowed to create pods, services and configmaps, and it is set with &amp;lt;code&amp;gt;spark.kubernetes.authenticate.driver.serviceAccountName&amp;lt;/code&amp;gt; (default &amp;lt;code&amp;gt;default&amp;lt;/code&amp;gt;).&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How do you submit a PySpark application to Kubernetes? ==&lt;br /&gt;
The master URL has the form &amp;lt;code&amp;gt;k8s://&amp;lt;api_server_host&amp;gt;:&amp;lt;port&amp;gt;&amp;lt;/code&amp;gt;; the port is required even when it is 443, and the scheme defaults to HTTPS.&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt; The application name is used to name the Kubernetes resources, so it must contain only lowercase alphanumeric characters, &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt;.&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt; The image comes from &amp;lt;code&amp;gt;spark.kubernetes.container.image&amp;lt;/code&amp;gt;; Spark ships Dockerfiles and &amp;lt;code&amp;gt;bin/docker-image-tool.sh&amp;lt;/code&amp;gt; to build images (including a PySpark image), and the Apache Spark images on Docker Hub (&amp;lt;code&amp;gt;apache/spark&amp;lt;/code&amp;gt;) can be used directly.&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./bin/spark-submit \&lt;br /&gt;
  --master k8s://https://k8s-apiserver.example.com:6443 \&lt;br /&gt;
  --deploy-mode cluster \&lt;br /&gt;
  --name daily-orders \&lt;br /&gt;
  --conf spark.kubernetes.namespace=spark-jobs \&lt;br /&gt;
  --conf spark.kubernetes.authenticate.driver.serviceAccountName=spark \&lt;br /&gt;
  --conf spark.kubernetes.container.image=apache/spark:4.3.0-python3 \&lt;br /&gt;
  --conf spark.executor.instances=4 \&lt;br /&gt;
  local:///opt/app/daily_orders.py&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;local://&amp;lt;/code&amp;gt; scheme points to a file already inside the image. Dependencies on the submitting machine (&amp;lt;code&amp;gt;file://&amp;lt;/code&amp;gt; or a plain path) are uploaded to a Hadoop-compatible file system set by &amp;lt;code&amp;gt;spark.kubernetes.file.upload.path&amp;lt;/code&amp;gt;, for example an S3 bucket, and downloaded by the driver pod.&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt; The namespace defaults to &amp;lt;code&amp;gt;default&amp;lt;/code&amp;gt; when &amp;lt;code&amp;gt;spark.kubernetes.namespace&amp;lt;/code&amp;gt; is not set.&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In cluster mode, &amp;lt;code&amp;gt;spark-submit --status&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;spark-submit --kill&amp;lt;/code&amp;gt; take a submission ID of the form &amp;lt;code&amp;gt;namespace:driver-pod-name&amp;lt;/code&amp;gt;, and both accept glob patterns.&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== What is the difference between cluster mode and client mode on Kubernetes? ==&lt;br /&gt;
In cluster mode the driver runs in a pod that Spark creates. Client mode, supported since Spark 2.4.0, lets the driver run in an existing pod or on a host outside the cluster.&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt; In client mode the executors must be able to reach the driver at a routable host name and port (&amp;lt;code&amp;gt;spark.driver.host&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;spark.driver.port&amp;lt;/code&amp;gt;); for a driver in a pod, the documentation suggests a headless service.&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In client mode inside a pod, setting &amp;lt;code&amp;gt;spark.kubernetes.driver.pod.name&amp;lt;/code&amp;gt; to the driver pod&amp;#039;s name makes Spark add an OwnerReference to each executor pod, so Kubernetes deletes the executors when the driver pod is deleted. Without it, executor pods can remain in the cluster if Spark&amp;#039;s own deletion request fails.&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== What are pod templates? ==&lt;br /&gt;
A pod template is a Kubernetes pod specification file that Spark uses as the starting point for the driver or executor pod, for settings that Spark configuration properties do not cover (for example security contexts or sidecar containers). The files are set with &amp;lt;code&amp;gt;spark.kubernetes.driver.podTemplateFile&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;spark.kubernetes.executor.podTemplateFile&amp;lt;/code&amp;gt;.&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Spark does not validate pod templates and leaves validation to the API server. Spark always overwrites some fields, such as the namespace and the driver&amp;#039;s service account, so a template only gives Spark a non-empty pod to start from. When a template defines several containers, &amp;lt;code&amp;gt;spark.kubernetes.driver.podTemplateContainerName&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;spark.kubernetes.executor.podTemplateContainerName&amp;lt;/code&amp;gt; choose the Spark container; otherwise the first container is used.&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How are volumes and local storage configured? ==&lt;br /&gt;
Spark on Kubernetes can mount four volume types into driver and executor pods: &amp;lt;code&amp;gt;hostPath&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;emptyDir&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;nfs&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;persistentVolumeClaim&amp;lt;/code&amp;gt;. Volumes are declared with properties of the form &amp;lt;code&amp;gt;spark.kubernetes.[driver|executor].volumes.[VolumeType].[VolumeName].mount.path&amp;lt;/code&amp;gt;, plus type-specific &amp;lt;code&amp;gt;options.*&amp;lt;/code&amp;gt; properties.&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt; The documentation warns that &amp;lt;code&amp;gt;hostPath&amp;lt;/code&amp;gt; volumes have known security risks and recommends the Pod Security Admission controller to limit them.&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For executors, a claim name of &amp;lt;code&amp;gt;OnDemand&amp;lt;/code&amp;gt; creates a persistent volume claim per executor, with &amp;lt;code&amp;gt;storageClass&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sizeLimit&amp;lt;/code&amp;gt; options. Since Spark 3.4 the driver can own these claims and reuse them for new executors (&amp;lt;code&amp;gt;spark.kubernetes.driver.ownPersistentVolumeClaim&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;spark.kubernetes.driver.reusePersistentVolumeClaim&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;spark.kubernetes.driver.waitToReusePersistentVolumeClaim&amp;lt;/code&amp;gt;).&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Volumes whose names start with &amp;lt;code&amp;gt;spark-local-dir-&amp;lt;/code&amp;gt; are used as Spark local storage for shuffle and spill data. Without one, Spark uses an &amp;lt;code&amp;gt;emptyDir&amp;lt;/code&amp;gt; volume, which does not outlive the pod; &amp;lt;code&amp;gt;spark.kubernetes.local.dirs.tmpfs=true&amp;lt;/code&amp;gt; makes these volumes RAM-backed, which counts toward the pod&amp;#039;s memory.&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
spark.kubernetes.executor.volumes.persistentVolumeClaim.spark-local-dir-1.options.claimName=OnDemand&lt;br /&gt;
spark.kubernetes.executor.volumes.persistentVolumeClaim.spark-local-dir-1.options.storageClass=gp&lt;br /&gt;
spark.kubernetes.executor.volumes.persistentVolumeClaim.spark-local-dir-1.options.sizeLimit=500Gi&lt;br /&gt;
spark.kubernetes.executor.volumes.persistentVolumeClaim.spark-local-dir-1.mount.path=/data&lt;br /&gt;
spark.kubernetes.executor.volumes.persistentVolumeClaim.spark-local-dir-1.mount.readOnly=false&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How does memory and dynamic allocation differ on Kubernetes? ==&lt;br /&gt;
Each executor pod requests its heap plus overhead memory. &amp;lt;code&amp;gt;spark.executor.memoryOverheadFactor&amp;lt;/code&amp;gt; defaults to 0.10, except for Kubernetes non-JVM jobs (such as PySpark), where it defaults to 0.40 because non-JVM tasks need more memory outside the heap.&amp;lt;ref name=&amp;quot;config&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/configuration.html |title=Spark Configuration (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; CPU requests and limits for pods can be set separately with &amp;lt;code&amp;gt;spark.kubernetes.executor.request.cores&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;spark.kubernetes.executor.limit.cores&amp;lt;/code&amp;gt;.&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Dynamic allocation works on Kubernetes, but Spark on Kubernetes does not support the external shuffle service, so &amp;lt;code&amp;gt;spark.shuffle.service.enabled=true&amp;lt;/code&amp;gt; cannot be used to keep shuffle files.&amp;lt;ref name=&amp;quot;jobsched&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/job-scheduling.html |title=Job Scheduling (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; Shuffle tracking, decommissioning with shuffle block migration, or a shuffle storage plugin are used instead; see [[Executor#Dynamic allocation|Executor: dynamic allocation]]. Spark 4.3.0 also ships a &amp;lt;code&amp;gt;KubernetesLocalDiskShuffleDataIO&amp;lt;/code&amp;gt; plugin that recovers shuffle data from reused persistent volume claims.&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How does it relate to the Kubernetes Operator for Apache Spark? ==&lt;br /&gt;
{{Main|Kubernetes Operator for Apache Spark}}&lt;br /&gt;
The Apache Spark Kubernetes Operator is a separate Apache Spark project that manages Spark workloads declaratively through custom resources: &amp;lt;code&amp;gt;SparkApplication&amp;lt;/code&amp;gt; for applications and &amp;lt;code&amp;gt;SparkCluster&amp;lt;/code&amp;gt; for [[Spark standalone cluster manager|standalone]] clusters. The Spark documentation calls the two approaches complementary, because the operator runs applications on the same native Kubernetes scheduler backend that spark-submit uses.&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt; Its latest release is 1.1.0, published on 12 November 2026.&amp;lt;ref&amp;gt;{{Cite web |url=https://github.com/apache/spark-kubernetes-operator/releases/tag/1.1.0 |title=Release 1.1.0 |publisher=apache/spark-kubernetes-operator on GitHub |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
Spark 2.3.0 added the Kubernetes scheduler backend for native submission to Kubernetes (SPARK-18278) and marked it experimental.&amp;lt;ref&amp;gt;{{Cite web |url=https://spark.apache.org/releases/spark-release-2-3-0.html |title=Spark Release 2.3.0 |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; Spark 3.1.1 declared Kubernetes support generally available (SPARK-33005).&amp;lt;ref&amp;gt;{{Cite web |url=https://spark.apache.org/releases/spark-release-3-1-1.html |title=Spark Release 3.1.1 |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{Cite web |url=https://issues.apache.org/jira/browse/SPARK-33005 |title=SPARK-33005: Kubernetes GA Preparation |publisher=Apache Software Foundation JIRA |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; Spark on Kubernetes is not deprecated in Spark 4.3.0.&lt;br /&gt;
&lt;br /&gt;
== Spark on Kubernetes compared with other cluster managers ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! !! Spark on Kubernetes !! [[Spark on YARN]] !! [[Spark standalone cluster manager|Spark standalone]]&lt;br /&gt;
|-&lt;br /&gt;
! Driver and executors run in&lt;br /&gt;
| Kubernetes pods&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt; || YARN containers&amp;lt;ref name=&amp;quot;yarn&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/running-on-yarn.html |title=Running Spark on YARN (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; || Processes on standalone workers&amp;lt;ref name=&amp;quot;standalone&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/spark-standalone.html |title=Spark Standalone Mode (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! Master URL&lt;br /&gt;
| &amp;lt;code&amp;gt;k8s://HOST:PORT&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;yarn&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;spark://HOST:PORT&amp;lt;/code&amp;gt;&amp;lt;ref name=&amp;quot;submit&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/submitting-applications.html |title=Submitting Applications (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! External shuffle service&lt;br /&gt;
| Not supported || Supported || Supported&amp;lt;ref name=&amp;quot;jobsched&amp;quot; /&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Kubernetes Operator for Apache Spark]]&lt;br /&gt;
* [[Spark-submit|spark-submit]]&lt;br /&gt;
* [[Executor]]&lt;br /&gt;
* [[Spark on YARN]]&lt;br /&gt;
* [[Spark standalone cluster manager]]&lt;br /&gt;
* [[Spark configuration precedence]]&lt;br /&gt;
* [[Spark Connect]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Navbox open lakehouse}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Concepts]]&lt;br /&gt;
[[Category:Glossary terms]]&lt;br /&gt;
[[Category:Apache Spark]]&lt;/div&gt;</summary>
		<author><name>Open Lakehouse Wiki sync</name></author>
	</entry>
</feed>