Including spark-submit in a Custom Cloudera Workflow Orchestrator Image

Learn how to extract Apache Spark binaries from a Cloudera Manager host and bundle them into a custom Cloudera Workflow Orchestrator image.

Cloudera Workflow Orchestrator ships with the apache-airflow-providers-apache-spark package, which provides operators such as SparkSubmitOperator. However, to keep base image sizes small and maintain compatibility across different Cloudera Runtime versions, the default Cloudera Workflow Orchestrator image does not bundle Spark client binaries.

To execute Spark jobs using Airflow operators, you must create a custom Cloudera Workflow Orchestrator image that contains the Spark client binaries matching your Cloudera Runtime environment.

  1. Active SSH access to the Cloudera Manager server host.
  2. A Docker build environment for creating custom Cloudera Workflow Orchestrator container images.
  1. SSH into the Cloudera Manager server host and locate of the Spark directory on the Cloudera Manager host:
    ssh [***CLOUDERA-MANAGER-SERVER-HOST***] "ls -hal /opt/cloudera/parcels/CDH/lib"
  2. Compress and download the Spark binaries locally as an archive named spark.tar.gz:
    ssh [***CLOUDERA-MANAGER-SERVER-HOST***] "tar -chzvf - -C /opt/cloudera/parcels/CDH/lib spark3" > spark.tar.gz
  3. Place the downloaded archive into your Docker build context directory (for example, lib/spark/spark.tar.gz).
  4. In the Dockerfile for your custom Cloudera Workflow Orchestrator image, extract the Spark binaries and add them to PATH so an Apache Spark Submit connection in Airflow can use them.

    Example,

    For including the downloaded Spark binaries lib/spark/spark.tar.gz in a Dockerfile:

    # Extract Spark binaries to /opt/spark3
    RUN --mount=type=bind,source=lib/spark,target=/var/spark tar -xzf /var/spark/spark.tar.gz -C /opt
    ENV PATH="[***PATH-TO-THE-SPARKSUBMIT-BINARY'S-FOLDER***]:${PATH}"
  5. Build and tag your custom Cloudera Workflow Orchestrator image for deployment in your Cloudera Workflow Orchestrator environment. For building custom images, see Create a custom image.