Configuring prerequisites
Before you can start using on-demand Spark clusters on Domino you need to ensure that this functionality is enabled and properly configured on your deployment.
Note
Domino on-demand Spark functionality is available starting with Domino 4.2.
Enabling Spark on your deployment
Domino Administrators need to:
-
Enable on-demand Spark functionality
Set ShortLived.SparkClustersEnabled feature flag to true.
-
Enable new workspace experience
Set ShortLived.UseNewWorkspaceChrome to true. This enables the new Domino workspace experience which allows for easy access to the Spark Web UI.
Creating a base Spark cluster environment
By default, Domino does not come with a Spark compatibleCompute Environment that can be used for the components of the cluster. Without at least one such environment available, you will not be able to create a cluster.
Note that when using on-demand Spark in Domino you will have two separate environments - one for the Spark cluster and one for the workspace/job.
To create a new base Spark cluster environment, you will follow the genera Environment Management with the following environment attributes
-
Base image
select the Custom Image option and specify an image URI that points to a deployable Spark image.
It is recommended that you use the latest specific release tag for your desired version of Spark. For example, a suitable recent version would be represented by bitnami/spark:2.4.6-debian-10-r14.
Note
Minimum image tag
When using Spark 2.4.5, you need to use image bitnami/spark:2.4.5-debian-10-r136 or a more recent revision. This will ensure proper compatibility for S3 access.
Image compatibility
Domino's on-demand Spark functionality has been developed and tested using open-source Spark images from Bitnami. While not been explicitly verified, it may be possible to use a different base image, as long as that image is compatible the Bitnami Spark Helm Chart.
For more information on the benefits, see the Why use Bitnami images section of the Bitnami image distribution page.
-
Supported clusters
Select the Domino managed Spark option (REQUIRED). This will ensure that the environment will be available for use when creating Spark clusters from workspaces and jobs.
-
Visibility
You can set this attribute the same way you would for any other Compute Environment based on your desired visibility.
-
Dockerfile Instructions
Leave blank to use the default Hadoop client libraries or follow the instructions for custom Hadoop client libraries.
You can further add to this section to include any additional dependencies (JARs and packages) that should be available on the cluster nodes of any cluster.
To learn more, refer to Managing dependencies
-
Pluggable Notebooks / Workspace Sessions
This section should remain blank as the Spark base environments are not intended to also include notebook configuration.
Base Spark cluster environment - default Hadoop client libraries
Leave the Docker Instructions section blank, if you want a thin base image that only contains core Spark with the default Hadoop client libraries. Currently both Spark 2.4.x and Spark 3.0.0 come with Hadoop 2.7.
Base Spark cluster environment (Advanced) - custom Hadoop client libraries
In some cases the Hadoop client libraries pre-bundled with your desired Spark version may not be appropriate for your needs. This would typically be the case if you want to utilize cloud object store connector improvements introduced post Hadoop 2.7.
Add the following to the Docker Instructions section adjusting for the desired Spark and Hadoop version.
### need if using the recommended Bitnami base image USER root ### Make sure wget is available RUN apt-get update && apt-get install -y wget && rm -r /var/lib/apt/lists /var/cache/apt/archives ### Modify the Hadoop and Spark versions below as needed. ### NOTE: The HADOOP_HOME and SPARK_HOME locations should not be modified ENV HADOOP_VERSION=2.9.2 ENV HADOOP_HOME=/opt/bitnami/hadoop ENV HADOOP_CONF_DIR=/opt/bitnami/hadoop/etc/hadoop ENV SPARK_VERSION=2.4.6 ENV SPARK_HOME=/opt/bitnami/spark ENV PATH="$PATH:$SPARK_HOME/bin:$HADOOP_HOME/bin" ### Enable this for access to ADLS Gen2 when using Hadoop 3.2+ ### ENV HADOOP_OPTIONAL_TOOLS=hadoop-azure ### Remove the pre-installed Spark since it is pre-bundled with hadoop but preserve the python env WORKDIR /opt/bitnami RUN [ -d ${SPARK_HOME}/venv ] && mv ${SPARK_HOME}/venv /opt/bitnami/temp-venv RUN rm -rf ${SPARK_HOME} ### Install the desired Hadoop-free Spark distribution RUN wget -q https://archive.apache.org/dist/spark/spark-${SPARK_VERSION}/spark-${SPARK_VERSION}-bin-without-hadoop.tgz && \ tar -xf spark-${SPARK_VERSION}-bin-without-hadoop.tgz && \ rm spark-${SPARK_VERSION}-bin-without-hadoop.tgz && \ mv spark-${SPARK_VERSION}-bin-without-hadoop ${SPARK_HOME} && \ chmod -R 777 ${SPARK_HOME}/conf ### Restore the virtual python environment RUN [ -d /opt/bitnami/temp-venv ] && mv /opt/bitnami/temp-venv ${SPARK_HOME}/venv ### Install the desired Hadoop libraries RUN wget -q http://archive.apache.org/dist/hadoop/common/hadoop-${HADOOP_VERSION}/hadoop-${HADOOP_VERSION}.tar.gz && \ tar -xf hadoop-${HADOOP_VERSION}.tar.gz && \ rm hadoop-${HADOOP_VERSION}.tar.gz && \ mv hadoop-${HADOOP_VERSION} ${HADOOP_HOME} ### Setup the Hadoop libraries classpath RUN echo 'export SPARK_DIST_CLASSPATH="$(hadoop classpath):'"${HADOOP_HOME}"'/share/hadoop/tools/lib/*"' >> ${SPARK_HOME}/conf/spark-env.sh ENV LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:$HADOOP_HOME/lib/native" ### This is important to maintain compatibility with Bitnami WORKDIR / RUN /opt/bitnami/scripts/spark/postunpack.sh WORKDIR ${SPARK_HOME} USER 1001
Preparing your PySpark compute environment
In addition to the base Spark cluster environment, you also need to configure the PySpark compute environments for workspaces and/or jobs that will connect to your cluster.
You can either enhance the Docker Instructions section of an existing environment or create a new environment that uses an existing environment as its base.
PySpark compute environment - default Hadoop client libraries
The Bitnami base images referenced above come pre-built with Hadoop. For Spark 2.4.X and Spark 3.0.0, the pre-built Hadoop version currently is 2.7. If this is appropriate for your needs, you can use the simplified configuration instructions below to install and configure PySpark.
Note
PySpark 2 does not support Python 3.8 or higher. Build PySpark 2 compute environments from images with Python before 3.8.
Note
The Spark version below should match the Spark version used when creating the Spark-enabled compute environment above. In the example here, this version is 2.4.6 but should be adjusted as Spark evolves.
### Clear any existing PySpark install that may exist ### Omit if you know the environment does not have PySpark RUN pip uninstall pyspark &>/dev/null ### Install PySpark matching the Spark version of your base image ### Modify the version below as needed RUN pip install pyspark==2.4.6 ### Set SPARK_HOME on the driver to point to the version installed by pyspark RUN \ SPARK_HOME=$(pip show pyspark | grep "Location" | awk '{print $2}')/pyspark && \ chown -R ubuntu:ubuntu ${SPARK_HOME} && \ echo "export SPARK_HOME=${SPARK_HOME}" >> /home/ubuntu/.domino-defaults && \ echo "export PATH=\$PATH:${SPARK_HOME}/bin" >> /home/ubuntu/.domino-defaults ### Optionally copy spark-submit to spark-submit.sh to be able to run from Domino jobs RUN spark_submit_path=$(which spark-submit) && \ cp ${spark_submit_path} ${spark_submit_path}.sh ### Hadoop 2.7 does not come with the required binaries for AWS access so we add them ### hadoop-aws.jar must match the hadoop-common.jar version of your install RUN \ SPARK_HOME=$(pip show pyspark | grep "Location" | awk '{print $2}')/pyspark && \ rm -rf ${SPARK_HOME}/hadoop-aws* && \ rm -rf ${SPARK_HOME}/aws-java-sdk* && \ curl https://repo1.maven.org/maven2/org/apache/hadoop/hadoop-aws/2.7.3/hadoop-aws-2.7.3.jar --output ${SPARK_HOME}/jars/hadoop-aws-2.7.3.jar && \ curl https://repo1.maven.org/maven2/com/amazonaws/aws-java-sdk/1.7.4/aws-java-sdk-1.7.4.jar --output ${SPARK_HOME}/jars/aws-java-sdk-1.7.4.jar
PySpark compute environment (Advanced) - custom Hadoop client libraries
In some cases the Hadoop libraries pre-bundled with your desired Spark version may not be appropriate for your needs. This would typically be the case if you want to utilize cloud object store connector improvements introduced post Hadoop 2.7.
You can follow the instructions below to configure your environment with PySpark and a custom Hadoop client libraries version.
RUN mkdir -p /opt/domino ### Modify the Hadoop and Spark versions below as needed. ENV HADOOP_VERSION=2.9.2 ENV HADOOP_HOME=/opt/domino/hadoop ENV HADOOP_CONF_DIR=/opt/domino/hadoop/etc/hadoop ENV SPARK_VERSION=2.4.6 ENV SPARK_HOME=/opt/domino/spark ENV PATH="$PATH:$SPARK_HOME/bin:$HADOOP_HOME/bin" ### Enable this for access to ADLS Gen2 when using Hadoop 3.2+ ### ENV HADOOP_OPTIONAL_TOOLS=hadoop-azure ### Install the desired Hadoop-free Spark distribution RUN rm -rf ${SPARK_HOME} && \ wget -q https://archive.apache.org/dist/spark/spark-${SPARK_VERSION}/spark-${SPARK_VERSION}-bin-without-hadoop.tgz && \ tar -xf spark-${SPARK_VERSION}-bin-without-hadoop.tgz && \ rm spark-${SPARK_VERSION}-bin-without-hadoop.tgz && \ mv spark-${SPARK_VERSION}-bin-without-hadoop ${SPARK_HOME} && \ chmod -R 777 ${SPARK_HOME}/conf ### Install the desired Hadoop libraries RUN rm -rf ${HADOOP_HOME} && \ wget -q http://archive.apache.org/dist/hadoop/common/hadoop-${HADOOP_VERSION}/hadoop-${HADOOP_VERSION}.tar.gz && \ tar -xf hadoop-${HADOOP_VERSION}.tar.gz && \ rm hadoop-${HADOOP_VERSION}.tar.gz && \ mv hadoop-${HADOOP_VERSION} ${HADOOP_HOME} ### Setup the Hadoop libraries classpath and Spark related envars for proper init in Domino RUN echo "export SPARK_HOME=${SPARK_HOME}" >> /home/ubuntu/.domino-defaults RUN echo "export HADOOP_HOME=${HADOOP_HOME}" >> /home/ubuntu/.domino-defaults RUN echo "export HADOOP_CONF_DIR=${HADOOP_CONF_DIR}" >> /home/ubuntu/.domino-defaults RUN echo "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:${HADOOP_HOME}/lib/native" >> /home/ubuntu/.domino-defaults RUN echo "export PATH=\$PATH:${SPARK_HOME}/bin:${HADOOP_HOME}/bin" >> /home/ubuntu/.domino-defaults RUN echo "export SPARK_DIST_CLASSPATH=\"\$(hadoop classpath):${HADOOP_HOME}/share/hadoop/tools/lib/*\"" >> ${SPARK_HOME}/conf/spark-env.sh ### Complete the PySpark setup from the Spark distribution files WORKDIR $SPARK_HOME/python RUN python setup.py install ### Optionally copy spark-submit to spark-submit.sh to be able to run from Domino jobs RUN spark_submit_path=$(which spark-submit) && \ cp ${spark_submit_path} ${spark_submit_path}.sh ### Hadoop 2.7 does not come with the required binaries for AWS access so we add them ### hadoop-aws.jar must match the hadoop-common.jar version of your install RUN \ SPARK_HOME=$(pip show pyspark | grep "Location" | awk '{print $2}')/pyspark && \ rm -rf ${SPARK_HOME}/hadoop-aws* && \ rm -rf ${SPARK_HOME}/aws-java-sdk* && \ curl https://repo1.maven.org/maven2/org/apache/hadoop/hadoop-aws/2.7.3/hadoop-aws-2.7.3.jar --output ${SPARK_HOME}/jars/hadoop-aws-2.7.3.jar && \ curl https://repo1.maven.org/maven2/com/amazonaws/aws-java-sdk/1.7.4/aws-java-sdk-1.7.4.jar --output ${SPARK_HOME}/jars/aws-java-sdk-1.7.4.jar ### Optionally install boto3 which can help working with AWS credential file profiles ### Can omit if not needed RUN pip install boto3
Comments
0 comments
Please sign in to leave a comment.