ইলামে অ্যাপাচি স্পার্ক কানেক্ট: কনফিগারেশন এবং সংযোগ গাইড
স্পার্ক কানেক্ট কী?
স্পার্ক কানেক্ট জন্য একটি আধুনিক ক্লায়েন্ট-সার্ভার ইন্টারফেস অ্যাপাচি স্পার্ক that enables remote execution of Spark workloads from lightweight clients such as Python, Java, Scala, R, and SQL-based tools. Introduced in Spark 3.4, Spark Connect decouples the Spark client from the Spark runtime, allowing developers to ইন্টারেক্টিভ ডেটা অ্যাপ্লিকেশন তৈরি করুন , নোটবুক এবং ড্যাশবোর্ডগুলি স্থানীয়ভাবে পুরো স্পার্ক ইঞ্জিন স্থাপন না করে।
স্পার্ক কানেক্ট লিভারেজ জিআরপিসি-ভিত্তিক যোগাযোগ একটি দূরবর্তী স্পার্ক সার্ভারের সাথে ইন্টারঅ্যাক্ট করতে, ডেটা ইঞ্জিনিয়ারিং, ডেটা সায়েন্স এবং বিশ্লেষণ কর্মপ্রবাহের জন্য নমনীয়তা, উন্নত সুরক্ষা এবং সরলীকৃত অবকাঠামো সরবরাহ করে।
এটা very similar to Ilum’s approach to Spark microservices, যেখানে স্পার্ক উপাদানগুলি ধারক করা হয় এবং গতিশীল পরিষেবা হিসাবে উন্মুক্ত হয়। ব্যবহৃত নকশা কুবারনেটসে পাইস্পার্ক মাইক্রোসার্ভিস মোতায়েন করা হচ্ছে : উভয়ই ক্লায়েন্ট সাইডে সম্পূর্ণ ক্লাস্টার সেটআপ ছাড়াই স্পার্কে স্কেলেবল, স্টেটলেস এবং সুরক্ষিত অ্যাক্সেস সক্ষম করে।
Why use Spark Connect on Kubernetes?
Traditional Spark submission often requires complex local setups (Java, Hadoop binaries, exact Spark versions). Spark Connect eliminates this "dependency hell."
| বৈশিষ্ট্য | Traditional Spark Submission (স্পার্ক-সাবমিট ) | স্পার্ক কানেক্ট |
|---|---|---|
| স্থাপত্য | Monolithic (Driver runs on client or cluster edge) | Decoupled (Client is separate from Server) |
| Client Requirements | Heavy (Requires Java, Spark binaries, Hadoop configs) | Lightweight (Only Python/Go/Scala library required) |
| Network Protocol | Custom RPC (Sensitive to version mismatch) | gRPC (Standard, version-agnostic, firewall-friendly) |
| Iteration Speed | Slow (Build & Deploy jars) | Fast (Interactive, REPL-style development) |
| Language Support | limited to JVM/Python | Polyglot (Python, Scala, Go, Rust, etc.) |
For a deeper dive into how Ilum leverages this for multi-tenancy, see our Architecture Documentation.
ইলুমে, স্পার্ক কানেক্ট আমাদের মাইক্রোসার্ভিস-ভিত্তিক স্পার্ক আর্কিটেকচারের সাথে প্রাকৃতিকভাবে সারিবদ্ধ হয়। আপনি একটি স্ট্যান্ডার্ড কাজ হিসাবে একটি স্পার্ক কানেক্ট সার্ভার স্থাপন করতে পারেন এবং পডের নাম, পড আইপি বা কুবারনেটসের মাধ্যমে প্রকাশিত কোনও পরিষেবা ব্যবহার করে বিভিন্ন সংযোগ পদ্ধতির মাধ্যমে এটি অ্যাক্সেস করতে পারেন।
Prepare Your Client Environment
Before connecting, you need a lightweight client library. Unlike traditional Spark, you do not need a local JVM or Hadoop installation.
Python (PySpark)
- Spark 4 (default)
- Spark 3
pip install pyspark[connect]==4.0.1 grpcio-status
pip install pyspark[connect]==3.5.7 grpcio-status
Scala (sbt)
For Scala applications, add the Spark Connect client dependency:
- Spark 4 (default)
- Spark 3
libraryDependencies += "org.apache.spark" % % "spark-connect-client-jvm" % "4.0.1"
libraryDependencies += "org.apache.spark" % % "spark-connect-client-jvm" % "3.5.7"
Spark SQL CLI
You can also use the generic Spark SQL CLI to connect remotely:
/path/to/spark/bin/spark-sql --remote "sc://<ilum-cluster-address>:15002"
নোট : Always match your client library version (e.g.,
4.0.1; fallback3.5.7) with the Spark version running on your Ilum cluster.
Ilum UI এর মাধ্যমে অ্যাপাচি স্পার্ক কানেক্ট ইনস্ট্যান্স তৈরি করা হচ্ছে
ওয়েব ইউআই ব্যবহার করে আপনার ইলাম ক্লাস্টারে চাকরি হিসাবে স্পার্ক কানেক্ট সার্ভার চালু করতে এই পদক্ষেপগুলি অনুসরণ করুন:
-
Start a New Spark Job: Log in to the Ilum UI and navigate to the Jobs section. Click on নতুন চাকরি একটি নতুন স্পার্ক কাজ তৈরি করতে।
-
Job Name: Enter a recognizable name for the job (e.g.,
স্পার্ক কানেক্ট সার্ভার) ইউআইতে পরে এটি সনাক্ত করতে। -
Main Class: Set the job's main class to:
org.apache.spark.sql.connect.service.SparkConnectServerThis is the built-in Spark class that starts the Spark Connect server process, enabling remote connectivity to Spark clusters.
-
Spark Configuration: Go to the Configuration tab/section for the job. Add the following Spark property to ensure the Spark Connect server code is available:
- Spark 4 (default)
- Spark 3
Key: স্পার্ক.জারস.প্যাকেজস
মান : org.apache.spark:spark-connect_2.13:4.0.1
Key: স্পার্ক.জারস.প্যাকেজস
মান : org.apache.spark:spark-connect_2.12:3.5.7
This configuration instructs Spark to fetch the Spark Connect library from Maven when the job starts.
-
(Optional) Label the Pod: If you plan to expose this Spark Connect server via a Kubernetes Service, add a label to the Spark driver pod:
- Key:
spark.kubernetes.driver.label.type - মান :
স্পার্ককানেক্ট
This will tag the Spark Connect server's pod with a label
প্রকার=স্পার্ককানেক্টfor easy service selection. - Key:
-
Submit the Job: Click জমা . ইলাম স্পার্কের কাজটি ক্লাস্টারে মোতায়েন করবে। অল্প সময় পর রানিং জব লিস্টে দেখতে হবে কাজটি।
-
Verify the Server is Running: Wait for the job status to become "Running". You can check the job's logs for a message indicating Spark Connect has started (e.g., a log line mentioning port 15002). Once running, the Spark Connect server is listening for client connections on the default port 15002 .


If your job fails immediately, ensure you added স্পার্ক.জারস.প্যাকেজস with the correct version.
স্পার্ক কানেক্ট সার্ভারের সাথে সংযোগ করা হচ্ছে
একবার স্পার্ক কানেক্ট সার্ভারটি চালু হলে, আপনি স্পার্ক কানেক্ট URL ব্যবহার করে কোনও স্পার্ক ক্লায়েন্ট (যেমন, PySpark, Spark শেল, sparklyr, ইত্যাদি) থেকে এটির সাথে সংযোগ করতে পারেন ( sc://... ). আপনার নেটওয়ার্ক সেটআপের উপর নির্ভর করে নীচে বিভিন্ন সংযোগ পদ্ধতি রয়েছে:
- পদ্ধতি 1: পড নাম (ক্লাস্টার ডিএনএস) দ্বারা সংযোগ করুন
- পদ্ধতি 2: পড আইপি দ্বারা সংযোগ করুন
- Method 3: Port Forwarding with kubectl
- পদ্ধতি 4: স্পার্ক সংযোগের জন্য একটি পরিষেবা প্রকাশ করা
If your environment allows DNS resolution of pod names (for example, your client is within the cluster or can resolve the cluster's internal DNS), you can connect using the pod's DNS name. Kubernetes assigns each pod a DNS name of the form <pod-name>। <namespace>.pod.cluster.local ( Kubernetes DNS ). This DNS name resolves to the pod's IP address inside the cluster.
পদক্ষেপ:
- Find the Pod Name: In the Ilum UI, locate the Spark Connect job you started. Note the driver pod name (Ilum may show it in the job details or logs). It will be something like
চাকরি-xxxxxx-ড্রাইভার(সঠিক বিন্যাস পৃথক হতে পারে)। - Construct the URL: Use the pod's fully qualified DNS name. For example, if the pod name is
চাকরি-abc123-ড্রাইভারএতেডিফল্টনামস্থান, ঠিকানা হবে:sc://job-abc123-driver.default.pod.cluster.local:15002 - Connect via Spark Client: Use this URL in your SparkSession builder or Spark shell. For example, in PySpark you can do:
notebook.ipynb
থেকে পাইস্পার্ক . এসকিউএল আমদানি স্পার্কসেশন
স্ফুলিঙ্গ = স্পার্কসেশন . builder. দূরবর্তী (
"sc://job-abc123-driver.default.pod.cluster.local:15002"
) . getOrCreate ( )
This will create a Spark session that connects remotely to the Spark Connect server at the given DNS address. Ensure that your environment's DNS can resolve .pod.cluster.local ঠিকানা (সাধারণত কেবল তখনই সত্য যদি ক্লাস্টারের মধ্যে বা ভিপিএন এর মাধ্যমে ক্লাস্টার নেটওয়ার্কে চলমান থাকে)।

নোট : This is crucial for managing your Apache Spark applications. If your client is running inside the same namespace in the cluster, you might not need the full domain. For instance, just sc://job-abc123-driver:15002 could work due to Kubernetes' DNS search path. However, using the full পড.ক্লাস্টার.লোকাল নেমস্পেস সহ ঠিকানা সবচেয়ে স্পষ্ট এবং নির্ভরযোগ্য পদ্ধতি।
If DNS resolution is not available, you can use the pod's IP address directly in the Spark Connect URL. This requires that your client environment can reach the pod IP (e.g., if you are on the same network or have appropriate routing to the cluster's pod network).
পদক্ষেপ:
- Get the Pod IP: Find the IP address of the Spark Connect pod. In Ilum UI, check the job details for an IP, or use the CLI:
কুবেক্টল গেট পড <pod-name> -ও ওয়াইডto see the pod's IP. - Construct the URL: Use the IP in place of the host. For example, if the pod IP is
10.42.1.25, ইউআরএল হবে:sc://10.42.1.25:15002 - Connect via Spark Client: Use the IP-based URL in your Spark client. For example:
connect_by_ip.py
স্ফুলিঙ্গ = স্পার্কসেশন . builder. দূরবর্তী ( "sc://10.42.1.25:15002") . getOrCreate ( )
এটি সেই আইপিতে পোর্ট 15002 এর সাথে সংযোগ স্থাপনের চেষ্টা করবে।

আপনার মেশিনটি আসলে স্পার্ক সার্ভারের সেই আইপি ঠিকানায় পৌঁছাতে পারে তা নিশ্চিত করুন।
- যদি আপনার ক্লায়েন্ট হয় ক্লাস্টারের ভিতরে (বা একই ভিপিসি / নেটওয়ার্কে), পড আইপি পৌঁছানো উচিত।
- যদি আপনার ক্লায়েন্ট হয় ক্লাস্টারের বাইরে (e.g., your local laptop), the pod IP is likely not directly routable. In that case, this method will time out or refuse connection. You'd then need to use Method 3 or 4 instead.
If you are connecting from outside the cluster (for example, from your local development environment) and cannot reach the pod IP or DNS directly, a convenient approach is to use Kubernetes port forwarding. Port forwarding opens a tunnel from your local machine to the remote pod's port.
পদক্ষেপ:
- Run Port-Forward: Open a terminal on your machine that has access to the Kubernetes cluster (where
কুবেক্টলকনফিগার করা হয়)। চালনা:প্রতিস্থাপনPort Forwardকুবেক্টল পোর্ট-ফরোয়ার্ড <pod-name> 15002: 15002<pod-name>with the Spark Connect pod's name (e.g.,চাকরি-abc123-ড্রাইভার). This command will bind your local port 15002 to the pod's port 15002. You should see output like127.0.0.1:15002 -> 15002 থেকে ফরোয়ার্ডিং. আপনার স্পার্ক সার্ভারের সাথে সংযোগের প্রয়োজন হওয়ার সময় এই প্রক্রিয়াটি চলমান রাখুন।

-
Connect to Localhost: With the port-forward in place, your local machine is now listening on port 15002. In your Spark client, connect to
লোকালহোস্ট:15002স্পার্ক কানেক্ট ইউআরএল ব্যবহার করে:local_script.pyস্ফুলিঙ্গ = স্পার্কসেশন . builder. দূরবর্তী ( "sc://localhost:15002") . getOrCreate ( )স্পার্ক কানেক্ট ডিফল্টরূপে 15002 পোর্ট ব্যবহার করে ( Quickstart: Spark Connect — PySpark 3.5 documentation), তাই এটি দূরবর্তী সংযোগকে ক্লাস্টারগুলিকে স্পার্ক করার অনুমতি দেয়।
sc://localhost:15002সুড়ঙ্গ দিয়ে ক্লাস্টারে পৌঁছে যাবে। এখন আপনার স্পার্ক সেশনটি দূরবর্তীভাবে ক্লাস্টার স্পার্ক উদাহরণের সাথে সংযুক্ত। -
Use Spark as Usual: Once connected, you can use the
স্ফুলিঙ্গsession as if it were local—all DataFrame operations will execute on the cluster.
এই পদ্ধতিটি প্রায়শই বিকাশের জন্য সবচেয়ে সহজ। আপনার কাজ শেষ হয়ে গেলে, আপনি টিপে পোর্ট-ফরওয়ার্ডিং বন্ধ করতে পারেন Ctrl+C চলমান টার্মিনালে Kubectl পোর্ট-ফরোয়ার্ড আদেশ।
আরও স্থায়ী সমাধানের জন্য বা একাধিক ব্যবহারকারী / ক্লায়েন্টকে সহজেই সংযোগ করার অনুমতি দেওয়ার জন্য, আপনি কুবারনেটস পরিষেবার মাধ্যমে স্পার্ক কানেক্ট সার্ভারটি প্রকাশ করতে পারেন। একটি পরিষেবা স্পার্ক কানেক্ট পডের জন্য একটি স্থিতিশীল নেটওয়ার্ক এন্ডপয়েন্ট (ডিএনএস নাম এবং আইপি) দেয় এবং ঐচ্ছিকভাবে এটি ক্লাস্টারের বাইরে প্রকাশ করতে পারে (যেমন, একটি লোডব্যালেন্সার বা নোডপোর্টের মাধ্যমে)।
পরিষেবার মাধ্যমে প্রকাশ করার পদক্ষেপগুলি:
-
Ensure Pod Label: If you haven't already labeled the Spark Connect pod (as suggested in step 5 of the setup above), do so now. You can add a label on the fly with kubectl:
Kubectl লেবেল পড <pod-name> টাইপ = স্পার্ককানেক্ট(যদি পডটি ইতিমধ্যে স্পার্ক কনফিগের মাধ্যমে লেবেলযুক্ত থাকে তবে এই পদক্ষেপের প্রয়োজন নেই))
-
Create a Service: Define a Kubernetes Service YAML that targets this pod by its label.
spark-connect-service.yamlapiVersion : v1
প্রকার : সেবা
মেটাডেটা :
নাম : স্ফুলিঙ্গ - connect- সেবা
নামস্থান : ইলুম # use the namespace where your Spark Connect pod is running
স্পেসিফিকেশন :
নির্বাচক :
টাইপ : স্পার্ককানেক্ট # this label should match the pod's label
পোর্ট :
- নাম : স্পার্ককানেক্ট
প্রোটোকল : টিসিপি
পোর্ট : 15002 # service port (clients will use this)
টার্গেট পোর্ট : 15002 # target port on the pod
নোডপোর্ট : 30002 # node port (external users will use this nodeip:30002)
টাইপ : নোডপোর্ট # ClusterIP is only accessible within the cluster
# বাহ্যিক অ্যাক্সেসের জন্য, আপনি এখানে টাইপ: নোডপোর্ট বা লোডব্যালেন্সার ব্যবহার করতে পারেন।kubectl apply -f spark-connect-service.yamlএই পরিষেবাটি যে কোনও পডে ট্র্যাফিক রুট করবে
প্রকার: স্পার্ককানেক্টlabel on port 15002. You can verify withকুবেক্টল এসভিসি স্পার্ক-কানেক্ট-সার্ভিস পান.
-
Inside Cluster or VPN: Use the service's DNS name or cluster IP. For example, within the cluster (or on a VPN that can resolve cluster DNS), the URL would be:
sc://spark-connect-service.default.svc.cluster.local:15002বাsc://spark-connect-service:15002এই ঠিকানার সমস্ত ট্র্যাফিক স্পার্ক কানেক্ট পডে অগ্রবর্তী করা হবে। -
Outside Cluster (if exposed): If you set the Service type to NodePort or LoadBalancer, use the external address. For NodePort, that might be
sc://<node-ip>:30002. লোডব্যালেন্সারের জন্য, এটি হতে পারেsc://<load-balancer-host>:15002আপনার ক্লাউড সরবরাহকারী কীভাবে এটি বরাদ্দ করে তার উপর নির্ভর করে। (এগুলি উন্নত পরিস্থিতি; প্রায়শই পোর্ট-ফরওয়ার্ডিং বাহ্যিক অ্যাক্সেসের জন্য সহজ))

Using a Service has the benefit of a stable name – you don't need to know the exact pod name or IP after it's set up. It also allows you to change the backing pod (e.g., restart the Spark Connect job) without changing how clients connect (as long as the new pod has the same label).
If your Service selector matches multiple Spark Connect pods, client requests can be routed inconsistently. A Kubernetes Service will load-balance connections among all matching pods. This means if you accidentally run two Spark Connect jobs with the label প্রকার=স্পার্ককানেক্ট , a client might connect to either one (potentially different sessions each time). To avoid issues, ensure only one Spark Connect pod is behind a given Service, or use unique labels (and Service names) per instance. In cases where you need to scale Spark Connect horizontally, be aware that each client session is bound to a single server; multiple servers won't share session state.
পরিষ্কারের কাজ
আপনার স্পার্ক কানেক্ট সেশন (গুলি) শেষ করার পরে, সংস্থানগুলি মুক্ত করতে এবং অনাথ সংযোগগুলি এড়াতে নিম্নলিখিত ক্লিনআপ পদক্ষেপগুলি সম্পাদন করুন:
-
Stop the Spark Connect Job: In the Ilum UI, navigate to the running Spark Connect job and click থামান বা বন্ধ . This will shut down the Spark Connect server process on the cluster. Confirm that the job's status changes to stopped/finished. (If you forget this step, the Spark Connect server will keep running and occupying cluster resources, impacting your spark application performance.)
-
Terminate Port-Forward Sessions: If you used
Kubectl পোর্ট-ফরোয়ার্ড, go to the terminal where it's running and pressCtrl+Cপোর্ট-ফরওয়ার্ডিং শেষ করতে। এটি টানেলটি বন্ধ করে দেয় এবং আপনার স্থানীয় বন্দরটি মুক্ত করে। আপনি যদি পটভূমিতে পোর্ট-ফরোয়ার্ড চালান তবে সেই প্রক্রিয়াটি হত্যা করতে ভুলবেন না। -
Delete Kubernetes Service (if created): If you exposed a Service for Spark Connect, remove it when it's no longer needed. You can delete it with:
Kubectl মুছে ফেলুন পরিষেবা স্পার্ক-কানেক্ট-সার্ভিস -এন ডিফল্টপ্রতিস্থাপন
স্পার্ক-কানেক্ট-সার্ভিসand namespace as appropriate. This ensures you don't leave an open network endpoint in the cluster. (If you set up a LoadBalancer, deleting the Service will also release the external IP/port. If you used a NodePort, it frees that port on the nodes for other uses.)
পরিষ্কার করে, আপনি নিশ্চিত করেন যে আপনার স্পার্ক কানেক্ট ব্যবহারের সাথে সম্পর্কিত কোনও বিপথগামী প্রক্রিয়া বা পোর্টগুলি খোলা নেই, আপনার স্পার্ক ক্লাস্টারে সংস্থানগুলি অপ্টিমাইজ করে।
Troubleshooting Spark Connect Issues
Here are solutions to the most common errors when connecting to Spark on Kubernetes.
How to fix "Connection Refused" on port 15002?
If your client fails with ConnectionRefusedErrorবা UNAVAILABLE:
Cause: The client cannot reach the Spark Driver pod. This is usually a networking issue, not a Spark issue.
সমাধান :
- Check Job Status: Is the job actually
RUNNINGএতে Ilum UI ? - Check Network Access:
- If you are outside the cluster (e.g., local laptop), you cannot use the Pod IP directly. You must use
Kubectl পোর্ট-ফরোয়ার্ড(Method 3) or a NodePort/LoadBalancer Service (Method 4).
- If you are outside the cluster (e.g., local laptop), you cannot use the Pod IP directly. You must use
- Verify Port: Ensure you are connecting to
15002(Spark Connect), not4040(Spark UI). - Test Connection: Run
nc -vz localhost 15002(if using port-forward).
How to resolve "Name or service not known" (DNS Error)?
Cause: Your local machine doesn't know how to resolve Kubernetes internal DNS names like job-xyz.default.pod.cluster.local.
সমাধান :
- Option A:ব্যবহার
Kubectl পোর্ট-ফরোয়ার্ডand connect tosc://localhost:15002. - Option B: Connect using the Pod IP directly (only works if you are on the same VPN/VPC).
- Option C: Configure your local
/etc/hoststo point the DNS name to 127.0.0.1 (combined with port forwarding).
How to fix "Pod not found" during port-forwarding?
Cause: Spark Driver pods are ephemeral. If you restart the job, the pod name changes (e.g., from job-abc-driverকরতে job-xyz-driver).
সমাধান :
- Always check the current driver pod name in the Ilum UI or via
kubectl get pods -l spark-role=driver. - একটি ব্যবহার করুন সেবা (Method 4) to get a stable hostname that doesn't change between restarts.
Error: "Client version mismatch" or "Unsupported Protocol"
Cause: You are trying to connect a Spark 3.4 client to a Spark 3.5 server (or vice versa).
সমাধান : Check your client version:
pip show pyspark
It must match the Ilum cluster version (e.g., both must be 3.5.x).
Error: "ModuleNotFoundError: No module named 'grpc'"
Cause: The grpcio-status library is missing. It is a required optional dependency for Spark Connect.
সমাধান :
pip install grpcio-status
এই গাইডটি অনুসরণ করে, আপনার সক্ষম হওয়া উচিত ইলামে একটি স্পার্ক কানেক্ট সার্ভার কনফিগার করুন এবং বিভিন্ন পদ্ধতির মাধ্যমে এটির সাথে সংযোগ স্থাপন করুন। ইলাম ইউআই স্পার্ক কানেক্ট উদাহরণটি স্থাপন করা সহজ করে তোলে এবং উপরের কৌশলগুলির সাহায্যে আপনি কুবারনেটস ক্লাস্টারের ভিতরে বা দূরবর্তীভাবে কাজ করছেন কিনা তা আপনি এটি অ্যাক্সেস করতে পারেন। হ্যাপি কানেক্টিং!