Skip to content
This repository was archived by the owner on Jan 9, 2020. It is now read-only.

Commit 9811de7

Browse files
committed
Initial Kerberos support
1 parent 0cffc23 commit 9811de7

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,20 @@ package object config extends Logging {
505505
.booleanConf
506506
.createWithDefault(false)
507507

508+
private[spark] val KUBERNETES_KERBEROS_KEYTAB =
509+
ConfigBuilder("spark.kubernetes.kerberos.keytab")
510+
.doc("Specify the location of keytab" +
511+
" for Kerberos in order to access Secure HDFS")
512+
.stringConf
513+
.createOptional
514+
515+
private[spark] val KUBERNETES_KERBEROS_PRINCIPAL =
516+
ConfigBuilder("spark.kubernetes.kerberos.principal")
517+
.doc("Specify the principal" +
518+
" for Kerberos in order to access Secure HDFS")
519+
.stringConf
520+
.createOptional
521+
508522
private[spark] def resolveK8sMaster(rawMasterString: String): String = {
509523
if (!rawMasterString.startsWith("k8s://")) {
510524
throw new IllegalArgumentException("Master URL should start with k8s:// in Kubernetes mode.")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.spark.deploy.kubernetes.submit.submitsteps.hadoopsteps
18+
19+
import java.io.File
20+
21+
import org.apache.hadoop.conf.Configuration
22+
import org.apache.hadoop.security.{Credentials, UserGroupInformation}
23+
24+
import org.apache.spark.SparkConf
25+
import org.apache.spark.deploy.SparkHadoopUtil
26+
import org.apache.spark.deploy.kubernetes.config._
27+
import org.apache.spark.internal.Logging
28+
29+
// import org.apache.spark.deploy.security.HadoopDelegationTokenManager
30+
31+
private[spark] case class DelegationToken(
32+
principle: String,
33+
bytes: Array[Byte],
34+
renewal: Long)
35+
36+
/**
37+
* This class is responsible for Hadoop DT renewal
38+
* TODO: THIS IS BLOCKED BY SPARK 2.2 REBASE
39+
*/
40+
private[spark] class HadoopKerberosMounterStep(
41+
submissionSparkConf: SparkConf)
42+
extends HadoopConfigurationStep with Logging {
43+
44+
private val maybePrincipal = submissionSparkConf.get(KUBERNETES_KERBEROS_PRINCIPAL)
45+
private val maybeKeytab = submissionSparkConf.get(KUBERNETES_KERBEROS_KEYTAB).map(
46+
k => new File(k))
47+
48+
override def configureContainers(hadoopConfigSpec: HadoopConfigSpec): HadoopConfigSpec = {
49+
val hadoopConf = SparkHadoopUtil.get.newConfiguration(submissionSparkConf)
50+
if (!UserGroupInformation.isSecurityEnabled) logError("Hadoop not configuration with Kerberos")
51+
for {
52+
principal <- maybePrincipal
53+
keytab <- maybeKeytab
54+
} yield {
55+
submissionSparkConf.set("spark.yarn.principal", principal)
56+
submissionSparkConf.set("spark.yarn.keytab", keytab.toURI.toString)
57+
}
58+
hadoopConfigSpec
59+
}
60+
}

0 commit comments

Comments
 (0)