pan3793 commented on code in PR #3852:
URL: https://github.com/apache/incubator-kyuubi/pull/3852#discussion_r1033081656


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/engine/spark/SparkProcessBuilder.scala:
##########
@@ -53,8 +54,42 @@ class SparkProcessBuilder(
     Paths.get(sparkHome, "bin", SPARK_SUBMIT_FILE).toFile.getCanonicalPath
   }
 
+  completeMasterUrl()
+
   override def mainClass: String = 
"org.apache.kyuubi.engine.spark.SparkSQLEngine"
 
+  /**
+   * Add `spark.master` if KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT
+   * are defined. So we can deploy spark on kubernetes without setting 
`spark.master`
+   * explicitly when kyuubi-servers are on kubernetes, which also helps in 
case that
+   * api-server is not exposed to us.
+   * Besides, set `spark.master` into kyuubiConf if which is set in 
spark-defaults.conf
+   * under SPARK_CONF_DIR.
+   */
+  protected def completeMasterUrl(): Unit = {
+    try {
+      (
+        clusterManager(),
+        sys.env.get(KUBERNETES_SERVICE_HOST),
+        sys.env.get(KUBERNETES_SERVICE_PORT)) match {
+        case (None, Some(kubernetesServiceHost), Some(kubernetesServicePort)) 
=>
+          // According to 
"https://kubernetes.io/docs/concepts/architecture/control-plane-
+          // node-communication/#node-to-control-plane", the API server is 
configured to listen
+          // for remote connections on a secure HTTPS port (typically 443), so 
we set https here.
+          val masterURL = 
s"k8s://https://${kubernetesServiceHost}:${kubernetesServicePort}";
+          conf.set(MASTER_KEY, masterURL)
+        case (Some(clusterManager), _, _) =>
+          // in case that ClusterManager was set in spark-defaults.conf, which 
should be set into
+          // KyuubiConf, the one which is used to build sparkSubmit.
+          conf.setIfMissing(MASTER_KEY, clusterManager)

Review Comment:
   it's redundant, please remove it and keep thing simple.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to