Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,13 @@ private[spark] object Config extends Logging {
.stringConf
.createOptional

val KUBERNETES_DRIVER_REQUEST_EPHEMERAL_STORAGE =
ConfigBuilder("spark.kubernetes.driver.request.ephemeral.storage")
.doc("Specify the ephemeral storage request for the driver pod")
.version("4.1.0")
.stringConf
.createOptional

val KUBERNETES_DRIVER_SUBMIT_CHECK =
ConfigBuilder("spark.kubernetes.submitInDriver")
.internal()
Expand Down Expand Up @@ -342,6 +349,13 @@ private[spark] object Config extends Logging {
.stringConf
.createOptional

val KUBERNETES_EXECUTOR_REQUEST_EPHEMERAL_STORAGE =
ConfigBuilder("spark.kubernetes.executor.request.ephemeral.storage")
.doc("Specify the ephemeral storage request for the executor pod")
.version("4.1.0")
.stringConf
.createOptional

val KUBERNETES_DRIVER_POD_NAME =
ConfigBuilder("spark.kubernetes.driver.pod.name")
.doc("Name of the driver pod.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ private[spark] class BasicDriverFeatureStep(conf: KubernetesDriverConf)
// Memory settings
private val driverMemoryMiB = conf.get(DRIVER_MEMORY)

// Ephemeral storage
private val driverEphemeralStorageRequest = conf
.get(KUBERNETES_DRIVER_REQUEST_EPHEMERAL_STORAGE)

// The default memory overhead factor to use, derived from the deprecated
// `spark.kubernetes.memoryOverheadFactor` config or the default overhead values.
// If the user has not set it, then use a different default for non-JVM apps. This value is
Expand Down Expand Up @@ -90,6 +94,9 @@ private[spark] class BasicDriverFeatureStep(conf: KubernetesDriverConf)
val maybeCpuLimitQuantity = driverLimitCores.map { limitCores =>
("cpu", new Quantity(limitCores))
}
val maybeEphemeralStorageQuantity = driverEphemeralStorageRequest.map { storageRequest =>
("ephemeral-storage", new Quantity(storageRequest))
}

val driverResourceQuantities =
KubernetesUtils.buildResourcesQuantities(SPARK_DRIVER_PREFIX, conf.sparkConf)
Expand Down Expand Up @@ -135,6 +142,8 @@ private[spark] class BasicDriverFeatureStep(conf: KubernetesDriverConf)
.addToLimits(maybeCpuLimitQuantity.toMap.asJava)
.addToRequests("memory", driverMemoryQuantity)
.addToLimits("memory", driverMemoryQuantity)
.addToRequests(maybeEphemeralStorageQuantity.toMap.asJava)
.addToLimits(maybeEphemeralStorageQuantity.toMap.asJava)
.addToLimits(driverResourceQuantities.asJava)
.endResources()
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ private[spark] class BasicExecutorFeatureStep(
execResources.cores.get.toString
}
private val executorLimitCores = kubernetesConf.get(KUBERNETES_EXECUTOR_LIMIT_CORES)
private val executorRequestEphemeralStorage = kubernetesConf.get(KUBERNETES_EXECUTOR_REQUEST_EPHEMERAL_STORAGE)

private def buildExecutorResourcesQuantities(
customResources: Set[ExecutorResourceRequest]): Map[String, Quantity] = {
Expand Down Expand Up @@ -120,6 +121,10 @@ private[spark] class BasicExecutorFeatureStep(
val executorCpuQuantity = new Quantity(executorCoresRequest)
val executorResourceQuantities =
buildExecutorResourcesQuantities(execResources.customResources.values.toSet)
val maybeEphemeralStorageQuantity = executorRequestEphemeralStorage.map {
storageRequest =>
("ephemeral-storage", new Quantity(storageRequest))
}

val executorEnv: Seq[EnvVar] = {
val sparkAuthSecret = Option(secMgr.getSecretKey()).map {
Expand Down Expand Up @@ -194,6 +199,8 @@ private[spark] class BasicExecutorFeatureStep(
.addToRequests("memory", executorMemoryQuantity)
.addToLimits("memory", executorMemoryQuantity)
.addToRequests("cpu", executorCpuQuantity)
.addToRequests(maybeEphemeralStorageQuantity.toMap.asJava)
.addToLimits(maybeEphemeralStorageQuantity.toMap.asJava)
.addToLimits(executorResourceQuantities.asJava)
.endResources()
.addNewEnv()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,20 @@ class BasicDriverFeatureStepSuite extends SparkFunSuite {
}
}

test("Check driver pod respects kubernetes driver request ephemeral-storage") {
val sparkConf = new SparkConf()
.set(KUBERNETES_DRIVER_POD_NAME, "spark-driver-pod")
.set(CONTAINER_IMAGE, "spark-driver:latest")

val basePod = SparkPod.initialPod()
sparkConf.set(KUBERNETES_DRIVER_REQUEST_EPHEMERAL_STORAGE, "5Gi")
val requests1 = new BasicDriverFeatureStep(KubernetesTestConf.createDriverConf(sparkConf))
.configurePod(basePod)
.container.getResources
.getRequests.asScala
assert(amountAndFormat(requests1("ephemeral-storage")) === "5Gi")
}

test("Check appropriate entrypoint rerouting for various bindings") {
val javaSparkConf = new SparkConf()
.set(DRIVER_MEMORY.key, "4g")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,21 @@ class BasicExecutorFeatureStepSuite extends SparkFunSuite with BeforeAndAfter {
}
}

test("basic executor pod with ephemeral-storage") {
baseConf.set(KUBERNETES_EXECUTOR_REQUEST_EPHEMERAL_STORAGE, "5Gi")
initDefaultProfile(baseConf)
val step = new BasicExecutorFeatureStep(newExecutorConf(), new SecurityManager(baseConf),
defaultProfile)
val executor = step.configurePod(SparkPod.initialPod())

assert(executor.container.getResources.getRequests.size() === 3)
assert(executor.container.getResources.getLimits.size() === 2)
assert(amountAndFormat(executor.container.getResources
.getRequests.get("ephemeral-storage")) === "5Gi")
assert(amountAndFormat(executor.container.getResources
.getLimits.get("ephemeral-storage")) === "5Gi")
}

test("basic executor pod has reasonable defaults") {
val conf = newExecutorConf()
val step = new BasicExecutorFeatureStep(conf, new SecurityManager(baseConf),
Expand Down
Loading