Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 15D242004F3 for ; Tue, 15 Aug 2017 20:11:55 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 143971671ED; Tue, 15 Aug 2017 18:11:55 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 5A31A1671EB for ; Tue, 15 Aug 2017 20:11:53 +0200 (CEST) Received: (qmail 75083 invoked by uid 500); 15 Aug 2017 18:11:51 -0000 Mailing-List: contact dev-help@spark.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list dev@spark.apache.org Received: (qmail 75023 invoked by uid 99); 15 Aug 2017 18:11:51 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Aug 2017 18:11:51 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id D54791A0259 for ; Tue, 15 Aug 2017 18:11:50 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.791 X-Spam-Level: X-Spam-Status: No, score=-0.791 tagged_above=-999 required=6.31 tests=[HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-2.8, SPF_PASS=-0.001, T_KAM_HTML_FONT_INVALID=0.01] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id MR8qUVgpVUPQ for ; Tue, 15 Aug 2017 18:11:43 +0000 (UTC) Received: from mail-oi0-f44.google.com (mail-oi0-f44.google.com [209.85.218.44]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 7FC225F659 for ; Tue, 15 Aug 2017 18:11:42 +0000 (UTC) Received: by mail-oi0-f44.google.com with SMTP id e124so14662515oig.2 for ; Tue, 15 Aug 2017 11:11:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=ss5DcSrY+JFR9YaCocdpHQVeU2cDW3u90tT9JyA5enk=; b=c7LfQyJLMRqx503yG3C8v2WKg2pQydhCWPjixKRVEMPjl0E/R/1/hInXer1y9K9SFV obFJ7B9Jz4I3UIBzheFZUWd6j9yTBkmy3h+CEjcOqpwqQ0to532zOZQc311ferBfjAkL 3T8pdtQLX8TlNxyBRs0Ac9na6TPfbVOyDKcdqt2oC+API3Un4AK/c2I09nVnRBFupoNw pKMFieUu3gS7y3yt8h3KeUwV1iv6mzH6FCfTgNBKw4D3tWvt6vFU/BzgbMnHXP5V4MLY YdJKFReWrGQZ8vYKmTvwbeoQgGVt2neonsGZ0PW4zmqYKf8lKFV7OKkNtJabCIzJ5XGh vnIA== X-Gm-Message-State: AHYfb5hc2xh0BgsFggy0VNkQGnolo+T5s3k6FyeLJz6kp1AiZOZKCOKn otaboPV3RX4MqB72/7t8E3ITIghHfOBP X-Received: by 10.202.108.146 with SMTP id h140mr30480955oic.125.1502820701607; Tue, 15 Aug 2017 11:11:41 -0700 (PDT) MIME-Version: 1.0 Received: by 10.74.103.83 with HTTP; Tue, 15 Aug 2017 11:11:40 -0700 (PDT) In-Reply-To: References: From: Erik Erlandson Date: Tue, 15 Aug 2017 11:11:40 -0700 Message-ID: Subject: Re: SPIP: Spark on Kubernetes To: dev@spark.apache.org Content-Type: multipart/alternative; boundary="001a1142dfa414aeb60556ceb62f" archived-at: Tue, 15 Aug 2017 18:11:55 -0000 --001a1142dfa414aeb60556ceb62f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Kubernetes has evolved into an important container orchestration platform; it has a large and growing user base and an active ecosystem. Users of Apache Spark who are also deploying applications on Kubernetes (or are planning to) will have convergence-related motivations for migrating their Spark applications to Kubernetes as well. It avoids the need for deploying separate cluster infra for Spark workloads and allows Spark applications to take full advantage of inhabiting the same orchestration environment as other applications. In this respect, native Kubernetes support for Spark represents a way to optimize uptake and retention of Apache Spark among the members of the expanding Kubernetes community. On Tue, Aug 15, 2017 at 8:43 AM, Erik Erlandson wrote= : > +1 (non-binding) > > > On Tue, Aug 15, 2017 at 8:32 AM, Anirudh Ramanathan > wrote: > >> Spark on Kubernetes effort has been developed separately in a fork, and >> linked back from the Apache Spark project as an experimental backend >> . >> We're ~6 months in, have had 5 releases >> . >> >> - 2 Spark versions maintained (2.1, and 2.2) >> - Extensive integration testing and refactoring efforts to maintain >> code quality >> - Developer >> and >> user-facing docu >> mentation >> - 10+ consistent code contributors from different organizations >> involved >> in actively maintaining and using the project, with several more memb= ers >> involved in testing and providing feedback. >> - The community has delivered several talks on Spark-on-Kubernetes >> generating lots of feedback from users. >> - In addition to these, we've seen efforts spawn off such as: >> - HDFS on Kubernetes >> with >> Locality and Performance Experiments >> - Kerberized access >> to >> HDFS from Spark running on Kubernetes >> >> *Following the SPIP process, I'm putting this SPIP up for a vote.* >> >> - +1: Yeah, let's go forward and implement the SPIP. >> - +0: Don't really care. >> - -1: I don't think this is a good idea because of the following >> technical reasons. >> >> If there is any further clarification desired, on the design or the >> implementation, please feel free to ask questions or provide feedback. >> >> >> SPIP: Kubernetes as A Native Cluster Manager >> >> Full Design Doc: link >> >> >> JIRA: https://issues.apache.org/jira/browse/SPARK-18278 >> >> Kubernetes Issue: https://github.com/kubernetes/kubernetes/issues/34377 >> >> Authors: Yinan Li, Anirudh Ramanathan, Erik Erlandson, Andrew Ash, Matt >> Cheah, >> >> Ilan Filonenko, Sean Suchter, Kimoon Kim >> Background and Motivation >> >> Containerization and cluster management technologies are constantly >> evolving in the cluster computing world. Apache Spark currently implemen= ts >> support for Apache Hadoop YARN and Apache Mesos, in addition to providin= g >> its own standalone cluster manager. In 2014, Google announced developmen= t >> of Kubernetes which has its own unique feature >> set and differentiates itself from YARN and Mesos. Since its debut, it h= as >> seen contributions from over 1300 contributors with over 50000 commits. >> Kubernetes has cemented itself as a core player in the cluster computing >> world, and cloud-computing providers such as Google Container Engine, >> Google Compute Engine, Amazon Web Services, and Microsoft Azure support >> running Kubernetes clusters. >> >> This document outlines a proposal for integrating Apache Spark with >> Kubernetes in a first class way, adding Kubernetes to the list of cluste= r >> managers that Spark can be used with. Doing so would allow users to shar= e >> their computing resources and containerization framework between their >> existing applications on Kubernetes and their computational Spark >> applications. Although there is existing support for running a Spark >> standalone cluster on Kubernetes >> , >> there are still major advantages and significant interest in having nati= ve >> execution support. For example, this integration provides better support >> for multi-tenancy and dynamic resource allocation. It also allows users = to >> run applications of different Spark versions of their choices in the sam= e >> cluster. >> >> The feature is being developed in a separate fork >> in order to minimize risk >> to the main project during development. Since the start of the developme= nt >> in November of 2016, it has received over 100 commits from over 20 >> contributors and supports two releases based on Spark 2.1 and 2.2 >> respectively. Documentation is also being actively worked on both in the >> main project repository and also in the repository >> https://github.com/apache-spark-on-k8s/userdocs. Regarding real-world >> use cases, we have seen cluster setup that uses 1000+ cores. We are also >> seeing growing interests on this project from more and more organization= s. >> >> While it is easy to bootstrap the project in a forked repository, it is >> hard to maintain it in the long run because of the tricky process of >> rebasing onto the upstream and lack of awareness in the large Spark >> community. It would be beneficial to both the Spark and Kubernetes >> community seeing this feature being merged upstream. On one hand, it giv= es >> Spark users the option of running their Spark workloads along with other >> workloads that may already be running on Kubernetes, enabling better >> resource sharing and isolation, and better cluster administration. On th= e >> other hand, it gives Kubernetes a leap forward in the area of large-scal= e >> data processing by being an officially supported cluster manager for Spa= rk. >> The risk of merging into upstream is low because most of the changes are >> purely incremental, i.e., new Kubernetes-aware implementations of existi= ng >> interfaces/classes in Spark core are introduced. The development is also >> concentrated in a single place at resource-managers/kubernetes >> . >> The risk is further reduced by a comprehensive integration test framewor= k, >> and an active and responsive community of future maintainers. >> Target Personas >> >> Devops, data scientists, data engineers, application developers, anyone >> who can benefit from having Kubernetes >> as a >> native cluster manager for Spark. >> Goals >> >> - >> >> Make Kubernetes a first-class cluster manager for Spark, alongside >> Spark Standalone, Yarn, and Mesos. >> - >> >> Support both client and cluster deployment mode. >> - >> >> Support dynamic resource allocation >> >> . >> - >> >> Support Spark Java/Scala, PySpark, and Spark R applications. >> - >> >> Support secure HDFS access. >> - >> >> Allow running applications of different Spark versions in the same >> cluster through the ability to specify the driver and executor Docker >> images on a per-application basis. >> - >> >> Support specification and enforcement of limits on both CPU cores and >> memory. >> >> Non-Goals >> >> - >> >> Support cluster resource scheduling and sharing beyond capabilities >> offered natively by the Kubernetes per-namespace resource quota model= . >> >> Proposed API Changes >> >> Most API changes are purely incremental, i.e., new Kubernetes-aware >> implementations of existing interfaces/classes in Spark core are >> introduced. Detailed changes are as follows. >> >> - >> >> A new cluster manager option KUBERNETES is introduced and some >> changes are made to SparkSubmit to make it be aware of this option. >> - >> >> A new implementation of CoarseGrainedSchedulerBackend, namely >> KubernetesClusterSchedulerBackend is responsible for managing the >> creation and deletion of executor Pods through the Kubernetes API. >> - >> >> A new implementation of TaskSchedulerImpl, namely >> KubernetesTaskSchedulerImpl, and a new implementation of >> TaskSetManager, namely Kubernetes TaskSetManager, are introduced for >> Kubernetes-aware task scheduling. >> - >> >> When dynamic resource allocation is enabled, a new implementation of >> ExternalShuffleService, namely KubernetesExternalShuffleService is >> introduced. >> >> Design Sketch >> >> Below we briefly describe the design. For more details on the design and >> architecture, please refer to the architecture documentation >> . >> The main idea of this design is to run Spark driver and executors inside >> Kubernetes Pods . >> Pods are a co-located and co-scheduled group of one or more containers r= un >> in a shared context. The driver is responsible for creating and destroyi= ng >> executor Pods through the Kubernetes API, while Kubernetes is fully >> responsible for scheduling the Pods to run on available nodes in the >> cluster. In the cluster mode, the driver also runs in a Pod in the clust= er, >> created through the Kubernetes API by a Kubernetes-aware submission clie= nt >> called by the spark-submit script. Because the driver runs in a Pod, it >> is reachable by the executors in the cluster using its Pod IP. In the >> client mode, the driver runs outside the cluster and calls the Kubernete= s >> API to create and destroy executor Pods. The driver must be routable fro= m >> within the cluster for the executors to communicate with it. >> >> The main component running in the driver is the >> KubernetesClusterSchedulerBackend, an implementation of >> CoarseGrainedSchedulerBackend, which manages allocating and destroying >> executors via the Kubernetes API, as instructed by Spark core via calls = to >> methods doRequestTotalExecutors and doKillExecutors, respectively. >> Within the KubernetesClusterSchedulerBackend, a separate >> kubernetes-pod-allocator thread handles the creation of new executor >> Pods with appropriate throttling and monitoring. Throttling is achieved >> using a feedback loop that makes decision on submitting new requests for >> executors based on whether previous executor Pod creation requests have >> completed. This indirection is necessary because the Kubernetes API serv= er >> accepts requests for new Pods optimistically, with the anticipation of >> being able to eventually schedule them to run. However, it is undesirabl= e >> to have a very large number of Pods that cannot be scheduled and stay >> pending within the cluster. The throttling mechanism gives us control ov= er >> how fast an application scales up (which can be configured), and helps >> prevent Spark applications from DOS-ing the Kubernetes API server with t= oo >> many Pod creation requests. The executor Pods simply run the >> CoarseGrainedExecutorBackend class from a pre-built Docker image that >> contains a Spark distribution. >> >> There are auxiliary and optional components: ResourceStagingServer and >> KubernetesExternalShuffleService, which serve specific purposes >> described below. The ResourceStagingServer serves as a file store (in >> the absence of a persistent storage layer in Kubernetes) for application >> dependencies uploaded from the submission client machine, which then get >> downloaded from the server by the init-containers in the driver and >> executor Pods. It is a Jetty server with JAX-RS and has two endpoints fo= r >> uploading and downloading files, respectively. Security tokens are retur= ned >> in the responses for file uploading and must be carried in the requests = for >> downloading the files. The ResourceStagingServer is deployed as a >> Kubernetes Service >> >> backed by a Deployment >> >> in the cluster and multiple instances may be deployed in the same cluste= r. >> Spark applications specify which ResourceStagingServer instance to use >> through a configuration property. >> >> The KubernetesExternalShuffleService is used to support dynamic resource >> allocation, with which the number of executors of a Spark application ca= n >> change at runtime based on the resource needs. It provides an additional >> endpoint for drivers that allows the shuffle service to delete driver >> termination and clean up the shuffle files associated with corresponding >> application. There are two ways of deploying the >> KubernetesExternalShuffleService: running a shuffle service Pod on each >> node in the cluster or a subset of the nodes using a DaemonSet >> , >> or running a shuffle service container in each of the executor Pods. In = the >> first option, each shuffle service container mounts a hostPath >> volume. >> The same hostPath volume is also mounted by each of the executor >> containers, which must also have the environment variable >> SPARK_LOCAL_DIRS point to the hostPath. In the second option, a shuffle >> service container is co-located with an executor container in each of th= e >> executor Pods. The two containers share an emptyDir >> volume >> where the shuffle data gets written to. There may be multiple instances = of >> the shuffle service deployed in a cluster that may be used for different >> versions of Spark, or for different priority levels with different resou= rce >> quotas. >> >> New Kubernetes-specific configuration options are also introduced to >> facilitate specification and customization of driver and executor Pods a= nd >> related Kubernetes resources. For example, driver and executor Pods can = be >> created in a particular Kubernetes namespace and on a particular set of = the >> nodes in the cluster. Users are allowed to apply labels and annotations = to >> the driver and executor Pods. >> >> Additionally, secure HDFS support is being actively worked on following >> the design here >> . >> Both short-running jobs and long-running jobs that need periodic delegat= ion >> token refresh are supported, leveraging built-in Kubernetes constructs l= ike >> Secrets. Please refer to the design doc for details. >> Rejected DesignsResource Staging by the Driver >> >> A first implementation effectively included the ResourceStagingServer in >> the driver container itself. The driver container ran a custom command t= hat >> opened an HTTP endpoint and waited for the submission client to send >> resources to it. The server would then run the driver code after it had >> received the resources from the submission client machine. The problem w= ith >> this approach is that the submission client needs to deploy the driver i= n >> such a way that the driver itself would be reachable from outside of the >> cluster, but it is difficult for an automated framework which is not awa= re >> of the cluster's configuration to expose an arbitrary pod in a generic w= ay. >> The Service-based design chosen allows a cluster administrator to expose >> the ResourceStagingServer in a manner that makes sense for their >> cluster, such as with an Ingress or with a NodePort service. >> Kubernetes External Shuffle Service >> >> Several alternatives were considered for the design of the shuffle >> service. The first design postulated the use of long-lived executor pods >> and sidecar containers in them running the shuffle service. The advantag= e >> of this model was that it would let us use emptyDir for sharing as oppos= ed >> to using node local storage, which guarantees better lifecycle managemen= t >> of storage by Kubernetes. The apparent disadvantage was that it would be= a >> departure from the traditional Spark methodology of keeping executors fo= r >> only as long as required in dynamic allocation mode. It would additional= ly >> use up more resources than strictly necessary during the course of >> long-running jobs, partially losing the advantage of dynamic scaling. >> >> Another alternative considered was to use a separate shuffle service >> manager as a nameserver. This design has a few drawbacks. First, this me= ans >> another component that needs authentication/authorization management and >> maintenance. Second, this separate component needs to be kept in sync wi= th >> the Kubernetes cluster. Last but not least, most of functionality of thi= s >> separate component can be performed by a combination of the in-cluster >> shuffle service and the Kubernetes API server. >> Pluggable Scheduler Backends >> >> Fully pluggable scheduler backends were considered as a more generalized >> solution, and remain interesting as a possible avenue for future-proofin= g >> against new scheduling targets. For the purposes of this project, addin= g a >> new specialized scheduler backend for Kubernetes was chosen as the appro= ach >> due to its very low impact on the core Spark code; making scheduler full= y >> pluggable would be a high-impact high-risk modification to Spark=E2=80= =99s core >> libraries. The pluggable scheduler backends effort is being tracked in >> JIRA-19700 . >> >> > --001a1142dfa414aeb60556ceb62f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Kubernetes has evolved into an important co= ntainer orchestration platform; it has a large and growing user base and an= active ecosystem.=C2=A0 Users of Apache Spark who are also deploying appli= cations on Kubernetes (or are planning to) will have convergence-related mo= tivations for migrating their Spark applications to Kubernetes as well. It = avoids the need for deploying separate cluster infra for Spark workloads an= d allows Spark applications to take full advantage of inhabiting the same o= rchestration environment as other applications.=C2=A0 In this respect, nati= ve Kubernetes support for Spark represents a way to optimize uptake and ret= ention of Apache Spark among the members of the expanding Kubernetes commun= ity.

On = Tue, Aug 15, 2017 at 8:43 AM, Erik Erlandson <eerlands@redhat.com&g= t; wrote:
+1 (non= -binding)


On Tue, Aug 15, 2017 at 8:32 AM, Anirudh Ramanathan= <foxish@google.com> wrote:
Spark on K= ubernetes effort has been developed separately in a fork, and linked back f= rom the Apache Spark project as=C2=A0an = experimental backend. We're ~6 months in, have had=C2=A05 = releases.=C2=A0
  • 2 Spar= k versions maintained (2.1, and 2.2)
  • Ext= ensive integration testing and refactoring efforts to maintain code quality=
  • Developer=C2=A0and= =C2=A0user-facing=C2=A0documentation
  • 10+ consistent code contributors from=C2=A0different organizations=C2=A0involved in actively main= taining and using the project, with several more members involved in testin= g and providing feedback.
  • The community = has delivered several talks on Spark-on-Kubernetes generating lots of feedb= ack from users.
  • In addition to these, we= 've seen efforts spawn off such as:

Following the=C2=A0SPIP=C2=A0= process, I'm putting this=C2=A0SPIP=C2=A0up for a vote.
  • +1: Yeah, let's= go forward and implement the SPIP.
  • = +0: Don't really care.
  • -1: I don= 't think this is a good idea because of the following technical reasons= .
If there is any further clarific= ation desired, on the design or the implementation, please feel free to ask= questions or provide feedback.


SPIP: Kubernetes as A Nativ= e Cluster Manager


Full Design Doc: link

JIRA: https:= //issues.apache.org/jira/browse/SPARK-18278

Kubern= etes Issue: https:/= /github.com/kubernetes/kubernetes/issues/34377


Authors: Yinan Li, Anirudh Ramanathan, Erik Erlandson, Andrew Ash, Matt Ch= eah,

Ilan Filonenko, Sean Suchter, Kimoon Kim

<= span style=3D"font-size:20pt;font-family:Arial;color:rgb(0,0,0);background-= color:transparent;font-weight:400;vertical-align:baseline;white-space:pre-w= rap">Background and Motivation

Containerization and cluster management tec= hnologies are constantly evolving in the cluster computing world. Apache Sp= ark currently implements support for Apache Hadoop YARN and Apache Mesos, i= n addition to providing its own standalone cluster manager. In 2014, Google= announced development of Kubernetes<= span style=3D"font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-= color:transparent;vertical-align:baseline;white-space:pre-wrap"> which has = its own unique feature set and differentiates itself from YARN and Mesos. S= ince its debut, it has seen contributions from over 1300 contributors with = over 50000 commits. Kubernetes has cemented itself as a core player in the = cluster computing world, and cloud-computing providers such as Google Conta= iner Engine, Google Compute Engine, Amazon Web Services, and Microsoft Azur= e support running Kubernetes clusters.


This document outlines a propo= sal for integrating Apache Spark with Kubernetes in a first class way, addi= ng Kubernetes to the list of cluster managers that Spark can be used with. = Doing so would allow users to share their computing resources and container= ization framework between their existing applications on Kubernetes and the= ir computational Spark applications. Although there is existing support for= <= span style=3D"font-size:11pt;font-family:Arial;background-color:transparent= ;text-decoration-line:underline;vertical-align:baseline;white-space:pre-wra= p">running a Spark standalone cluster on Kubernetes, there are still maj= or advantages and significant interest in having native execution support. = For example, this integration provides better support for multi-tenancy and= dynamic resource allocation. It also allows users to run applications of d= ifferent Spark versions of their choices in the same cluster.

The feat= ure is being developed in a = separate fork in order to minimize risk to the main project during develop= ment. Since the start of the development in November of 2016, it has receiv= ed over 100 commits from over 20 contributors and supports two releases bas= ed on Spark 2.1 and 2.2 respectively. Documentation is also being actively = worked on both in the main project repository and also in the repository https://github.com/apache-s= park-on-k8s/userdocs. Regarding real-world use cases, we have seen cl= uster setup that uses 1000+ cores. We are also seeing growing interests on = this project from more and more organizations.


While it is easy to boot= strap the project in a forked repository, it is hard to maintain it in the = long run because of the tricky process of rebasing onto the upstream and la= ck of awareness in the large Spark community. It would be beneficial to bot= h the Spark and Kubernetes community seeing this feature being merged upstr= eam. On one hand, it gives Spark users the option of running their Spark wo= rkloads along with other workloads that may already be running on Kubernete= s, enabling better resource sharing and isolation, and better cluster admin= istration. On the other hand, it gives Kubernetes a leap forward in the are= a of large-scale data processing by being an officially supported cluster m= anager for Spark. The risk of merging into upstream is low because most of = the changes are purely incremental, i.e., new Kubernetes-aware implementati= ons of existing interfaces/classes in Spark core are introduced. The develo= pment is also concentrated in a single place at resource-managers/kubernetes. The risk is further reduced by a comprehens= ive integration test framework, and an active and responsive community of f= uture maintainers.

Target Personas

Devops, data scientis= ts, data engineers, application developers, anyone who can benefit from hav= ing Kube= rnetes as a native cluster manager for Spark.

Goals

  • Make Kubernetes a first-class cluster manager for Spark, alongsid= e Spark Standalone, Yarn, and Mesos.

  • Support both client and cluster deployment mode.

  • <= li dir=3D"ltr" style=3D"list-style-type:disc;font-size:11pt;font-family:Ari= al;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline"><= p dir=3D"ltr" style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><= span style=3D"font-size:11pt;background-color:transparent;vertical-align:ba= seline;white-space:pre-wrap">Support dynamic resource allocation.

  • Suppo= rt Spark Java/Scala, PySpark, and Spark R applications.

  • Support secure HDFS access.

  • Allow running applications of different Spark versi= ons in the same cluster through the ability to specify the driver and execu= tor Docker images on a per-application basis.

  • Support specification and enforcement of limits on both CPU= cores and memory.

Non-Goals

  • Suppo= rt cluster resource scheduling and sharing beyond capabilities offered nati= vely by the Kubernetes per-namespace resource quota model.

  • <= /ul>

    Proposed API Changes

    Most API changes are purely incremental, = i.e., new Kubernetes-aware implementations of existing interfaces/classes i= n Spark core are introduced. Detailed changes are as follows.

  • A= new cluster manager option KUBERNETES i= s introduced and some changes are made to SparkSubmit to make it be aware of this option.

  • A new implementation of CoarseGrainedSchedulerBackend= , namely KubernetesClusterSchedulerBack<= wbr>end is responsible for managing th= e creation and deletion of executor Pods through the Kubernetes API.=

  • A new implementation of TaskSchedulerI= mpl, namely KubernetesTaskSchedulerImpl<= /span>, and a new implementation of TaskSetMana= ger, namely Kubernetes TaskSetManager, are introduced for Kubernetes-aware tas= k scheduling.

  • When dynamic res= ource allocation is enabled, a new implementation of ExternalShuffleService, namely KubernetesExternalShuffleService is introduced.

  • Design Sketch

    Below we briefly describe the design. For more det= ails on the design and architecture, please refer to the architecture documentation. The main idea of t= his design is to run Spark driver and executors inside Kubernetes Pods. Pods are a co-locat= ed and co-scheduled group of one or more containers run in a shared context= . The driver is responsible for creating and destroying executor Pods throu= gh the Kubernetes API, while Kubernetes is fully responsible for scheduling= the Pods to run on available nodes in the cluster. In the cluster mode, th= e driver also runs in a Pod in the cluster, created through the Kubernetes = API by a Kubernetes-aware submission client called by the sp= ark-submit script. Because the driver runs in a Pod, it is reachable by the ex= ecutors in the cluster using its Pod IP. In the client mode, the driver run= s outside the cluster and calls the Kubernetes API to create and destroy ex= ecutor Pods. The driver must be routable from within the cluster for the ex= ecutors to communicate with it.


    The main component running in the driv= er is the KubernetesClusterSchedulerBackend, an implementa= tion of CoarseGrainedSchedulerBackend, which manages allocating= and destroying executors via the Kubernetes API, as instructed by Spark co= re via calls to methods doRequestTotalExecutors and doKillExecutors, respectively. Within the KubernetesCluster= SchedulerBackend, a separate kubernetes-pod-allocator thread = handles the creation of new executor Pods with appropriate throttling and m= onitoring. Throttling is achieved using a feedback loop that makes decision= on submitting new requests for executors based on whether previous executo= r Pod creation requests have completed. This indirection is necessary becau= se the Kubernetes API server accepts requests for new Pods optimistically, = with the anticipation of being able to eventually schedule them to run. How= ever, it is undesirable to have a very large number of Pods that cannot be = scheduled and stay pending within the cluster. The throttling mechanism giv= es us control over how fast an application scales up (which can be configur= ed), and helps prevent Spark applications from DOS-ing the Kubernetes API s= erver with too many Pod creation requests. The executor Pods simply run the= CoarseGrainedExecutorBackend class from a pre-built Docker ima= ge that contains a Spark distribution.


    There are auxiliary and option= al components: ResourceStagingServer and Kuberne= tesExternalShuffleService, which serve specific purposes described below.= The ResourceStagingServer serves as a file store (in the absen= ce of a persistent storage layer in Kubernetes) for application dependencie= s uploaded from the submission client machine, which then get downloaded fr= om the server by the init-containers in the driver and executor Pods. It is= a Jetty server with JAX-RS and has two endpoints for uploading and downloa= ding files, respectively. Security tokens are returned in the responses for= file uploading and must be carried in the requests for downloading the fil= es. The ResourceStagingServer is deployed as a Kubernetes Service back= ed by a Deployment in the cluster and multiple instances may be deployed in t= he same cluster. Spark applications specify which ResourceSt= agingServer instance to use through a configuration property.


    The <= span style=3D"font-size:11pt;font-family:"Courier New";color:rgb(= 0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre= -wrap">KubernetesExternalShuffleService is used to support dynamic resour= ce allocation, with which the number of executors of a Spark application ca= n change at runtime based on the resource needs. It provides an additional = endpoint for drivers that allows the shuffle service to delete driver termi= nation and clean up the shuffle files associated with corresponding applica= tion. There are two ways of deploying the KubernetesExternal= ShuffleService: running a shuffle service Pod on each node in the cluster= or a subset of the nodes using a DaemonSet, or running a shuffle service cont= ainer in each of the executor Pods. In the first option, each shuffle servi= ce container mounts a hostPath volume. The same hostPath volume is also mounted by ea= ch of the executor containers, which must also have the environment variabl= e SPARK_LOCAL_DIRS point to the hostPath. In the second option,= a shuffle service container is co-located with an executor container in ea= ch of the executor Pods. The two containers share an emptyDir volume where the shuffl= e data gets written to. There may be multiple instances of the shuffle serv= ice deployed in a cluster that may be used for different versions of Spark,= or for different priority levels with different resource quotas.

    New K= ubernetes-specific configuration options are also introduced to facilitate = specification and customization of driver and executor Pods and related Kub= ernetes resources. For example, driver and executor Pods can be created in = a particular Kubernetes namespace and on a particular set of the nodes in t= he cluster. Users are allowed to apply labels and annotations to the driver= and executor Pods.


    Additionally, secure HDFS support is being actively= worked on following the design here. Both short-running jobs = and long-running jobs that need periodic delegation token refresh are suppo= rted, leveraging built-in Kubernetes constructs like Secrets. Please refer = to the design doc for details.

    Rejected Designs

    Resource Staging by the Driver

    A first implementation effecti= vely included the ResourceStagingServer in the driver container= itself. The driver container ran a custom command that opened an HTTP endp= oint and waited for the submission client to send resources to it. The serv= er would then run the driver code after it had received the resources from = the submission client machine. The problem with this approach is that the s= ubmission client needs to deploy the driver in such a way that the driver i= tself would be reachable from outside of the cluster, but it is difficult f= or an automated framework which is not aware of the cluster's configura= tion to expose an arbitrary pod in a generic way. The Service-based design = chosen allows a cluster administrator to expose the Resource= StagingServer in a manner that makes sense for their cluster, such as with an = Ingress or with a NodePort service.

    Kubernetes External S= huffle Service

    Several alternatives were considered for the design of the = shuffle service. The first design postulated the use of long-lived executor= pods and sidecar containers in them running the shuffle service. The advan= tage of this model was that it would let us use emptyDir for sharing as opp= osed to using node local storage, which guarantees better lifecycle managem= ent of storage by Kubernetes. The apparent disadvantage was that it would b= e a departure from the traditional Spark methodology of keeping executors f= or only as long as required in dynamic allocation mode. It would additional= ly use up more resources than strictly necessary during the course of long-= running jobs, partially losing the advantage of dynamic scaling.

    =

    Anothe= r alternative considered was to use a separate shuffle service manager as a= nameserver. This design has a few drawbacks. First, this means another com= ponent that needs authentication/authorization management and maintenance. = Second, this separate component needs to be kept in sync with the Kubernete= s cluster. Last but not least, most of functionality of this separate compo= nent can be performed by a combination of the in-cluster shuffle service an= d the Kubernetes API server.

    Pluggable Scheduler Backends=

    JIRA-19700= .




--001a1142dfa414aeb60556ceb62f--