← Back to list

Kubernetes에서 Apache Spark 배포하기: spark-submit 이해하기

들어가며

Se Hyeon Kim · 2024-08-19 05:48 · 1 claps · 2.3 min read
#spark #kubernetes #spark-submit
Open on Medium ↗
Wiki topics: ☁️ · DevOps & Cloud 🔧 · Data Engineering

Kubernetes에서 Apache Spark 배포하기: spark-submit 이해하기

Image source

Image source

들어가며

최근 Kubernetes 환경에서 Apache Spark를 배포하는 방법에 대해 공부하고 있습니다. 이 과정에서 가장 먼저 등장한 개념 중 하나가 spark-submit이었습니다. 이 글에서는 spark-submit이 무엇인지, 왜 중요한지, 그리고 Kubernetes에서 어떻게 사용되는지에 대해 알아보겠습니다.

What is spark-submit

The spark-submit script in Spark’s bin directory is used to launch applications on a cluster. It can use all of Spark’s supported cluster managers through a uniform interface.

Cluster Manager Types

  • Standalone
  • Hadoop YARN
  • Kubernetes

Bundling application’s dependencies

For Python, you can use the --py-files argument of spark-submit to add .py, .zip or .egg files to be distributed with your application. If you depend on multiple Python files we recommend packaging them into a .zip or .egg. For third-party Python dependencies

Launching Applications with spark-submit

Once a user application is bundled, it can be launched using the bin/spark-submit script. This script takes care of setting up the classpath with Spark and its dependencies, and can support different cluster managers and deploy modes that Spark supports:

# Run on a Kubernetes cluster in cluster deploy mode
./bin/spark-submit \
  --class org.apache.spark.examples.SparkPi \
  --master k8s://xx.yy.zz.ww:443 \
  --deploy-mode cluster \
  --executor-memory 20G \
  --num-executors 50 \
  http://path/to/examples.jar \
  1000
  • --class: The entry point for your application (e.g. org.apache.spark.examples.SparkPi)
  • --master: The master URL for the cluster (e.g. k8s://xx.yy.zz.ww:443)
  • --deploy-mode: Whether to deploy your driver on the worker nodes (cluster) or locally as an external client (client) (default: client)
  • --conf: Arbitrary Spark configuration property in key=value format. For values that contain spaces wrap “key=value” in quotes (as shown). Multiple configurations should be passed as separate arguments. (e.g. --conf <key>=<value> --conf <key2>=<value2>)
  • application-jar: Path to a bundled jar including your application and all dependencies. The URL must be globally visible inside of your cluster, for instance, an hdfs:// path or a file:// path that is present on all nodes.
  • application-arguments: Arguments passed to the main method of your main class, if any

What is master URL?

k8s://HOST:PORT

Connect to a Kubernetes cluster in client or cluster mode depending on the value of --deploy-mode. The HOST and PORT refer to the Kubernetes API Server. It connects using TLS by default. In order to force it to use an unsecured connection, you can use k8s://http://HOST:PORT.

How it works

spark-submit can be directly used to submit a Spark application to a Kubernetes cluster. The submission mechanism works as follows:

  • Spark creates a Spark driver running within a Kubernetes pod.
  • The driver creates executors which are also running within Kubernetes pods and connects to them, and executes application code.
  • When the application completes, the executor pods terminate and are cleaned up, but the driver pod persists logs and remains in “completed” state in the Kubernetes API until it’s eventually garbage collected or manually cleaned up.

Note that in the completed state, the driver pod does not use any computational or memory resources.

The driver and executor pod scheduling is handled by Kubernetes. Communication to the Kubernetes API is done via fabric8. It is possible to schedule the driver and executor pods on a subset of available nodes through a [node selector](http://Note that in the completed state, the driver pod does not use any computational or memory resources. The driver and executor pod scheduling is handled by Kubernetes. Communication to the Kubernetes API is done via fabric8. It is possible to schedule the driver and executor pods on a subset of available nodes through a node selector using the configuration property for it. It will be possible to use more advanced scheduling hints like node/pod affinities in a future release.) using the configuration property for it. It will be possible to use more advanced scheduling hints like [node/pod affinities](http://Note that in the completed state, the driver pod does not use any computational or memory resources. The driver and executor pod scheduling is handled by Kubernetes. Communication to the Kubernetes API is done via fabric8. It is possible to schedule the driver and executor pods on a subset of available nodes through a node selector using the configuration property for it. It will be possible to use more advanced scheduling hints like node/pod affinities in a future release.) in a future release.


메타데이터
post_id
f44678a4717c
slug
kubernetes에서-apache-spark-배포하기-spark-submit-이해하기-f44678a4717c
url
https://medium.com/@seilylook95/kubernetes%EC%97%90%EC%84%9C-apache-spark-%EB%B0%B0%ED%8F%AC%ED%95%98%EA%B8%B0-spark-submit-%EC%9D%B4%ED%95%B4%ED%95%98%EA%B8%B0-f44678a4717c
canonical_url
https://medium.com/@seilylook95/kubernetes%EC%97%90%EC%84%9C-apache-spark-%EB%B0%B0%ED%8F%AC%ED%95%98%EA%B8%B0-spark-submit-%EC%9D%B4%ED%95%B4%ED%95%98%EA%B8%B0-f44678a4717c
author_url
https://medium.com/@seilylook95
status
ok
fetched_at
2026-08-05 21:16:17