-
Notifications
You must be signed in to change notification settings - Fork 28.8k
[SPARK-25815][k8s] Support kerberos in client mode, keytab-based token renewal. #22911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
7f86e23
839477f
233ad0b
d0ec409
30f42cd
a129314
d8416cd
d4a84bc
7e9b3a2
78b76a8
88f1bb5
cda56a9
05333ea
4143603
90bec79
cce3f1d
ccb3956
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,6 +144,10 @@ private[spark] class BasicExecutorFeatureStep( | |
.addToLimits("memory", executorMemoryQuantity) | ||
.addToRequests("cpu", executorCpuQuantity) | ||
.endResources() | ||
.addNewEnv() | ||
.withName(ENV_SPARK_USER) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see that you noted that this is always done across resource managers. What is the reason for that, just wondering? as I introduced it exclusively in the HadoopSteps There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you don't do this, whatever is the OS user in the container will become the identity used to talk to Hadoop services (when kerberos is not on). In YARN, for example, that would be the "yarn" user. In k8s, with the current image, that would be "root". You probably don't want that by default. We're talking about non-secured Hadoop here, so users can easily override this stuff, but by default let's at least try to identify the user correctly. |
||
.withValue(Utils.getCurrentUserName()) | ||
.endEnv() | ||
.addAllToEnv(executorEnv.asJava) | ||
.withPorts(requiredPorts.asJava) | ||
.addToArgs("executor") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.spark.deploy.k8s.features | ||
|
||
import java.io.File | ||
import java.nio.charset.StandardCharsets | ||
|
||
import scala.collection.JavaConverters._ | ||
|
||
import com.google.common.io.Files | ||
import io.fabric8.kubernetes.api.model._ | ||
|
||
import org.apache.spark.deploy.k8s.{KubernetesConf, SparkPod} | ||
import org.apache.spark.deploy.k8s.Config._ | ||
import org.apache.spark.deploy.k8s.Constants._ | ||
|
||
/** | ||
* Mounts the Hadoop configuration - either a pre-defined config map, or a local configuration | ||
* directory - on the driver pod. | ||
*/ | ||
private[spark] class HadoopConfDriverFeatureStep(conf: KubernetesConf[_]) | ||
extends KubernetesFeatureConfigStep { | ||
|
||
private val confSpec = conf.hadoopConfSpec | ||
private val confDir = confSpec.flatMap(_.hadoopConfDir) | ||
private val confMap = confSpec.flatMap(_.hadoopConfigMapName) | ||
|
||
private lazy val confFiles: Seq[File] = { | ||
val dir = new File(confDir.get) | ||
if (dir.isDirectory) { | ||
dir.listFiles.filter(_.isFile).toSeq | ||
} else { | ||
Nil | ||
} | ||
} | ||
|
||
override def configurePod(original: SparkPod): SparkPod = { | ||
original.transform { case pod if confSpec.isDefined => | ||
val confVolume = if (confDir.isDefined) { | ||
val keyPaths = confFiles.map { file => | ||
new KeyToPathBuilder() | ||
.withKey(file.getName()) | ||
.withPath(file.getName()) | ||
.build() | ||
} | ||
new VolumeBuilder() | ||
.withName(HADOOP_CONF_VOLUME) | ||
.withNewConfigMap() | ||
.withName(conf.hadoopConfigMapName) | ||
.withItems(keyPaths.asJava) | ||
.endConfigMap() | ||
.build() | ||
} else { | ||
new VolumeBuilder() | ||
.withName(HADOOP_CONF_VOLUME) | ||
.withNewConfigMap() | ||
.withName(confMap.get) | ||
.endConfigMap() | ||
.build() | ||
} | ||
|
||
val podWithConf = new PodBuilder(pod.pod) | ||
.editSpec() | ||
.addNewVolumeLike(confVolume) | ||
.endVolume() | ||
.endSpec() | ||
.build() | ||
|
||
val containerWithMount = new ContainerBuilder(pod.container) | ||
.addNewVolumeMount() | ||
.withName(HADOOP_CONF_VOLUME) | ||
.withMountPath(HADOOP_CONF_DIR_PATH) | ||
.endVolumeMount() | ||
.addNewEnv() | ||
.withName(ENV_HADOOP_CONF_DIR) | ||
.withValue(HADOOP_CONF_DIR_PATH) | ||
.endEnv() | ||
.build() | ||
|
||
SparkPod(podWithConf, containerWithMount) | ||
} | ||
} | ||
|
||
override def getAdditionalKubernetesResources(): Seq[HasMetadata] = { | ||
if (confDir.isDefined) { | ||
val fileMap = confFiles.map { file => | ||
(file.getName(), Files.toString(file, StandardCharsets.UTF_8)) | ||
}.toMap.asJava | ||
|
||
Seq(new ConfigMapBuilder() | ||
.withNewMetadata() | ||
.withName(conf.hadoopConfigMapName) | ||
.endMetadata() | ||
.addToData(fileMap) | ||
.build()) | ||
} else { | ||
Nil | ||
} | ||
} | ||
|
||
} |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this because I started to get tired of code like the following:
To me that's hard to follow and brittle, and this pattern makes things clearer IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would think that this change is out of the scope of this PR, but I do love the use of a PartialFunction here. Thanks for this!