Run native Spark pipelines on YARN
The native Spark engine can run a pipeline on a Hadoop YARN cluster while Hop itself is the Spark driver: you start the pipeline from Hop GUI, hop-run or Hop Server, and the executors run in YARN containers. Spark calls this client deploy mode.
The alternative is spark-submit --master yarn on a machine with a Spark installation, with a fat jar and a project package; see Getting started with the native Spark engine.
Set up a local standalone cluster first if you have not run a pipeline on a cluster before: the fat jar, the run configuration and the troubleshooting there apply to YARN as well.
What you need
-
Hop 2.20 or later with the
hop-engines-sparkandhop-engines-beamplugins (see Local standalone cluster, steps 1 and 3), and anative-providedfat jar. -
The Hadoop client configuration of the cluster on the Hop machine: a folder with
core-site.xml,hdfs-site.xmlandyarn-site.xml. On a cluster edge node this is often/etc/hadoop/conf. -
Network access from the Hop machine to the YARN ResourceManager and to HDFS (namenode and datanodes), and from the YARN nodes back to the Hop machine: the executors connect to the Spark driver, which is Hop.
-
Java 21 on the YARN nodes, for the Spark processes in the containers. If the nodes run an older Java by default, point the containers at a Java 21 installation (see below).
-
Data that the YARN nodes can read and write, for example on HDFS. The executors cannot read files on the Hop machine.
Kerberos-secured clusters are not covered by this page.
Create the run configuration
Create a Pipeline run configuration with Engine type Native Spark pipeline engine, and use Load configuration template → YARN client as a start. Then set:
| Option | Value | Why |
|---|---|---|
Spark master |
|
The ResourceManager address comes from |
Hadoop configuration folder |
The folder with the cluster’s |
Leave it empty to use the |
Fat jar file location |
The absolute path of a |
The executors load Hop from it. |
Executor memory / Executor cores |
For example |
Must fit in a YARN container ( |
Spark config (key=value lines) |
|
|
What Hop does with this on YARN:
-
It passes every property in the
-site.xmlfiles to Spark asspark.hadoop.<property>. Aspark.hadoop.line in Spark config overrides the same property from the files. -
It sets
spark.yarn.jarsto its own Spark runtime: the jars inplugins/engines/spark/libplus the SLF4J and Jackson jars fromlib/core, about 285 MB. Spark uploads them to the YARN staging folder on HDFS for every run, so the containers run exactly the Spark version Hop runs (4.1.3). If you setspark.yarn.jarsorspark.yarn.archivein Spark config yourself, they must point at Spark 4.1.3 for Scala 2.13 and include those SLF4J and Jackson jars.
Use HDFS paths (hdfs:///data/…) or other storage all nodes can reach in Spark File transforms; see Paths and file systems.
Run it
From Hop GUI or hop-run, run the pipeline with this run configuration. The log shows:
Read <n> Hadoop configuration properties from file:///etc/hadoop/conf/core-site.xml, ...
YARN containers get the engine's Spark runtime: <n> jars in spark.yarn.jars
Created SparkSession version=4.1.3 master=yarn (owned)
...
Spark pipeline finished, result row count=0
The application appears in the YARN ResourceManager UI as Apache Hop (the Application name of the run configuration). Uploading the jars makes the start of every run take a while; a small pipeline takes about a minute.
Like on a standalone cluster, Hop GUI and Hop Server keep their Spark application, and the YARN resources it holds, until they stop; hop-run ends it when the pipeline is done.
Run it through Hop Server
Run a workflow on Hop Server whose Pipeline action uses the YARN run configuration, as described in Run it through Hop Server, with two differences:
-
Set the Hadoop configuration folder in the run configuration, or start Hop Server with
HADOOP_CONF_DIRset. -
Turn Export linked resources to server off in the remote workflow run configuration, and enable the project on Hop Server (
hop-server.sh -j <project>). With export on, Hop Server runs the pipeline from a zip file in its own temporary folder, and the executors on the YARN nodes cannot open it.
With export off, the samples project’s Workflow Log fails every workflow you send to Hop Server; disable that Workflow Log or use your own project (see the troubleshooting table).
Try it with a single-node YARN cluster in Docker
The Hop source tree has a single-node HDFS and YARN cluster for Docker on Linux: docker/integration-tests/integration-tests-spark-native-yarn.yaml. Its Hadoop configuration in docker/integration-tests/spark-yarn/conf serves both the container and Hop on the Docker host.
-
Start it from the root of the Hop source tree:
bashdocker compose -f docker/integration-tests/integration-tests-spark-native-yarn.yaml up -d --buildThe YARN UI is at http://localhost:8088 and HDFS at http://localhost:9870.
-
Copy the sample data to HDFS:
bashC=$(docker compose -f docker/integration-tests/integration-tests-spark-native-yarn.yaml ps -q hadoop-yarn) docker cp /path/to/hop/config/projects/samples/beam/input/customers-noheader-1k.txt $C:/tmp/ docker exec $C hdfs dfs -put -f /tmp/customers-noheader-1k.txt /data/ -
Create the run configuration with Hadoop configuration folder
<hop source>/docker/integration-tests/spark-yarn/conf, your fat jar, and these Spark config lines:spark.ui.enabled=false spark.submit.deployMode=client spark.driver.host=172.31.250.1 spark.executorEnv.JAVA_HOME=/opt/java21 spark.yarn.appMasterEnv.JAVA_HOME=/opt/java21172.31.250.1is the Docker host on the cluster’s network, and/opt/java21is the Java 21 runtime in the image. -
Use the pipeline from the local cluster guide with the paths
hdfs:///data/customers-noheader-1k.txtandhdfs:///output/customers-per-state, and run it. -
Check the result:
bashdocker exec $C bash -c 'hdfs dfs -cat /output/customers-per-state/part-*.csv'
Stop the cluster with docker compose -f docker/integration-tests/integration-tests-spark-native-yarn.yaml down.
Troubleshooting
| Symptom | Cause and fix |
|---|---|
The log shows |
Hop found no Hadoop configuration. Set Hadoop configuration folder, or set |
|
The Hop machine cannot reach the HDFS datanodes to upload the Spark jars. Check the datanode addresses the namenode hands out and the network between the Hop machine and the datanodes. |
|
Look at the logs of the application’s first container in the YARN UI. |
|
|
|
The workflow was sent with Export linked resources to server on. Turn it off and enable the project on Hop Server. |
|
The Spark engine plugin is older than 2.20 and has no YARN support. Update the |
Related pages
-
Native Spark pipeline engine (option reference)
-
Running Spark on YARN (Apache Spark documentation)