Skip to content

Commit 25a209b

Browse files
kimoonkimash211
authored andcommitted
Optionally expose the driver UI port as NodePort (#131)
* Optionally expose driver UI as a NodePort * Update the usage doc * Rename serviceType -> uiServiceType
1 parent 51df502 commit 25a209b

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

docs/running-on-kubernetes.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,14 @@ from the other deployment modes. See the [configuration page](configuration.html
194194
Time to wait for the driver pod to start running before aborting its execution.
195195
</td>
196196
</tr>
197+
<tr>
198+
<td><code>spark.kubernetes.driver.service.exposeUiPort</code></td>
199+
<td><code>false</code></td>
200+
<td>
201+
Whether to expose the driver Web UI port as a service NodePort. Turned off by default because NodePort is a limited
202+
resource. Use alternatives such as Ingress if possible.
203+
</td>
204+
</tr>
197205
</table>
198206

199207
## Current Limitations

resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/kubernetes/Client.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,15 @@ private[spark] class Client(
226226
logInfo("Successfully submitted local resources and driver configuration to" +
227227
" driver pod.")
228228
// After submitting, adjust the service to only expose the Spark UI
229+
val uiServiceType = if (sparkConf.get(EXPOSE_KUBERNETES_DRIVER_SERVICE_UI_PORT)) "NodePort"
230+
else "ClusterIP"
229231
val uiServicePort = new ServicePortBuilder()
230232
.withName(UI_PORT_NAME)
231233
.withPort(uiPort)
232234
.withNewTargetPort(uiPort)
233235
.build()
234236
kubernetesClient.services().withName(kubernetesAppId).edit().editSpec()
235-
.withType("ClusterIP")
237+
.withType(uiServiceType)
236238
.withPorts(uiServicePort)
237239
.endSpec()
238240
.done()

resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/kubernetes/config.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,15 @@ package object config {
156156
.stringConf
157157
.createOptional
158158

159+
private[spark] val EXPOSE_KUBERNETES_DRIVER_SERVICE_UI_PORT =
160+
ConfigBuilder("spark.kubernetes.driver.service.exposeUiPort")
161+
.doc("""
162+
| Whether to expose the driver Web UI port as a service NodePort. Turned off by default
163+
| because NodePort is a limited resource. Use alternatives such as Ingress if possible.
164+
""".stripMargin)
165+
.booleanConf
166+
.createWithDefault(false)
167+
159168
private[spark] val KUBERNETES_DRIVER_POD_NAME =
160169
ConfigBuilder("spark.kubernetes.driver.pod.name")
161170
.doc("""

0 commit comments

Comments
 (0)