This repository has been archived by the owner on Jan 9, 2020. It is now read-only.
forked from apache/spark
-
Notifications
You must be signed in to change notification settings - Fork 118
SparkR Support #507
Merged
foxish
merged 8 commits into
apache-spark-on-k8s:branch-2.2-kubernetes
from
bloomberg:branch-2.2-kubernetes
Oct 18, 2017
Merged
SparkR Support #507
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d376bb5
initial R support without integration tests
ifilonenko d3af8f5
finished sparkR integration
ifilonenko 0b9210c
case sensitive file names in unix
ifilonenko e539922
revert back to previous lower case in dockerfile
ifilonenko 71bbbf0
addition into the build-push-docker-images
ifilonenko c8a4bc3
Merge branch 'branch-2.2-kubernetes' into branch-2.2-kubernetes
mccheah b092ed4
merge conflicts
ifilonenko e5f606d
Merge branch 'branch-2.2-kubernetes' of https://github.com/bloomberg/…
ifilonenko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/submit/submitsteps/RStep.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* 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.submit.submitsteps | ||
|
||
import io.fabric8.kubernetes.api.model.ContainerBuilder | ||
|
||
import org.apache.spark.deploy.k8s.constants._ | ||
import org.apache.spark.deploy.k8s.submit.KubernetesFileUtils | ||
|
||
private[spark] class RStep( | ||
mainRFile: String, | ||
filesDownloadPath: String) extends DriverConfigurationStep { | ||
|
||
override def configureDriver(driverSpec: KubernetesDriverSpec): KubernetesDriverSpec = { | ||
val withRFileContainer = new ContainerBuilder(driverSpec.driverContainer) | ||
.addNewEnv() | ||
.withName(ENV_R_FILE) | ||
.withValue(KubernetesFileUtils.resolveFilePath(mainRFile, filesDownloadPath)) | ||
.endEnv() | ||
driverSpec.copy(driverContainer = withRFileContainer.build()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...netes/core/src/test/scala/org/apache/spark/deploy/k8s/submit/submitsteps/RStepSuite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* 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.submit.submitsteps | ||
|
||
import io.fabric8.kubernetes.api.model._ | ||
import org.scalatest.BeforeAndAfter | ||
import scala.collection.JavaConverters._ | ||
|
||
import org.apache.spark.{SparkConf, SparkFunSuite} | ||
|
||
class RStepSuite extends SparkFunSuite with BeforeAndAfter { | ||
private val FILE_DOWNLOAD_PATH = "/var/data/spark-files" | ||
private val R_PRIMARY_FILE_OP1 = "local:///app/files/file1.R" | ||
private val RESOLVED_R_PRIMARY_FILE_OP1 = "/app/files/file1.R" | ||
private val R_PRIMARY_FILE_OP2 = "file:///app/files/file2.R" | ||
private val RESOLVED_R_PRIMARY_FILE_OP2 = FILE_DOWNLOAD_PATH + "/file2.R" | ||
|
||
test("testing RSpark with local file") { | ||
val rStep = new RStep( | ||
R_PRIMARY_FILE_OP1, | ||
FILE_DOWNLOAD_PATH) | ||
val returnedDriverContainer = rStep.configureDriver( | ||
KubernetesDriverSpec( | ||
new Pod(), | ||
new Container(), | ||
Seq.empty[HasMetadata], | ||
new SparkConf)) | ||
assert(returnedDriverContainer.driverContainer.getEnv | ||
.asScala.map(env => (env.getName, env.getValue)).toMap === | ||
Map( | ||
"R_FILE" -> RESOLVED_R_PRIMARY_FILE_OP1)) | ||
} | ||
|
||
test("testing RSpark with remote file") { | ||
val rStep = new RStep( | ||
R_PRIMARY_FILE_OP2, | ||
FILE_DOWNLOAD_PATH) | ||
val returnedDriverContainer = rStep.configureDriver( | ||
KubernetesDriverSpec( | ||
new Pod(), | ||
new Container(), | ||
Seq.empty[HasMetadata], | ||
new SparkConf)) | ||
assert(returnedDriverContainer.driverContainer.getEnv | ||
.asScala.map(env => (env.getName, env.getValue)).toMap === | ||
Map( | ||
"R_FILE" -> RESOLVED_R_PRIMARY_FILE_OP2)) | ||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
resource-managers/kubernetes/docker-minimal-bundle/src/main/docker/driver-r/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# | ||
# 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. | ||
# | ||
|
||
FROM spark-base | ||
|
||
# If this docker file is being used in the context of building your images from a Spark distribution, the docker build | ||
# command should be invoked from the top level directory of the Spark distribution. E.g.: | ||
# docker build -t spark-driver-r:latest -f dockerfiles/driver-r/Dockerfile . | ||
|
||
ADD examples /opt/spark/examples | ||
ADD R /opt/spark/R | ||
|
||
RUN apk add --no-cache R R-dev | ||
|
||
ENV R_HOME /usr/lib/R | ||
|
||
CMD SPARK_CLASSPATH="${SPARK_HOME}/jars/*" && \ | ||
env | grep SPARK_JAVA_OPT_ | sed 's/[^=]*=\(.*\)/\1/g' > /tmp/java_opts.txt && \ | ||
readarray -t SPARK_DRIVER_JAVA_OPTS < /tmp/java_opts.txt && \ | ||
if ! [ -z ${SPARK_MOUNTED_CLASSPATH+x} ]; then SPARK_CLASSPATH="$SPARK_MOUNTED_CLASSPATH:$SPARK_CLASSPATH"; fi && \ | ||
if ! [ -z ${SPARK_SUBMIT_EXTRA_CLASSPATH+x} ]; then SPARK_CLASSPATH="$SPARK_SUBMIT_EXTRA_CLASSPATH:$SPARK_CLASSPATH"; fi && \ | ||
if ! [ -z ${SPARK_EXTRA_CLASSPATH+x} ]; then SPARK_CLASSPATH="$SPARK_EXTRA_CLASSPATH:$SPARK_CLASSPATH"; fi && \ | ||
if ! [ -z ${SPARK_MOUNTED_FILES_DIR+x} ]; then cp -R "$SPARK_MOUNTED_FILES_DIR/." .; fi && \ | ||
if ! [ -z ${SPARK_MOUNTED_FILES_FROM_SECRET_DIR+x} ]; then cp -R "$SPARK_MOUNTED_FILES_FROM_SECRET_DIR/." .; fi && \ | ||
${JAVA_HOME}/bin/java "${SPARK_DRIVER_JAVA_OPTS[@]}" -cp $SPARK_CLASSPATH -Xms$SPARK_DRIVER_MEMORY -Xmx$SPARK_DRIVER_MEMORY $SPARK_DRIVER_CLASS $R_FILE $SPARK_DRIVER_ARGS |
38 changes: 38 additions & 0 deletions
38
resource-managers/kubernetes/docker-minimal-bundle/src/main/docker/executor-r/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# | ||
# 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. | ||
# | ||
|
||
FROM spark-base | ||
|
||
# If this docker file is being used in the context of building your images from a Spark distribution, the docker build | ||
# command should be invoked from the top level directory of the Spark distribution. E.g.: | ||
# docker build -t spark-executor-r:latest -f dockerfiles/executor-r/Dockerfile . | ||
|
||
ADD examples /opt/spark/examples | ||
ADD R /opt/spark/R | ||
|
||
RUN apk add --no-cache R R-dev | ||
|
||
ENV R_HOME /usr/lib/R | ||
|
||
CMD SPARK_CLASSPATH="${SPARK_HOME}/jars/*" && \ | ||
env | grep SPARK_JAVA_OPT_ | sed 's/[^=]*=\(.*\)/\1/g' > /tmp/java_opts.txt && \ | ||
readarray -t SPARK_EXECUTOR_JAVA_OPTS < /tmp/java_opts.txt && \ | ||
if ! [ -z ${SPARK_MOUNTED_CLASSPATH}+x} ]; then SPARK_CLASSPATH="$SPARK_MOUNTED_CLASSPATH:$SPARK_CLASSPATH"; fi && \ | ||
if ! [ -z ${SPARK_EXECUTOR_EXTRA_CLASSPATH+x} ]; then SPARK_CLASSPATH="$SPARK_EXECUTOR_EXTRA_CLASSPATH:$SPARK_CLASSPATH"; fi && \ | ||
if ! [ -z ${SPARK_MOUNTED_FILES_DIR+x} ]; then cp -R "$SPARK_MOUNTED_FILES_DIR/." .; fi && \ | ||
if ! [ -z ${SPARK_MOUNTED_FILES_FROM_SECRET_DIR+x} ]; then cp -R "$SPARK_MOUNTED_FILES_FROM_SECRET_DIR/." .; fi && \ | ||
${JAVA_HOME}/bin/java "${SPARK_EXECUTOR_JAVA_OPTS[@]}" -Dspark.executor.port=$SPARK_EXECUTOR_PORT -Xms$SPARK_EXECUTOR_MEMORY -Xmx$SPARK_EXECUTOR_MEMORY -cp $SPARK_CLASSPATH org.apache.spark.executor.CoarseGrainedExecutorBackend --driver-url $SPARK_DRIVER_URL --executor-id $SPARK_EXECUTOR_ID --cores $SPARK_EXECUTOR_CORES --app-id $SPARK_APPLICATION_ID --hostname $SPARK_EXECUTOR_POD_IP |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Important here that, similar to Python Primary Resource, that the R File is distributed via --files.