|
| 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