You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/05/20 05:42:43 UTC

[GitHub] [spark] dongjoon-hyun commented on a change in pull request #24601: [SPARK-27702][K8S] Allow using some alternatives for service accounts

dongjoon-hyun commented on a change in pull request #24601: [SPARK-27702][K8S] Allow using some alternatives for service accounts
URL: https://github.com/apache/spark/pull/24601#discussion_r285434004
 
 

 ##########
 File path: resource-managers/kubernetes/core/src/main/scala/org/apache/spark/scheduler/cluster/k8s/KubernetesClusterManager.scala
 ##########
 @@ -50,10 +50,21 @@ private[spark] class KubernetesClusterManager extends ExternalClusterManager wit
       require(sc.conf.get(KUBERNETES_DRIVER_POD_NAME).isDefined,
         "If the application is deployed using spark-submit in cluster mode, the driver pod name " +
           "must be provided.")
+      val serviceAccountToken =
+        Some(new File(Config.KUBERNETES_SERVICE_ACCOUNT_TOKEN_PATH)).filter(_.exists)
+      val serviceAccountCaCrt =
+        Some(new File(Config.KUBERNETES_SERVICE_ACCOUNT_CA_CRT_PATH)).filter(_.exists)
+      val apiServerUri = if (serviceAccountToken.nonEmpty || serviceAccountCaCrt.nonEmpty) {
+        KUBERNETES_MASTER_INTERNAL_URL
+      } else {
+        val masterUri = KubernetesUtils.parseMasterUrl(masterURL)
+        logWarning(s"Service account has been disabled. Using master: $masterUri")
+        masterUri
+      }
       (KUBERNETES_AUTH_DRIVER_MOUNTED_CONF_PREFIX,
-        KUBERNETES_MASTER_INTERNAL_URL,
-        Some(new File(Config.KUBERNETES_SERVICE_ACCOUNT_TOKEN_PATH)),
-        Some(new File(Config.KUBERNETES_SERVICE_ACCOUNT_CA_CRT_PATH)))
+        apiServerUri,
+        serviceAccountToken,
+        serviceAccountCaCrt)
 
 Review comment:
   @Udbhav30 . Could you add a test case this your PR?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org