You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "maomaodev (via GitHub)" <gi...@apache.org> on 2026/09/02 02:31:32 UTC

[PR] [SPARK-50758][K8S]Mounts the krb5 config map on the executor pod [spark]

maomaodev opened a new pull request, #58464:
URL: https://github.com/apache/spark/pull/58464

   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
     2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a faster review.
     7. If you want to add a new configuration, please read the guideline first for naming configurations in
        'common/utils/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
     8. If you want to add or modify an error type or message, please read the guideline first in
        'common/utils/src/main/resources/error/README.md'.
   -->
   
   ### What changes were proposed in this pull request?
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If you fix some SQL features, you can provide some references of other DBMSes.
     3. If there is design documentation, please add the link.
     4. If there is a discussion in the mailing list, please add the link.
   -->
   This is the second attempt of https://github.com/apache/spark/pull/49467, which added the ability to mount the `krb5.conf` ConfigMap on executor pods. The first attempt only worked in cluster mode; this follow-up adds client mode compatibility.
   
   In this pr, for spark on k8s, the krb5.conf config map will be mounted in executor side as well. Before, the krb5.conf config map is only mounted in driver side. But according to the parameter description (`spark.kubernetes.kerberos.krb5.path` and `spark.kubernetes.kerberos.krb5.configMapName`), the krb5.conf file should be mounted on both the driver and the executor.
   
   
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   After [SPARK-43504](https://issues.apache.org/jira/browse/SPARK-43504), the hadoop config map will be mounted on the executor pod.
   Now the executor pod fails to start because the hadoop conf file contains Kerberos authentication configuration, but the executor does not mount krb5.conf correctly. See the https://github.com/apache/spark/pull/41181 discuss.
   
   
   ### Does this PR introduce _any_ user-facing change?
   <!--
   Note that it means *any* user-facing change including all aspects such as new features, bug fixes, or other behavior changes. Documentation-only updates are not considered user-facing changes.
   
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   Yes, users do not need to take workarounds to make executors load the krb5.conf. Such as:
   - including krb5.conf in executor image
   - placing krb5.conf in executor working directory using --files
   
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
   -->
   Added UT:
   - `KerberosConfExecutorFeatureStepSuite` — mount / no-op / driver-step publishing.
   - `KubernetesClusterSchedulerBackendSuite` — `setUpExecutorKrb5ConfigMap` covers 4 branches (no krb5 config / cluster mode already set / user-provided ConfigMap / local file).
   - `KerberosConfDriverFeatureStepSuite` — updated assertions for the published system property.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   <!--
   If generative AI tooling has been used in the process of authoring this patch, please include the
   phrase: 'Generated-by: ' followed by the name of the tool and its version.
   If no, write 'No'.
   Please refer to the [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html) for details.
   -->
   Generated-by: DeepSeek-V4-Pro


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-50758][K8S] Mounts the krb5 config map on the executor pod [spark]

Posted by "uros-b (via GitHub)" <gi...@apache.org>.
uros-b commented on PR #58464:
URL: https://github.com/apache/spark/pull/58464#issuecomment-5635995697

   Thank you @tdcmeehan and @maomaodev for iterating here! Let's get an expert k8s committer here for final review and merge please


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-50758][K8S] Mounts the krb5 config map on the executor pod [spark]

Posted by "maomaodev (via GitHub)" <gi...@apache.org>.
maomaodev commented on code in PR #58464:
URL: https://github.com/apache/spark/pull/58464#discussion_r3962307452


##########
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/scheduler/cluster/k8s/KubernetesClusterSchedulerBackend.scala:
##########
@@ -98,6 +100,35 @@ private[spark] class KubernetesClusterSchedulerBackend(
     kubernetesClient.configMaps().inNamespace(namespace).resource(configMap).create()
   }
 
+  /**
+   * Publishes the krb5 ConfigMap name into [[KRB_CONFIG_MAP_NAME]] so executor pods can mount it.
+   * Cluster mode already has it set by the driver step; client mode creates or reuses it here.
+   */
+  private[k8s] def setUpExecutorKrb5ConfigMap(driverPod: Option[Pod]): Unit = {
+    // Already set by the driver feature step (cluster mode), nothing to do.
+    if (conf.getOption(KRB_CONFIG_MAP_NAME).isEmpty) {
+      conf.get(KUBERNETES_KERBEROS_KRB5_CONFIG_MAP) match {
+        case Some(existingMap) =>
+          // User supplied an existing ConfigMap, just publish its name to executors.
+          conf.set(KRB_CONFIG_MAP_NAME, existingMap)
+        case None =>
+          conf.get(KUBERNETES_KERBEROS_KRB5_FILE).foreach { localPath =>
+            val file = new File(localPath)
+            val configMapName = KubernetesClientUtils
+              .configMapName(s"spark-krb5-${KubernetesUtils.uniqueID()}")
+            val labels =
+              Map(SPARK_APP_ID_LABEL -> applicationId(),
+                SPARK_ROLE_LABEL -> SPARK_POD_EXECUTOR_ROLE)
+            val configMap = KubernetesClientUtils.buildConfigMap(
+              configMapName, Map(file.getName -> Files.readString(file.toPath)), labels)

Review Comment:
   Thanks for the review. Fixed in https://github.com/apache/spark/pull/58464/changes/692454934a05561120d23fa76f4886cdbab3e49f — both the client-mode and cluster-mode paths now store the krb5.conf ConfigMap data under the fixed "krb5.conf" key (extracted to a KRB_FILE_NAME constant), matching the executor mount's subPath("krb5.conf"). Added assertions covering the data key, KeyToPath projection, and subPath for the local-file, existing-ConfigMap, and executor cases.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-50758][K8S] Mounts the krb5 config map on the executor pod [spark]

Posted by "maomaodev (via GitHub)" <gi...@apache.org>.
maomaodev commented on PR #58464:
URL: https://github.com/apache/spark/pull/58464#issuecomment-5520423151

   > Change seems correct to me, but adding @pan3793 to review
   
   Thanks for the review!


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-50758][K8S] Mounts the krb5 config map on the executor pod [spark]

Posted by "maomaodev (via GitHub)" <gi...@apache.org>.
maomaodev commented on PR #58464:
URL: https://github.com/apache/spark/pull/58464#issuecomment-5757683275

   @dongjoon-hyun Could you please take a look when you have time? Thanks!


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-50758][K8S]Mounts the krb5 config map on the executor pod [spark]

Posted by "maomaodev (via GitHub)" <gi...@apache.org>.
maomaodev commented on PR #58464:
URL: https://github.com/apache/spark/pull/58464#issuecomment-5503602287

   @pan3793  Could you please take a look when you have time? Thanks!


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-50758][K8S] Mounts the krb5 config map on the executor pod [spark]

Posted by "maomaodev (via GitHub)" <gi...@apache.org>.
maomaodev commented on code in PR #58464:
URL: https://github.com/apache/spark/pull/58464#discussion_r3962307452


##########
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/scheduler/cluster/k8s/KubernetesClusterSchedulerBackend.scala:
##########
@@ -98,6 +100,35 @@ private[spark] class KubernetesClusterSchedulerBackend(
     kubernetesClient.configMaps().inNamespace(namespace).resource(configMap).create()
   }
 
+  /**
+   * Publishes the krb5 ConfigMap name into [[KRB_CONFIG_MAP_NAME]] so executor pods can mount it.
+   * Cluster mode already has it set by the driver step; client mode creates or reuses it here.
+   */
+  private[k8s] def setUpExecutorKrb5ConfigMap(driverPod: Option[Pod]): Unit = {
+    // Already set by the driver feature step (cluster mode), nothing to do.
+    if (conf.getOption(KRB_CONFIG_MAP_NAME).isEmpty) {
+      conf.get(KUBERNETES_KERBEROS_KRB5_CONFIG_MAP) match {
+        case Some(existingMap) =>
+          // User supplied an existing ConfigMap, just publish its name to executors.
+          conf.set(KRB_CONFIG_MAP_NAME, existingMap)
+        case None =>
+          conf.get(KUBERNETES_KERBEROS_KRB5_FILE).foreach { localPath =>
+            val file = new File(localPath)
+            val configMapName = KubernetesClientUtils
+              .configMapName(s"spark-krb5-${KubernetesUtils.uniqueID()}")
+            val labels =
+              Map(SPARK_APP_ID_LABEL -> applicationId(),
+                SPARK_ROLE_LABEL -> SPARK_POD_EXECUTOR_ROLE)
+            val configMap = KubernetesClientUtils.buildConfigMap(
+              configMapName, Map(file.getName -> Files.readString(file.toPath)), labels)

Review Comment:
   Thanks for the review. Fixed in https://github.com/apache/spark/pull/58464/changes/9e36fc1cebbc9804d610aa441f05ce70e1697f0b — both the client-mode and cluster-mode paths now store the krb5.conf ConfigMap data under the fixed "krb5.conf" key (extracted to a KRB_FILE_NAME constant), matching the executor mount's subPath("krb5.conf"). Added assertions covering the data key, KeyToPath projection, and subPath for the local-file, existing-ConfigMap, and executor cases.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-50758][K8S] Mounts the krb5 config map on the executor pod [spark]

Posted by "maomaodev (via GitHub)" <gi...@apache.org>.
maomaodev commented on PR #58464:
URL: https://github.com/apache/spark/pull/58464#issuecomment-5635137977

   Hi @uros-b , this PR already has an approval from @tdcmeehan. Would you mind taking a look and merging it if everything looks good? Happy to make any further changes you'd suggest.


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-50758][K8S] Mounts the krb5 config map on the executor pod [spark]

Posted by "tdcmeehan (via GitHub)" <gi...@apache.org>.
tdcmeehan commented on code in PR #58464:
URL: https://github.com/apache/spark/pull/58464#discussion_r3960508636


##########
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/scheduler/cluster/k8s/KubernetesClusterSchedulerBackend.scala:
##########
@@ -98,6 +100,35 @@ private[spark] class KubernetesClusterSchedulerBackend(
     kubernetesClient.configMaps().inNamespace(namespace).resource(configMap).create()
   }
 
+  /**
+   * Publishes the krb5 ConfigMap name into [[KRB_CONFIG_MAP_NAME]] so executor pods can mount it.
+   * Cluster mode already has it set by the driver step; client mode creates or reuses it here.
+   */
+  private[k8s] def setUpExecutorKrb5ConfigMap(driverPod: Option[Pod]): Unit = {
+    // Already set by the driver feature step (cluster mode), nothing to do.
+    if (conf.getOption(KRB_CONFIG_MAP_NAME).isEmpty) {
+      conf.get(KUBERNETES_KERBEROS_KRB5_CONFIG_MAP) match {
+        case Some(existingMap) =>
+          // User supplied an existing ConfigMap, just publish its name to executors.
+          conf.set(KRB_CONFIG_MAP_NAME, existingMap)
+        case None =>
+          conf.get(KUBERNETES_KERBEROS_KRB5_FILE).foreach { localPath =>
+            val file = new File(localPath)
+            val configMapName = KubernetesClientUtils
+              .configMapName(s"spark-krb5-${KubernetesUtils.uniqueID()}")
+            val labels =
+              Map(SPARK_APP_ID_LABEL -> applicationId(),
+                SPARK_ROLE_LABEL -> SPARK_POD_EXECUTOR_ROLE)
+            val configMap = KubernetesClientUtils.buildConfigMap(
+              configMapName, Map(file.getName -> Files.readString(file.toPath)), labels)

Review Comment:
   Store this entry under `krb5.conf`, or project the source key to that path. The executor mount always selects `subPath("krb5.conf")`, so a supported local file with any other basename creates a ConfigMap volume without the requested path and the executor pod cannot start. Please also assert the projected key/path in the local-file test.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-50758][K8S] Mounts the krb5 config map on the executor pod [spark]

Posted by "uros-b (via GitHub)" <gi...@apache.org>.
uros-b commented on PR #58464:
URL: https://github.com/apache/spark/pull/58464#issuecomment-5509657562

   Change seems correct to me, but adding @pan3793 to review


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-50758][K8S] Mounts the krb5 config map on the executor pod [spark]

Posted by "uros-b (via GitHub)" <gi...@apache.org>.
uros-b commented on PR #58464:
URL: https://github.com/apache/spark/pull/58464#issuecomment-5509653563

   I updated the PR title ever so slightly (space nit)


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-50758][K8S] Mounts the krb5 config map on the executor pod [spark]

Posted by "maomaodev (via GitHub)" <gi...@apache.org>.
maomaodev commented on PR #58464:
URL: https://github.com/apache/spark/pull/58464#issuecomment-5695582090

   gentle ping @pan3793 


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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