New to Kestra?
Use blueprints to kickstart your first workflows.
Clone a Git repository and run a PySpark job using Spark Submit with Kestra. Automate distributed Python workloads as part of data engineering pipelines.
id: git-spark
namespace: company.team
tasks:
- id: working_directory
type: io.kestra.plugin.core.flow.WorkingDirectory
tasks:
- id: clone_repository
type: io.kestra.plugin.git.Clone
url: https://github.com/kestra-io/scripts
branch: main
- id: spark_job
type: io.kestra.plugin.spark.SparkCLI
commands:
- spark-submit --name Pi --master spark://localhost:7077
etl/spark_pi.py
Pull your PySpark code straight from version control and submit it to a Spark cluster in one declarative workflow. This blueprint clones a Git repository containing your Spark application, then runs the job with the Spark Submit CLI, so your distributed Python workloads stay in sync with the code in your repo instead of manually copied JARs or scripts. It is a clean pattern for GitOps-style Spark deployments where the latest committed code is always what runs.
The flow runs inside a single io.kestra.plugin.core.flow.WorkingDirectory task so both steps share the same isolated working directory:
clone_repository uses io.kestra.plugin.git.Clone to clone the configured url (the kestra-io/scripts repository) at the main branch into the working directory.spark_job uses io.kestra.plugin.spark.SparkCLI to run spark-submit, pointing at the Spark master with --master spark://localhost:7077 and executing the cloned PySpark file (etl/spark_pi.py).Because both tasks live in the same WorkingDirectory, the freshly cloned code is immediately available to the spark-submit command without any extra file shuffling.
Spark's own scheduler distributes tasks within a job, but it does not pull your code from Git, manage retries across the whole pipeline, or react to upstream events. Kestra wraps the clone and submit steps in declarative YAML, adds event and schedule triggers, retries, and full execution lineage, and lets you chain Spark jobs into larger data pipelines that Spark alone cannot coordinate.
spark://localhost:7077).spark-submit.This blueprint clones a public repository and submits to a local Spark master, so it references no {{ secret('NAME') }} values. To pull from a private repository, add a Git token and pass it to the Clone task as username and password using a secret such as {{ secret('GITHUB_TOKEN') }}.
7077 is exposed.url, branch, and the spark-submit command to match your own repository and PySpark application.url at your own repository and submit your real PySpark application.--master spark://localhost:7077 for a remote master, YARN, or Kubernetes target.--conf and --py-files arguments to spark-submit for tuning and dependencies.