Skip to content

Commit

Permalink
Support specify CPU cores for driver pod (apache#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
hustcat authored and ash211 committed Mar 30, 2017
1 parent 3254246 commit 35a5e32
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ private[spark] class Client(
.map(_.split(","))
.getOrElse(Array.empty[String])

// CPU settings
private val driverCpuCores = sparkConf.getOption("spark.driver.cores").getOrElse("1")

// Memory settings
private val driverMemoryMb = sparkConf.get(org.apache.spark.internal.config.DRIVER_MEMORY)
private val driverSubmitServerMemoryMb = sparkConf.get(KUBERNETES_DRIVER_SUBMIT_SERVER_MEMORY)
Expand Down Expand Up @@ -431,6 +434,9 @@ private[spark] class Client(
.withPath("/v1/submissions/ping")
.withNewPort(SUBMISSION_SERVER_PORT_NAME)
.build()
val driverCpuQuantity = new QuantityBuilder(false)
.withAmount(driverCpuCores)
.build()
val driverMemoryQuantity = new QuantityBuilder(false)
.withAmount(s"${driverContainerMemoryMb}M")
.build()
Expand Down Expand Up @@ -478,6 +484,8 @@ private[spark] class Client(
.endEnv()
.addToEnv(sslConfiguration.sslPodEnvVars: _*)
.withNewResources()
.addToRequests("cpu", driverCpuQuantity)
.addToLimits("cpu", driverCpuQuantity)
.addToRequests("memory", driverMemoryQuantity)
.addToLimits("memory", driverMemoryLimitQuantity)
.endResources()
Expand Down

0 comments on commit 35a5e32

Please sign in to comment.