<p>My goal is to optimally run Spark applications alongside the stateless workload in my cluster to make the best use of my cluster resources.</p>
<p>Since Spark applications can suffer from partial scheduling (drivers blocking the executors as the driver pods are started first which then request for the executor pods), a simple strategy to prevent this would be to implement the much talked about gang/co-scheduling to make sure that we only start the driver pod if we can guarantee that all the executors can be started in the future by implementing some kind of a reservations design such that the driver can reserve resources for the executors that will be started in the future.</p>
<p>Also, this reservation definition/implementation must be visible to all the other non-spark pods as well since they would also have to log their resource requests like the Spark pods so we have a clear picture of the cluster resource utilization.</p>
<p>The current implementations include running a new custom scheduler or implementing a scheduler extender to do so but I was wondering if we can achieve this by writing custom scheduler plugins. Additionally, what extension points in the scheduling framework would the plugins have to take advantage of to optimize the scheduling of Spark jobs in a multi-tenant environment (with different kinds of workload) so that my default profile can continue to schedule the stateless workload while the custom profile that uses these plugins can schedule Spark applications?</p>
<p>Finally, would this be the best way to optimize scheduling Spark and Stateless workload in a multi-tenant environment? What would the drawbacks of this approach (using custom plugins) be since we only have a single queue that all the profiles must share?</p>

<p>It sounds like what you would like to have is <a href="https://en.wikipedia.org/wiki/Gang_scheduling" rel="nofollow noreferrer">Gang Scheduling</a> 📆. If you'd like to have that capability, I suggest you use <a href="https://github.com/volcano-sh/volcano" rel="nofollow noreferrer">Volcano</a> to schedule/run 🏃 your jobs in Kubernetes with <a href="https://volcano.sh/docs/scheduler-reclaim/#gang-1" rel="nofollow noreferrer">Gang Scheduling</a>.</p>
<p>Another approach is to create your own scheduler using the <a href="https://github.com/kubernetes/community/blob/master/contributors/design-proposals/scheduling/scheduler_extender.md" rel="nofollow noreferrer">scheduler extender</a> as described <a href="https://medium.com/palantir/spark-scheduling-in-kubernetes-4976333235f3" rel="nofollow noreferrer">here</a> or use the <a href="https://github.com/palantir/k8s-spark-scheduler" rel="nofollow noreferrer">Palantir gang scheduler extender</a>.</p>
<p>✌️</p>
