Configuring external IDE Spark Connect sessions
Learn about how to configure a Spark Connect Session with Cloudera Data Engineering.
Before you create a Spark Connect Session, perform the following steps:
- Deploy a Spark Compute instance through the Anywhere Cloud Marketplace.
- Have kubectl access to both the Anywhere Cloud Marketplace cluster and the Cloudera Data Engineering cluster, or ask your cluster administrator to retrieve the root CA certificates from the Kubernetes clusters using kubectl.
- Install Python on the local machine where you want to use Spark Connect.
-
Obtain or create the TLS CA certificate bundle based on your environment's
certificate configuration:
- Cloudera self-signed certificates:
- Set the
KUBECONFIGenvironment variable to the path of your cluster kubeconfig file before running kubectl commands. - Open a terminal on your device and run the following command on both
the Anywhere Cloud Marketplace cluster and the Cloudera Data Engineering workload cluster to extract the
CA
certificates:
kubectl get secret default-awc-tls -n istio-ingress -o jsonpath='{.data.ca\.crt}' | base64 -d - Copy the decoded certificate outputs from both Anywhere Cloud Marketplace cluster and the Cloudera Data Engineering workload cluster and paste them into a single PEM file (for example, ca-bundle.pem).
- If you do not have
kubectlaccess to these clusters, ask your cluster administrator to generate and provide this combined PEM file.
- Set the
- Custom Certificate Authority (CA):
- Request a single PEM file containing the full certificate chain
(
rootand intermediate CAs) from your cluster administrator. - Skip this step if your organization's IT team already distributes these certificates to your local trust store.
- Request a single PEM file containing the full certificate chain
(
- Cloudera self-signed certificates:
- Create API access keys in the Anywhere Cloud Console UI.
-
Save the generated client ID and client secret to your local credentials
file.
Sample credential file:
[default] awc_client_id = [***CLIENT_ID_COPIED_IN_THE_PRECEEDING_STEP***] awc_client_secret = [***CLIENT_SECRET_COPIED_IN_THE_PRECEEDING_STEP***] -
Create the Cloudera Data Engineering client configuration file and
point it to your certificate bundle, credentials file, and endpoints:
tls-ca-certscredentials-filede-endpointawc-endpoint
-
Save the configuration file. On Unix-like systems, save it to
~/.cde/config.yaml.
Sample configuration file:
tls-ca-certs: /Users/username/Downloads/cacert_grpc.pem credentials-file: /Users/username/.cde/credentials de-endpoint: https://cde-jobs-c007-cde-nov19-1-e78e1a.cde-nov19-1.awcqe2.sandbox21.cloudera.com awc-endpoint: https://console.27268-engds2integra.awcqe2.sandbox21.cloudera.com -
Download the
cdeconnectclient tarball and the PySpark tarball from the Job Management UI:- Access Anywhere Cloud Console.
- Sign in using your enterprise identity provider.
-
Click
Apps in the left navigation pane on the Anywhere Cloud Console. The list of deployed engines and the associated blueprints is displayed.
- In the Engines tab, search for the required Cloudera Data Engineering instance and click on the instance name. A details pane is displayed.
- Click on the Cloudera Data Engineering URL available in the URL column. The Cloudera Data Engineering console home page is displayed.
- In the left navigation pane, click Sessions.
- Click on the Spark Connect session you want to connect to.
- Click on the Connect tab.
- Click on the CDE Tarball and PySpark tarball links to download them.
-
Create and activate a virtual environment, then install the downloaded
packages:
python -m venv spark-connect-venv . spark-connect-venv/bin/activate pip install <path to cde connect tarball you downloded in previous step> pip install <path to pyspark tarball you downloded in previous step> Your virtual env is ready to use now. You can run the python script mentioned in next step to check for connectivity. -
Run the following PySpark script to verify local connectivity to the Spark
Connect session:
SESSION_NAME = "[***SESSION_NAME***]" from cde import CDESparkConnectSession # Initialize the Spark Connect Session spark = CDESparkConnectSession.builder.sessionName(SESSION_NAME).get() import pyspark.errors.utils as _pyspark_error_utils _pyspark_error_utils._enable_debugging_cache = False # Single partition, one row — minimal driver↔executor work for a sanity check. n = spark.range(1).count() # Validate the output print(f"spark.version={spark.version}") print(f"range(1).count()={n}")
