<p>I am using Spark 3.0.1 and working on a project spark deployment on Kubernetes where Kubernetes acting cluster manager for spark job and spark submits the job using client mode. In case Cluster does not have sufficient resource (CPU/ Memory ) for minimum number of executors , the executors goes in Pending State for indefinite time until the resource gets free.</p>
<p>Suppose, Cluster Configurations are:</p>
<pre><code>total Memory=204Gi
used Memory=200Gi
free memory= 4Gi
SPARK.EXECUTOR.MEMORY=10G
SPARK.DYNAMICALLOCTION.MINEXECUTORS=4
SPARK.DYNAMICALLOCATION.MAXEXECUTORS=8
</code></pre>
<p>Here job should not be submitted as executors allocated are less than MIN_EXECUTORS.</p>
<p>How can driver abort the job in this scenario?</p>

Ranju
<p>Firstly would like to mention that, spark dynamic allocation not supported for kubernetes yet(as of version 3.0.1), its in pipeline for future release <a href="https://spark.apache.org/docs/latest/running-on-kubernetes.html#future-work" rel="nofollow noreferrer">Link</a></p>
<p>while for the requirement you have posted, you could address by running a resource monitor code snippet before the job initialized and terminate the initialization pod itself with error.</p>
<p>if you want to run this from CLI you could use <code>kubectl describe nodes</code>/ kube-capacity utility to monitor the resources</p>
