Spark executor self-exiting due to driver disassociated in Kubernetes with client deploy-mode
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
When Spark executors on Kubernetes report that they are self-exiting because the driver is disassociated, the real problem is usually network reachability, not the executors themselves. In client deploy mode, the driver does not live in the same fully managed way as it does in cluster mode, so every executor pod must be able to open a stable connection back to the driver's advertised host and port. If that address is wrong, unroutable, or blocked, executors eventually give up.
Why Client Mode Is Fragile On Kubernetes
In Spark client mode, the driver runs outside the normal Kubernetes-managed driver lifecycle or at least outside the simpler cluster-mode pattern. Executors are launched inside Kubernetes, but they still need to talk back to the driver.
That means the driver must advertise an address that executor pods can actually reach.
Typical failure pattern:
- driver starts
- executors launch
- executors try to register or maintain RPC communication
- the advertised driver host or port is unreachable
- executors log disassociation and exit
This is why the issue is much more common in client mode than cluster mode.
The Most Common Cause: Wrong Driver Address
A very common misconfiguration is allowing Spark to advertise a driver host that only makes sense on the machine where spark-submit ran, such as:
- '
localhost' - a private workstation hostname
- a NATed address not reachable from the cluster
- a pod IP that is not stable or not exposed correctly
The important Spark settings are typically:
- '
spark.driver.host' - '
spark.driver.port' - sometimes
spark.driver.bindAddress
If these do not describe a routable endpoint from the executors' point of view, disassociation is expected.
A Typical Client-Mode Submission Pattern
Here is the shape of a submission where the driver is expected to be reachable explicitly:
This only works if driver.example.internal:7078 is actually reachable from the executor pods.
If you run client mode from a laptop, CI runner, or jump box outside the cluster, that reachability requirement is often the root failure.
When The Driver Runs In A Pod
Some teams still use client mode while running the driver inside a pod they manage themselves. In that case, the driver endpoint should usually be exposed through a stable Kubernetes Service rather than relying on a raw pod IP.
The important design principle is:
- executors need a stable DNS name or address and an open port
If the driver pod restarts or the pod IP changes without a stable service abstraction, executors can lose the connection.
Network Policies, Firewalls, And NAT
Even with the correct hostname, the network path can still fail because of:
- Kubernetes
NetworkPolicy - cloud firewalls or security groups
- node-to-external routing restrictions
- NAT or port-forward assumptions
This is why a configuration that works from one environment may fail from another. Spark is not just resolving a name. It is relying on real bidirectional RPC connectivity.
A practical debugging step is to test connectivity from an executor pod to the advertised driver host and port.
Why Cluster Mode Usually Avoids This
In cluster mode, Spark manages the driver inside Kubernetes. That generally makes networking simpler because the driver and executors live inside the same orchestration environment, and the integration is designed around that model.
If you do not have a strong reason to use client mode, cluster mode is often the safer Kubernetes choice.
Practical Fixes
The usual remedies are:
- set
spark.driver.hostto a hostname or IP reachable from executor pods - set
spark.driver.portexplicitly and make sure it is open - if needed, set
spark.driver.bindAddressseparately from the advertised host - expose the driver through a stable Kubernetes Service when the driver runs in a pod
- prefer
clusterdeploy mode when external driver reachability is awkward or unreliable
If the issue is intermittent, also check for timeouts, pod restarts, and network churn rather than assuming the executor logs are the primary problem.
A Diagnostic Mindset
When you see "driver disassociated," ask these questions first:
- What host and port is the driver advertising?
- Can an executor pod resolve that host?
- Can an executor pod connect to that port?
- Is some firewall or network policy blocking the path?
- Would cluster mode eliminate this network dependency?
That sequence is much more productive than tuning executor memory or CPU first.
Common Pitfalls
- Running client mode from a workstation and letting Spark advertise
localhostor another non-routable hostname. - Exposing the driver on a port that is not reachable from the Kubernetes network.
- Confusing the driver's bind address with the host executors must use to reach it.
- Ignoring network policies or cloud firewall rules that block executor-to-driver RPC.
- Choosing client mode on Kubernetes when cluster mode would be operationally simpler.
Summary
- In Spark client mode on Kubernetes, executors must connect back to the driver's advertised address.
- Driver disassociation usually means that advertised endpoint is wrong or unreachable.
- Check
spark.driver.host,spark.driver.port, network reachability, and firewall policy first. - Use a stable Service if the driver runs in a pod and needs a persistent endpoint.
- Prefer cluster mode when you do not need the special behavior of client mode.
Related reading
- Spark executors fails to run on kubernetes cluster
- Spark Kubernetes - FileNotFoundException when copying config files from driver to executors using --files or spark.files
- Spark on Kubernetes Executor pods silently get killed
- Spark submit to kubernetes packages not pulled by executors
- Spark Find pairs having at least n common attributes?
- Spark from_avro() dataframe.show() errors java.lang.ArrayIndexOutOfBoundsException
- Spark/k8s How to run spark submit on Kubernetes with client mode
- Specify scheduling order of a Kubernetes DaemonSet

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.