Run Spark Submit (spark-submit) on Kubernetes
تعمل وظيفة Spark البسيطة في Ilum تماما مثل تلك التي يتم تقديمها عبر المعيار شرارة تقديم ، ولكن مع تحسينات إضافية لسهولة الاستخدام والتكوين والتكامل مع الأدوات الخارجية.
يمكنك استخدام ملف JAR مع أمثلة Spark من تثبيت Spark المحلي أو أي JAR مخصص لديك.
يوجد أدناه دليل تفصيلي لإعداد وتشغيل وظيفة Spark بسيطة باستخدام شرارة تقديم 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 3.5.7 are installed, upload your JAR, and run:
./bin/spark-submit \
--master k8s://http<ilum-core-address>://:<ilum-core-port> \
--نشر نظام المجموعة \
--class org.apache.spark.examples.SparkPi \
--conf spark.driver.memory = 4g \
--conf spark.ilum.cluster=افتراضي \
--conf spark.kubernetes.container.image=ilum/spark:3.5.7 \
--conf spark.kubernetes.submission.waitAppCompletion=true \
s3a://ilum-files/spark-examples_2.12-3.5.7.jar
Note: Replace <ilum-core-address> with your actual Ilum Core endpoint.
Step-by-Step Guide
1. Prerequisites
- تأكد من تثبيت Java 17 وتعيينه بشكل صحيح في
JAVA_HOME. - التنزيل والاستخراج Apache Spark 3.5.7(أو نسخة مكافئة):
wget https://dlcdn.apache.org/spark/spark-3.5.7/spark-3.5.7-bin-hadoop3.tgz
tar -xzf spark-3.5.7-bin-hadoop3.tgz
cd spark-3.5.7-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 .
المنفذ إلى الأمام SVC / ILUM الأساسي 9888: 9888
إذا كنت تتواصل من داخل نفس مجموعة Kubernetes، فيمكنك استخدام عناوين الخدمة المستندة إلى Kubernetes DNS (على سبيل المثال، 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.
-
Locate the example JAR:
examples/jars/spark-examples_2.12-3.5.7.jar -
Upload it to MinIO (bucket
ملفات ILUM). Example path:s3a://ilum-files/spark-examples_2.12-3.5.7.jar2. Submit via REST
Limitationspark.ilum.pyالمتطلباتis not supported in this mode, as REST does not support PySpark submissions.Run the following command:
REST Submit./bin/spark-submit \
- سيد spark://localhost:9888 \
--نشر نظام المجموعة \
--class org.apache.spark.examples.SparkPi \
--conf spark.master.rest.enabled=true \
--conf spark.ilum.cluster=افتراضي \
--conf spark.app.name=my-spark-job \
s3a://ilum-files/spark-examples_2.12-3.5.7.jarParameters:
| 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
تشغيل Spark باستخدام بروتوكول إرسال تطبيق REST.
25/03/12 12:58:01 INFO RestSubmissionClient: تقديم طلب لإطلاق طلب في spark://localhost:9888.
25/03/12 12:58:03 INFO RestSubmissionClient: تم إنشاء الإرسال بنجاح ك 20250312-1158-qdnioef2rny. حالة تقديم الاقتراع ...
25/03/12 12:58:03 INFO RestSubmissionClient: تقديم طلب لحالة التقديم 20250312-1158-qdnioef2rny في spark://localhost:9888.
25/03/12 12:58:03 INFO RestSubmissionClient: تم الآن إرسال حالة برنامج التشغيل 20250312-1158-qdnioef2rny.
25/03/12 12:58:03 INFO RestSubmissionClient: يتم تشغيل برنامج التشغيل على عامل ILUM في ILUM_UI_ADDRESS/workloads/details/job/20250312-1158-qdnioef2rny.
25/03/12 12:58:03 INFO RestSubmissionClient: استجاب الخادم باستخدام CreateSubmissionResponse:
{
"action" : "CreateSubmissionResponse",
"serverSparkVersion" : "3.5.7",
"معرف التقديم": "20250312-1158-qdnioef2rny",
"النجاح" : صحيح
}
25/03/12 12:58:03 معلومات ShutdownHookManager: خطاف إيقاف التشغيل يسمى
25/03/12 12:58:03 معلومات إيقاف التشغيلHookManager: حذف الدليل /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 شرارة تقديم .
-
Locate the example JAR:
examples/jars/spark-examples_2.12-3.5.7.jar -
Upload it to MinIO (bucket
ملفات ILUM). Example path:s3a://ilum-files/spark-examples_2.12-3.5.7.jar2. Submit via Kubernetes Mode
Include Ilum-specific configurations for better management:
-
--conf spark.ilum.cluster=افتراضي -
--conf spark.app.name=my spark-job -
--conf spark.ilum.tags=تحليلات,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:
./bin/spark-submit \
--سيد K8S://http://localhost:9888 \
--نشر نظام المجموعة \
--class org.apache.spark.examples.SparkPi \
--conf spark.driver.memory = 4g \
--conf spark.ilum.cluster=افتراضي \
--conf spark.kubernetes.container.image=ilum/spark:3.5.7 \
--conf spark.kubernetes.submission.waitAppCompletion=true \
s3a://ilum-files/spark-examples_2.12-3.5.7.jar
Parameters:
| Parameter | وصف |
|---|---|
--أحسن | Address of your Kubernetes API (or Ilum Core for REST mode). |
--نشر وضع المجموعة | Submits the job to the Spark cluster. |
--فصل | Entry point class of your Spark application (use format اسم الملف.اسم الفئة ل Python). |
- 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 INFO SparkKubernetesClientFactory: التكوين التلقائي لعميل K8S باستخدام السياق الحالي من ملف تكوين K8S للمستخدمين
25/04/02 15:42:38 معلومات LoggingPodStatusWatcherImpl: تغيرت الحالة ، الحالة الجديدة:
اسم الجراب: 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
المجلدات: غير متاح
اسم العقدة: ILUM
وقت البدء: 2025-04-02T13:42:37.145Z
المرحلة: الجري
حالة الحاوية:
اسم الحاوية: سائق شرارة
container image: ilum/spark:3.5.7
حالة الحاوية: قيد التشغيل
بدأت الحاوية في: 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 INFO LoggingPodStatusWatcherImpl: حالة التطبيق ل spark-a4f8f1eb4ed344f38d799d79817c45dc (المرحلة: قيد التشغيل)
...
25/04/02 15:43:03 INFO LoggingPodStatusWatcherImpl: حالة التطبيق ل spark-a4f8f1eb4ed344f38d799d79817c45dc (المرحلة: قيد التشغيل)
25/04/02 15:43:03 معلومات LoggingPodStatusWatcherImpl: الحالات النهائية للحاوية:
اسم الحاوية: سائق شرارة
container image: ilum/spark:3.5.7
حالة الحاوية: قيد التشغيل
بدأت الحاوية في: 2025-04-02T13:42:37.145Z
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:
المنفذ الأمامي SVC / ILUM-MINIO 9000: 9000
2. Download S3 Dependencies
Download the required Hadoop/AWS JARs to your local الجرار folder:
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)
./bin/spark-submit \
--سيد K8S://http://localhost:9888 \
--نشر نظام المجموعة \
--class org.apache.spark.examples.SparkPi \
--conf spark.ilum.cluster=افتراضي \
--conf spark.app.name = my-sparkpi-job \
--conf spark.kubernetes.container.image=ilum/spark:3.5.7 \
--conf spark.kubernetes.submission.waitAppCompletion=true \
--conf spark.kubernetes.file.upload.path=s3a://ilum-files/spark-jobs \
--conf spark.hadoop.fs.s3a.endpoint=http://localhost:9000 \
--conf spark.hadoop.fs.s3a.access.key=minioadmin \
--conf spark.hadoop.fs.s3a.secret.key = minioadmin \
--conf spark.hadoop.fs.s3a.path.style.access=true \
--conf spark.hadoop.fs.s3a.impl=org.apache.hadoop.fs.s3a.S3AFileSystem \
--conf spark.hadoop.fs.s3a.fast.upload=true \
--conf spark.hadoop.fs.s3a.aws.credentials.provider=org.apache.hadoop.fs.s3a.SimpleAWSCredentialsProvider \
./examples/jars/spark-examples_2.12-3.5.7.jar
ماذا يحدث خلف الكواليس؟
- يقوم عميل Spark بتحميل JAR المحلي تلقائيا إلى حاوية MinIO المحددة (
ilum-files/spark-jobs). - يتم إنشاء جراب برنامج تشغيل Kubernetes على مجموعة Kubernetes المدارة من Ilum.
- تتم مراقبة تنفيذ المهمة مباشرة من خلال واجهة مستخدم Ilum.
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.