-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-23984][K8S] Initial Python Bindings for PySpark on K8s #21092
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 1 commit
fb5b9ed
b7b3db0
98cef8c
dc670dc
eabe4b9
8d3debb
91e2a2c
5761ee8
98cc044
678d381
bf738dc
c59068d
0344f90
306f3ed
f2fc53e
6f66d60
914ff75
d400607
72953a3
7bedeb6
1801e96
24a704e
6a6d69d
ab92913
a61d897
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ import org.apache.spark.SparkException | |
| import org.apache.spark.deploy.k8s.{KubernetesConf, KubernetesDriverSpecificConf, KubernetesUtils, SparkPod} | ||
| import org.apache.spark.deploy.k8s.Config._ | ||
| import org.apache.spark.deploy.k8s.Constants._ | ||
| import org.apache.spark.deploy.k8s.submit._ | ||
| import org.apache.spark.internal.config._ | ||
| import org.apache.spark.launcher.SparkLauncher | ||
|
|
||
|
|
@@ -44,6 +45,10 @@ private[spark] class BasicDriverFeatureStep( | |
| private val driverCpuCores = conf.get("spark.driver.cores", "1") | ||
| private val driverLimitCores = conf.get(KUBERNETES_DRIVER_LIMIT_CORES) | ||
|
|
||
| private val driverDockerContainer = conf.roleSpecificConf.mainAppResource.map { | ||
| case JavaMainAppResource(_) => "driver" | ||
| case PythonMainAppResource(_) => "driver-py" | ||
| }.getOrElse(throw new SparkException("Must specify a JVM or Python Resource")) | ||
|
||
| // Memory settings | ||
| private val driverMemoryMiB = conf.get(DRIVER_MEMORY) | ||
| private val memoryOverheadMiB = conf | ||
|
|
@@ -89,7 +94,7 @@ private[spark] class BasicDriverFeatureStep( | |
| .addToRequests("memory", driverMemoryQuantity) | ||
| .addToLimits("memory", driverMemoryQuantity) | ||
| .endResources() | ||
| .addToArgs("driver") | ||
| .addToArgs(driverDockerContainer) | ||
| .addToArgs("--properties-file", SPARK_CONF_PATH) | ||
| .addToArgs("--class", conf.roleSpecificConf.mainClass) | ||
| // The user application jar is merged into the spark.jars list and managed through that | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # | ||
| # 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. | ||
| # | ||
|
|
||
| ARG base_img | ||
| FROM $base_img | ||
| WORKDIR / | ||
| COPY python /opt/spark/python | ||
| RUN apk add --no-cache python && \ | ||
| python -m ensurepip && \ | ||
| rm -r /usr/lib/python*/ensurepip && \ | ||
|
Contributor
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. Can we add a comment about why this part? |
||
| pip install --upgrade pip setuptools && \ | ||
|
Member
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. this goes to python2 only, I think?
Contributor
Author
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. Correct. Would love recommendations on dependency management in regards to ‘pip’ as it’s tricky to allow for both pip installation and pip3 installation. Unless I use two separate virtual environments for dependency management
Contributor
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. So you can run both pip and pip3 with the same packages and they'll get installed in different directories and shouldn't stomp on top of eachother. That being said long term venvs are probably the way we want to go, but as we've discussed those are probably non-trivial and should go in a second PR.
Contributor
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. ping
Contributor
Author
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 will include pip3.6 installation for now until we figure out a long-term venv solution in the next PR |
||
| rm -r /root/.cache | ||
|
Contributor
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. Is this just being done for space reasons?
Contributor
Author
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. Yes |
||
| ENV PYTHON_VERSION 2.7.13 | ||
|
||
| ENV PYSPARK_PYTHON python | ||
| ENV PYSPARK_DRIVER_PYTHON python | ||
| ENV PYTHONPATH ${SPARK_HOME}/python/:${SPARK_HOME}/python/lib/py4j-0.10.6-src.zip:${PYTHONPATH} | ||
|
||
|
|
||
| WORKDIR /opt/spark/work-dir | ||
| ENTRYPOINT [ "/opt/entrypoint.sh" ] | ||
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.
One (future concern) is how we would to handle the overlay with both Python and R at the same time.