Skip to content

Commit d7441ba

Browse files
committed
working hadoop cluster
1 parent d3c5a03 commit d7441ba

File tree

24 files changed

+535
-84
lines changed

24 files changed

+535
-84
lines changed

resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/kubernetes/submit/submitsteps/hadoopsteps/HadoopKerberosKeytabResolverStep.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ private[spark] class HadoopKerberosKeytabResolverStep(
5959
}
6060
// In the case that keytab is not specified we will read from Local Ticket Cache
6161
val jobUserUGI = maybeJobUserUGI.getOrElse(UserGroupInformation.getCurrentUser)
62-
logInfo("Primary group name: jobUserUGI.getPrimaryGroupName")
62+
logInfo(s"Primary group name: ${jobUserUGI.getPrimaryGroupName}")
6363
val credentials: Credentials = jobUserUGI.getCredentials
6464
val credentialsManager = newHadoopTokenManager(submissionSparkConf, hadoopConf)
6565
var renewalTime = Long.MaxValue
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
18+
FROM spark-base
19+
20+
# If this docker file is being used in the context of building your images from a Spark distribution, the docker build
21+
# command should be invoked from the top level directory of the Spark distribution. E.g.:
22+
# docker build -t kerberos-test:latest -f dockerfiles/kerberos-test/Dockerfile .
23+
24+
COPY examples /opt/spark/examples
25+
RUN apk add --no-cache --update krb5 krb5-libs
26+
COPY hconf/krb5.conf /etc/krb5.conf
27+
COPY test-scripts/test-env.sh /
28+
29+
CMD /opt/spark/bin/spark-submit \
30+
--deploy-mode cluster \
31+
--class ${CLASS_NAME} \
32+
--master k8s://${MASTER_URL} \
33+
--kubernetes-namespace ${NAMESPACE} \
34+
--conf spark.executor.instances=1 \
35+
--conf spark.app.name=spark-hdfs \
36+
--conf spark.kubernetes.driver.docker.image=spark-driver:latest \
37+
--conf spark.kubernetes.executor.docker.image=spark-executor:latest \
38+
--conf spark.kubernetes.initcontainer.docker.image=spark-init:latest \
39+
--conf spark.kubernetes.kerberos=true \
40+
--conf spark.kubernetes.kerberos.keytab=/var/keytabs/hdfs.keytab \
41+
--conf spark.kubernetes.kerberos.principal=hdfs/nn.${NAMESPACE}[email protected] \
42+
--conf spark.kubernetes.driver.labels=spark-app-locator=${APP_LOCATOR_LABEL} \
43+
--files local:///etc/hadoop/core-site.xml,local:///etc/hadoop/hdfs-site.xml,local:///etc/hadoop/yarn-site.xml \
44+
${SUBMIT_RESOURCE} \
45+
hdfs://nn.${NAMESPACE}.svc.cluster.local:9000/user/ifilonenko/wordcount.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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.integrationtest.jobs
18+
19+
import org.apache.spark.sql.SparkSession
20+
21+
private[spark] object HDFSTest{
22+
23+
def main(args: Array[String]): Unit = {
24+
// scalastyle:off println
25+
if (args.length < 1) {
26+
System.err.println("Usage: HdfsTest <file>")
27+
System.exit(1)
28+
}
29+
// scalastyle:on println
30+
val spark = SparkSession
31+
.builder
32+
.appName("HdfsTest")
33+
.getOrCreate()
34+
val file = spark.read.text(args(0)).rdd
35+
val mapped = file.map(s => s.length).cache()
36+
// scalastyle:off println
37+
for (iter <- 1 to 10) {
38+
val start = System.currentTimeMillis()
39+
for (x <- mapped) { x + 2 }
40+
val end = System.currentTimeMillis()
41+
println("Iteration " + iter + " took " + (end-start) + " ms")
42+
}
43+
// scalastyle:on println
44+
spark.stop()
45+
}
46+
}

resource-managers/kubernetes/integration-tests/kerberos-yml/data-populator-deployment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ spec:
1818
name: data-populator
1919
image: ifilonenko/hadoop-base:latest
2020
imagePullPolicy: IfNotPresent
21+
runAsNonRoot: false
2122
volumeMounts:
2223
- mountPath: /var/keytabs
2324
name: data-populator-keytab

resource-managers/kubernetes/integration-tests/kerberos-yml/dn1-deployment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ spec:
1818
name: dn1
1919
image: ifilonenko/hadoop-base:latest
2020
imagePullPolicy: IfNotPresent
21+
runAsNonRoot: false
2122
volumeMounts:
2223
- mountPath: /var/keytabs
2324
name: dn1-keytab

resource-managers/kubernetes/integration-tests/kerberos-yml/kerberos-deployment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ spec:
1818
name: kerberos
1919
image: ifilonenko/hadoop-base:latest
2020
imagePullPolicy: IfNotPresent
21+
runAsNonRoot: false
2122
volumeMounts:
2223
- mountPath: /var/keytabs
2324
name: kerb-keytab
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
apiVersion: extensions/v1beta1
2+
kind: Deployment
3+
metadata:
4+
name: kerberos-test
5+
spec:
6+
replicas: 1
7+
template:
8+
metadata:
9+
labels:
10+
name: kerberos-test
11+
spec:
12+
containers:
13+
- name: kerberos-test
14+
image: kerberos-test:latest
15+
imagePullPolicy: IfNotPresent
16+
volumeMounts:
17+
- mountPath: /var/keytabs
18+
name: kerberos-test-keytab
19+
restartPolicy: Always
20+
volumes:
21+
- name: kerberos-test-keytab
22+
persistentVolumeClaim:
23+
claimName: server-keytab

resource-managers/kubernetes/integration-tests/kerberos-yml/namenode-hadoop-pv.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ metadata:
44
name: nn-hadoop
55
labels:
66
type: local
7+
job: kerberostest
78
spec:
89
capacity:
910
storage: 10Gi

resource-managers/kubernetes/integration-tests/kerberos-yml/nn-deployment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ spec:
2020
- containerPort: 9000
2121
image: ifilonenko/hadoop-base:latest
2222
imagePullPolicy: IfNotPresent
23+
runAsNonRoot: false
2324
volumeMounts:
2425
- mountPath: /var/keytabs
2526
name: nn-keytab

resource-managers/kubernetes/integration-tests/kerberos-yml/server-keytab-pv.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ metadata:
44
name: server-keytab
55
labels:
66
type: local
7+
job: kerberostest
78
spec:
89
capacity:
910
storage: 10Gi

0 commit comments

Comments
 (0)