Run Spark Submit (spark-submit) on Kubernetes
इलम में एक साधारण स्पार्क नौकरी मानक के माध्यम से प्रस्तुत की तरह ही संचालित होती है स्पार्क-सबमिट कमांड, लेकिन उपयोग में आसानी, कॉन्फ़िगरेशन और बाहरी उपकरणों के साथ एकीकरण के लिए अतिरिक्त संवर्द्धन के साथ।
आप अपने स्थानीय स्पार्क इंस्टॉलेशन या आपके पास मौजूद किसी भी कस्टम जार से स्पार्क उदाहरणों के साथ जेएआर फ़ाइल का उपयोग कर सकते हैं।
नीचे एक साधारण स्पार्क नौकरी का उपयोग करने और चलाने के लिए चरण-दर-चरण मार्गदर्शिका दी गई है स्पार्क-सबमिट on Ilum. This guide demonstrates the core configuration needed and shows how to monitor your job’s progress within the Ilum platform. For a complete overview of Ilum's architecture, check the Architecture Overview.
How do I run a Spark job on Kubernetes with स्पार्क-सबमिट?
To run a Spark job on Ilum (Kubernetes), ensure Java 17 and Spark are installed, upload your JAR, and run:
- Spark 4 (default)
- Spark 3
./bin/spark-submit \
--गुरू k8s://http://<ilum-core-address>:<ilum-core-port> \
--deploy-mode क्लस्टर \
--कक्षा org.apache.spark.examples.SparkPi \
--conf spark.driver.memory=4g \
--conf spark.ilum.cluster=चूक \
--conf स्पार्क.कुबेरनेट्स.कंटेनर.इमेज=ilum/spark:4.1.2 \
--conf spark.kubernetes.submission.waitAppCompletion=सच्चा \
s3a://ilum-files/ilum/default/spark-examples_2.13-4.1.2.jar
./bin/spark-submit \
--गुरू k8s://http://<ilum-core-address>:<ilum-core-port> \
--deploy-mode क्लस्टर \
--कक्षा org.apache.spark.examples.SparkPi \
--conf spark.driver.memory=4g \
--conf spark.ilum.cluster=चूक \
--conf स्पार्क.कुबेरनेट्स.कंटेनर.इमेज=ilum/spark:3.5.8 \
--conf spark.kubernetes.submission.waitAppCompletion=सच्चा \
s3a://ilum-files/ilum/default/spark-examples_2.12-3.5.8.jar
Note: Replace with your actual Ilum Core endpoint.
Step-by-Step Guide
1. Prerequisites
- सुनिश्चित करें कि जावा 17 स्थापित है और आपके में सही ढंग से सेट है
JAVA_HOME. - Download and extract the appropriate version of Apache Spark:
- Spark 4 (default)
- Spark 3
wget https://archive.apache.org/dist/spark/spark-4.1.2/spark-4.1.2-bin-hadoop3.tgz
tar -xzf spark-4.1.2-bin-hadoop3.tgz
cd spark-4.1.2-bin-hadoop3
wget https://dlcdn.apache.org/spark/spark-3.5.8/spark-3.5.8-bin-hadoop3.tgz
tar -xzf spark-3.5.8-bin-hadoop3.tgz
cd spark-3.5.8-bin-hadoop3
2. Connect to Ilum
If Ilum is deployed on Kubernetes, forward the service port to your local machine to make Ilum accessible at लोकलहोस्ट:9888.
kubectl port-forward svc/ilum-core 9888:9888
यदि आप एक ही कुबेरनेट्स क्लस्टर के भीतर से संचार कर रहे हैं, तो आप कुबेरनेट्स डीएनएस-आधारित सेवा पते का उपयोग कर सकते हैं (जैसे, http://ilum-core.namespace.svc.cluster.local) or expose services using Ingress.
3. Submit Your Spark Job
Choose the submission method that best fits your workflow:
- REST (Local Testing)
- Kubernetes (Production)
- Auto-Upload (Local JAR)
This method is suitable for quick local testing.
1. Upload your JAR File
For demonstration, we assume the JAR is uploaded manually to MinIO.
- Spark 4 (default)
- Spark 3
Locate the example JAR: examples/jars/spark-examples_2.13-4.1.2.jar
Upload it to MinIO (bucket इलम फ़ाइलें, path ilum/default/): s3a://ilum-files/ilum/default/spark-examples_2.13-4.1.2.jar
Locate the example JAR: examples/jars/spark-examples_2.12-3.5.8.jar
Upload it to MinIO (bucket इलम फ़ाइलें, path ilum/default/): s3a://ilum-files/ilum/default/spark-examples_2.12-3.5.8.jar
2. Submit via REST
स्पार्क.ilum.pyआवश्यकताएँ is not supported in this mode, as REST does not support PySpark submissions.
Run the following command:
- Spark 4 (default)
- Spark 3
./bin/spark-submit \
--गुरू spark://localhost:9888 \
--deploy-mode क्लस्टर \
--कक्षा org.apache.spark.examples.SparkPi \
--conf spark.master.rest.enabled=सच्चा \
--conf spark.ilum.cluster=चूक \
--conf spark.app.name=my-spark-job \
s3a://ilum-files/ilum/default/spark-examples_2.13-4.1.2.jar
./bin/spark-submit \
--गुरू spark://localhost:9888 \
--deploy-mode क्लस्टर \
--कक्षा org.apache.spark.examples.SparkPi \
--conf spark.master.rest.enabled=सच्चा \
--conf spark.ilum.cluster=चूक \
--conf spark.app.name=my-spark-job \
s3a://ilum-files/ilum/default/spark-examples_2.12-3.5.8.jar
Parameters:
| Parameter | या क़िस्म |
|---|---|
--गुरू | Ilum Core address via REST (e.g. spark://localhost:9888). |
--conf spark.master.rest.enabled=true | Enables REST submission. |
s3a/... | JAR file path in MinIO. |
Expected Output
REST एप्लिकेशन सबमिशन प्रोटोकॉल का उपयोग करके स्पार्क चलाना।
25/03/12 12:58:01 जानकारी RestSubmissionClient: spark://localhost:9888 में एक आवेदन शुरू करने के लिए एक अनुरोध सबमिट करना।
25/03/12 12:58:03 जानकारी RestSubmissionClient: सबमिशन सफलतापूर्वक 20250312-1158-qdnioef2rny के रूप में बनाया गया। मतदान प्रस्तुत करने की स्थिति...
25/03/12 12:58:03 जानकारी RestSubmissionClient: spark://localhost:9888 में सबमिशन 20250312-1158-qdnioef2rny की स्थिति के लिए अनुरोध सबमिट करना।
25/03/12 12:58:03 जानकारी RestSubmissionClient: ड्राइवर की स्थिति 20250312-1158-qdnioef2rny अब सबमिट किया गया है।
25/03/12 12:58:03 जानकारी RestSubmissionClient: ड्राइवर ILUM_UI_ADDRESS/workloads/details/job/20250312-1158-qdnioef2rny पर वर्कर ILUM पर चल रहा है।
25/03/12 12:58:03 जानकारी RestSubmissionClient: सर्वर CreateSubmissionResponse के साथ प्रतिसाद:
{
"कार्रवाई": "CreateSubmissionResponse",
"serverSparkVersion" : "4.1.2",
"सबमिशन आईडी": "20250312-1158-qdnioef2rny",
"सफलता": सच
}
25/03/12 12:58:03 जानकारी ShutdownHookManager: शटडाउन हुक कहा जाता है
25/03/12 12:58:03 जानकारी शटडाउनहुक मैनेजर: निर्देशिका हटाना /tmp/spark-fa2603be-488a-4e2a-9b7f-5e49825d379b
This method is recommended for production and supports advanced features like Python dependencies.
1. Upload your JAR File
For demonstration, we assume the JAR is uploaded manually to MinIO.
In production environments, this process should be automated and executed programmatically (e.g., using AWS SDK, Hadoop's S3A connector) before triggering स्पार्क-सबमिट.
- Spark 4 (default)
- Spark 3
Locate the example JAR: examples/jars/spark-examples_2.13-4.1.2.jar
Upload it to MinIO (bucket इलम फ़ाइलें, path ilum/default/): s3a://ilum-files/ilum/default/spark-examples_2.13-4.1.2.jar
Locate the example JAR: examples/jars/spark-examples_2.12-3.5.8.jar
Upload it to MinIO (bucket इलम फ़ाइलें, path ilum/default/): s3a://ilum-files/ilum/default/spark-examples_2.12-3.5.8.jar
2. Submit via Kubernetes Mode
Include Ilum-specific configurations for better management:
--conf spark.ilum.cluster=default--conf spark.app.name=my-spark-job--conf spark.ilum.tags=analytics,pi-calculation--conf spark.ilum.pyRequirements = "numpy == 1.24.1, pandas == 2.0.3"(if using Python)
These configurations allow you to better categorize, identify, and manage jobs within the Ilum UI. Run this command:
- Spark 4 (default)
- Spark 3
./bin/spark-submit \
--गुरू k8s://http://localhost:9888 \
--deploy-mode क्लस्टर \
--कक्षा org.apache.spark.examples.SparkPi \
--conf spark.driver.memory=4g \
--conf spark.ilum.cluster=चूक \
--conf स्पार्क.कुबेरनेट्स.कंटेनर.इमेज=ilum/spark:4.1.2 \
--conf spark.kubernetes.submission.waitAppCompletion=सच्चा \
s3a://ilum-files/ilum/default/spark-examples_2.13-4.1.2.jar
./bin/spark-submit \
--गुरू k8s://http://localhost:9888 \
--deploy-mode क्लस्टर \
--कक्षा org.apache.spark.examples.SparkPi \
--conf spark.driver.memory=4g \
--conf spark.ilum.cluster=चूक \
--conf स्पार्क.कुबेरनेट्स.कंटेनर.इमेज=ilum/spark:3.5.8 \
--conf spark.kubernetes.submission.waitAppCompletion=सच्चा \
s3a://ilum-files/ilum/default/spark-examples_2.12-3.5.8.jar
Parameters:
| Parameter | या क़िस्म |
|---|---|
--गुरू | Address of your Kubernetes API (or Ilum Core for REST mode). |
--deploy-mode क्लस्टर | Submits the job to the Spark cluster. |
--कक्षा | Entry point class of your Spark application (use format फ़ाइल नाम.क्लासनाम पायथन के लिए)। |
--conf spark.driver.memory | Specifies memory allocation for the driver. |
--conf spark.ilum.cluster | Logical cluster name defined in Ilum. |
--conf spark.kubernetes.container.image | Docker image containing Spark. |
--conf spark.kubernetes.submission.waitAppCompletion=true | Keeps the CLI process attached until the job completes. |
s3a/... | JAR path in S3-compatible storage like MinIO. |
Expected Output
25/04/02 15:42:30 जानकारी SparkKubernetesClientFactory: K8S कॉन्फ़िगरेशन फ़ाइल के उपयोगकर्ताओं से वर्तमान संदर्भ का उपयोग करके K8S क्लाइंट को ऑटो-कॉन्फ़िगर करना
25/04/02 15:42:38 जानकारी लॉगिंगPodStatusWatcherImpl: राज्य बदल गया, नया राज्य:
फली नाम: org-apache-spark-examples-sparkpi-30ae6d95f6bd37fd-driver
नामस्थान: डिफ़ॉल्ट
लेबल: ilum.jobId -> 20250402-1342-s55afwq7gax, ilum.clusterName -> डिफ़ॉल्ट
पॉड यूआईडी: 20250402-1342-S55AFWQ7GAX
निर्माण समय: 2025-04-02T13:42:37.145Z
सेवा खाता नाम: ilum-test-ilum-core-spark
वॉल्यूम: N/A
नोड नाम: इलम
प्रारंभ समय: 2025-04-02T13:42:37.145Z
चरण: चल रहा है
कंटेनर की स्थिति:
कंटेनर का नाम: स्पार्क-ड्राइवर
container image: ilum/spark:4.1.2
कंटेनर स्थिति: चल रहा है
कंटेनर शुरू हुआ: 2025-04-02T13:42:37.145Z
25/04/02 15:42:38 जानकारी LoggingPodStatusWatcherImpl: आवेदन की प्रतीक्षा org.apache.spark.examples.SparkPi एप्लिकेशन आईडी के साथ spark-a4f8f1eb4ed344f38d799d79817c45dc और सबमिशन आईडी डिफ़ॉल्ट:org-apache-spark-examples-sparkpi-30ae6d95f6bd37fd-driver समाप्त करने के लिए...
25/04/02 15:42:39 जानकारी लॉगिंगPodStatusWatcherImpl: स्पार्क-a4f8f1eb4ed344f38d799d79817c45dc (चरण: चल रहा है) के लिए आवेदन की स्थिति
...
25/04/02 15:43:03 जानकारी लॉगिंगPodStatusWatcherImpl: स्पार्क-a4f8f1eb4ed344f38d799d79817c45dc (चरण: चल रहा है) के लिए आवेदन की स्थिति
25/04/02 15:43:03 जानकारी लॉगिंगPodStatusWatcherImpl: कंटेनर अंतिम स्थिति:
कंटेनर का नाम: स्पार्क-ड्राइवर
container image: ilum/spark:4.1.2
container state: terminated
कंटेनर शुरू हुआ: 2025-04-02T13:42:37.145Z
container finished at: 2025-04-02T13:43:03.145Z
exit code: 0
termination reason: Spark job completed
25/04/02 15:43:03 जानकारी LoggingPodStatusWatcherImpl: आवेदन org.apache.spark.examples.SparkPi आवेदन आईडी के साथ spark-a4f8f1eb4ed344f38d799d79817c45dc और सबमिशन आईडी डिफ़ॉल्ट:org-apache-spark-examples-sparkpi-30ae6d95f6bd37fd-driver समाप्त
25/04/02 15:43:03 जानकारी ShutdownHookManager: शटडाउन हुक कहा जाता है
25/04/02 15:43:03 जानकारी शटडाउनHookManager: निर्देशिका हटाना /tmp/spark-61e63485-79a3-491d-9bac-c71a8c1d96aa
Ilum can automatically upload your local JARs to MinIO during submission.
1. Additional Prerequisites Forward the MinIO port so the local Spark client can upload files:
kubectl port-forward svc/ilum-minio 9000:9000
2. Download S3 Dependencies
Download the required Hadoop/AWS JARs to your local जार folder:
Spark 4.x bundles hadoop-client-3.4.x which uses time-suffixed config values (e.g., "60s"). Using hadoop-aws-3.3.4 with Spark 4.x will fail with java.lang.NumberFormatException: For input string: "60s". Make sure to use the matching hadoop-aws version for your Spark version.
- Spark 4 (default)
- Spark 3
wget -P जार \
https://repo1.maven.org/maven2/org/apache/hadoop/hadoop-aws/3.4.1/hadoop-aws-3.4.1.jar \
https://repo1.maven.org/maven2/com/amazonaws/aws-java-sdk-bundle/1.12.367/aws-java-sdk-bundle-1.12.367.jar \
https://repo1.maven.org/maven2/software/amazon/awssdk/bundle/2.24.6/bundle-2.24.6.jar
wget -P जार \
https://repo1.maven.org/maven2/org/apache/hadoop/hadoop-aws/3.3.4/hadoop-aws-3.3.4.jar \
https://repo1.maven.org/maven2/com/amazonaws/aws-java-sdk/1.12.262/aws-java-sdk-1.12.262.jar \
https://repo1.maven.org/maven2/com/amazonaws/aws-java-sdk-core/1.12.262/aws-java-sdk-core-1.12.262.jar \
https://repo1.maven.org/maven2/com/amazonaws/aws-java-sdk-dynamodb/1.12.262/aws-java-sdk-dynamodb-1.12.262.jar \
https://repo1.maven.org/maven2/com/amazonaws/aws-java-sdk-s3/1.12.262/aws-java-sdk-s3-1.12.262.jar
3. Submit with Auto-Upload
This command includes configuration to connect to the local MinIO port and upload files. (replace image/tag or S3 credentials as needed)
- Spark 4 (default)
- Spark 3
./bin/spark-submit \
--गुरू k8s://http://localhost:9888 \
--deploy-mode क्लस्टर \
--कक्षा org.apache.spark.examples.SparkPi \
--conf spark.ilum.cluster=चूक \
--conf spark.app.name=my-sparkpi-job \
--conf स्पार्क.कुबेरनेट्स.कंटेनर.इमेज=ilum/spark:4.1.2 \
--conf spark.kubernetes.submission.waitAppCompletion=सच्चा \
--conf spark.kubernetes.file.upload.path=s3a://ilum-files/spark-jobs \
--conf स्पार्क.hadoop.fs.s3a.endpoint=http://localhost:9000 \
--conf spark.hadoop.fs.s3a.access.key=मिनीएडमिन \
--conf spark.hadoop.fs.s3a.secret.key=मिनीएडमिन \
--conf स्पार्क.hadoop.fs.s3a.path.style.access=सच्चा \
--conf spark.hadoop.fs.s3a.impl=org.apache.hadoop.fs.s3a.S3AFileSystem \
--conf स्पार्क.hadoop.fs.s3a.fast.upload=सच्चा \
--conf spark.hadoop.fs.s3a.aws.credentials.provider=org.apache.hadoop.fs.s3a.SimpleAWSCredentialsProvider \
./examples/jars/spark-examples_2.13-4.1.2.jar
./bin/spark-submit \
--गुरू k8s://http://localhost:9888 \
--deploy-mode क्लस्टर \
--कक्षा org.apache.spark.examples.SparkPi \
--conf spark.ilum.cluster=चूक \
--conf spark.app.name=my-sparkpi-job \
--conf स्पार्क.कुबेरनेट्स.कंटेनर.इमेज=ilum/spark:3.5.8 \
--conf spark.kubernetes.submission.waitAppCompletion=सच्चा \
--conf spark.kubernetes.file.upload.path=s3a://ilum-files/spark-jobs \
--conf स्पार्क.hadoop.fs.s3a.endpoint=http://localhost:9000 \
--conf spark.hadoop.fs.s3a.access.key=मिनीएडमिन \
--conf spark.hadoop.fs.s3a.secret.key=मिनीएडमिन \
--conf स्पार्क.hadoop.fs.s3a.path.style.access=सच्चा \
--conf spark.hadoop.fs.s3a.impl=org.apache.hadoop.fs.s3a.S3AFileSystem \
--conf स्पार्क.hadoop.fs.s3a.fast.upload=सच्चा \
--conf spark.hadoop.fs.s3a.aws.credentials.provider=org.apache.hadoop.fs.s3a.SimpleAWSCredentialsProvider \
./examples/jars/spark-examples_2.12-3.5.8.jar
पर्दे के पीछे क्या होता है?
- स्पार्क क्लाइंट आपके स्थानीय JAR को स्वचालित रूप से निर्दिष्ट MinIO बाल्टी (
इलम-फाइल्स/स्पार्क-जॉब्स). - कुबेरनेट्स ड्राइवर पॉड इलम-प्रबंधित कुबेरनेट्स क्लस्टर पर बनाया गया है।
- नौकरी निष्पादन की निगरानी सीधे इलम यूआई के माध्यम से की जाती है।
4. Monitor and Troubleshoot
Using the Ilum UI:
- नौकरी की प्रगति की निगरानी करें: Track executors, memory usage, and job stages.
- Review Results: Access logs and the integrated Spark History Server.
- Troubleshoot: Diagnose failures by checking detailed executor logs.
For more details on monitoring metrics, see the Monitoring Guide.
Comparison: Classic spark-submit vs Ilum Approach
Running Spark directly on Kubernetes requires significant administrative effort. Ilum simplifies this by automating infrastructure management.
Traditional Approach (Native Spark on K8s) vs Ilum
| लक्षण | Native Spark on K8s | Ilum (Managed Spark) |
|---|---|---|
| Setup | Manual Docker image build & complex स्पार्क-सबमिट args. | Automated. Use existing JARs; Ilum handles images. |
| कॉन्फिग | Verbose (Service Accounts, Volumes, Secrets). | Simplified. Minimal args; configs are injected automatically. |
| भंडार | Manual Hadoop/S3 configuration per job. | Integrated. Automatic credential injection for S3/GCS/Azure. |
| निगरानी | CLI-based (kubectl logs), ephemeral. | Centralized UI. Persistent logs, metrics, and history. |
| अवलोकन योग्यता | Basic Spark UI (if exposed). | अग्रवर्ती. डेटा वंश, detailed resource metrics. |
Key Benefits of Ilum:
- Automatic Image Selection: Ilum selects a compatible Spark Docker image matching the cluster version.
- Advanced Observability: Ilum provides deep lineage observability and advanced monitoring capabilities.
- Simplified Configuration: Reduce
स्पार्क-सबमिटparameters by 3x-4x. - Integrated Storage Access: Credentials for all configured storages are automatically injected.
- Instant Monitoring: Logs and metrics (CPU/RAM) appear in the Ilum UI immediately.
For a developer, this means less time fighting with infrastructure and error-prone configurations, and more time delivering business logic.
For advanced customization, refer to the official Spark documentation.