Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -45,6 +45,7 @@ private[spark] object Constants {
// Default and fixed ports
val DEFAULT_DRIVER_PORT = 7078
val DEFAULT_BLOCKMANAGER_PORT = 7079
val DEFAULT_UI_PORT = 4040
val DRIVER_PORT_NAME = "driver-rpc-port"
val BLOCK_MANAGER_PORT_NAME = "blockmanager"
val UI_PORT_NAME = "spark-ui"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import io.fabric8.kubernetes.api.model.{HasMetadata, ServiceBuilder}
import org.apache.spark.deploy.k8s.{KubernetesDriverConf, KubernetesUtils, SparkPod}
import org.apache.spark.deploy.k8s.Constants._
import org.apache.spark.internal.{config, Logging}
import org.apache.spark.ui.SparkUI
import org.apache.spark.util.{Clock, SystemClock}

private[spark] class DriverServiceFeatureStep(
Expand Down Expand Up @@ -55,6 +56,9 @@ private[spark] class DriverServiceFeatureStep(
private val driverBlockManagerPort = kubernetesConf.sparkConf.getInt(
config.DRIVER_BLOCK_MANAGER_PORT.key, DEFAULT_BLOCKMANAGER_PORT)

val driverUIPort = SparkUI.getUIPort(kubernetesConf
.sparkConf)

override def configurePod(pod: SparkPod): SparkPod = pod

override def getAdditionalPodSystemProperties(): Map[String, String] = {
Expand Down Expand Up @@ -82,6 +86,11 @@ private[spark] class DriverServiceFeatureStep(
.withPort(driverBlockManagerPort)
.withNewTargetPort(driverBlockManagerPort)
.endPort()
.addNewPort()
.withName(UI_PORT_NAME)
.withPort(driverUIPort)
.withNewTargetPort(driverUIPort)
.endPort()
.endSpec()
.build()
Seq(driverService)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ class DriverServiceFeatureStepSuite extends SparkFunSuite {
"label1key" -> "label1value",
"label2key" -> "label2value")

test("Headless service has a port for the driver RPC and the block manager.") {
test("Headless service has a port for the driver RPC, the block manager and driver ui.") {
val sparkConf = new SparkConf(false)
.set(DRIVER_PORT, 9000)
.set(DRIVER_BLOCK_MANAGER_PORT, 8080)
.set(UI_PORT_NAME, "4040")
val kconf = KubernetesTestConf.createDriverConf(
sparkConf = sparkConf,
labels = DRIVER_LABELS)
Expand All @@ -56,6 +57,7 @@ class DriverServiceFeatureStepSuite extends SparkFunSuite {
verifyService(
9000,
8080,
4040,
s"${kconf.resourceNamePrefix}${DriverServiceFeatureStep.DRIVER_SVC_POSTFIX}",
driverService)
}
Expand Down Expand Up @@ -85,6 +87,7 @@ class DriverServiceFeatureStepSuite extends SparkFunSuite {
verifyService(
DEFAULT_DRIVER_PORT,
DEFAULT_BLOCKMANAGER_PORT,
DEFAULT_UI_PORT,
s"${kconf.resourceNamePrefix}${DriverServiceFeatureStep.DRIVER_SVC_POSTFIX}",
resolvedService)
val additionalProps = configurationStep.getAdditionalPodSystemProperties()
Expand Down Expand Up @@ -152,20 +155,24 @@ class DriverServiceFeatureStepSuite extends SparkFunSuite {
private def verifyService(
driverPort: Int,
blockManagerPort: Int,
drierUIPort: Int,
expectedServiceName: String,
service: Service): Unit = {
assert(service.getMetadata.getName === expectedServiceName)
assert(service.getSpec.getClusterIP === "None")
DRIVER_LABELS.foreach { case (k, v) =>
assert(service.getSpec.getSelector.get(k) === v)
}
assert(service.getSpec.getPorts.size() === 2)
assert(service.getSpec.getPorts.size() === 3)
val driverServicePorts = service.getSpec.getPorts.asScala
assert(driverServicePorts.head.getName === DRIVER_PORT_NAME)
assert(driverServicePorts.head.getPort.intValue() === driverPort)
assert(driverServicePorts.head.getTargetPort.getIntVal === driverPort)
assert(driverServicePorts(1).getName === BLOCK_MANAGER_PORT_NAME)
assert(driverServicePorts(1).getPort.intValue() === blockManagerPort)
assert(driverServicePorts(1).getTargetPort.getIntVal === blockManagerPort)
assert(driverServicePorts(2).getName === UI_PORT_NAME)
assert(driverServicePorts(2).getPort.intValue() === drierUIPort)
assert(driverServicePorts(2).getTargetPort.getIntVal === drierUIPort)
}
}