Skip to main content
Version 3.0

Spark, Trino, and the lakehouse
straight from notebooks.

Four scenarios: what the notebook image already ships, the connection to a Spark cluster, queries to Trino, and reading and writing lakehouse tables. Each one covers: the chart default, the block commented line by line when there is configuration, and the verification.

ChartVersion3.0.3TypeapplicationAppVersion5.3.0
CompatibilityKubernetes1.32+OpenShift4.19+Rancher2.10.x+

Notebooks communicate with the rest of the platform through kernel libraries and the Spark configuration mounted in each server by the tdp-jupyter chart. The kernel already includes PySpark and clients for Trino, S3, Iceberg, Delta Lake, Kafka and other databases. The tdpSparkIntegration block connects notebooks to a Spark cluster. The Hub's own database is covered in JupyterLab Configuration.

Your environment

If you fill in your environment details here, the examples and commands on the page use what you provided. The namespace, the release name and the values file are your choices, not the chart's.

Scenarios​

What the image includes: kernel libraries, the Spark distribution and network access allowed for servers.

JupyterHub connects to the rest of the platform through what ships in the notebook image: the kernel libraries and the Spark distribution. By default, nothing needs to be configured: Spark runs in local mode, inside the user server, and server network egress already allows the components used by these libraries. The following tabs cover the Spark cluster, Trino queries and the lakehouse (Iceberg and Delta Lake on S3 storage).

Before connecting any integration, you want to know what notebooks can already do without configuration. Each user server runs the TDP notebook image, with an isolated Python kernel that includes data libraries and platform component clients, and the Spark distribution from the TDP Spark image.

Spark

pyspark and pyarrow in the kernel. The Spark distribution in SPARK_HOME, copied from the TDP Spark image, at the same Spark version as the tdp-spark chart of the same TDP release. By default, Spark runs in local mode (local[*]).

Lakehouse and S3

delta-spark, pyiceberg (with PyArrow, Hive and S3 support) and boto3.

SQL

trino, sqlalchemy-trino, jupysql, sqlalchemy and duckdb.

Databases and messaging

clickhouse-driver, clickhouse-connect, psycopg2-binary, mysql-connector-python, pymongo, pyodbc, oracledb and confluent-kafka.

Analysis and quality

pandas, polars, matplotlib, seaborn, tabulate and great_expectations.

Network

The servers' NetworkPolicy allows egress to DNS, cluster pods, external addresses and Spark, Trino, Hive Metastore, Kafka and Ozone services. See Security - JupyterLab for details.

The user server and the Spark configuration

namespace <NAMESPACE>startsHubstarts serversUser server ×3Python kernel · PySparkConfigMap<RELEASE_NAME>-spark-integration
  1. Hub. Starts each user's server with the notebook image, Spark configuration and environment variables from the values file.
  2. User server. The Python kernel includes PySpark, delta-spark, pyiceberg, boto3, Trino, Kafka and ClickHouse clients, and clients for other databases. The Spark distribution comes from the TDP Spark image. Chart default: Local Spark (local[*]). (tdp-jupyter.singleuser.extraEnv.SPARK_MASTER_URL)
  3. Spark Configuration. Generated by the chart with spark-defaults.conf and an environment script, mounted in each server at /opt/bitnami/spark/conf. Chart default: spark.master local[*]. (tdpSparkIntegration.configMap)
The user server, with the kernel and Spark configuration mounted by the chart. Click an element to see the default.

Any other integration using one of these libraries works the same way: the notebook imports the library and connects to the service through its cluster address.

Names outside DNS

When a service used by notebooks has a name that cluster DNS cannot resolve, user servers can receive custom /etc/hosts entries:

Click the markers to understand each line.

1tdp-jupyter:
2singleuser:
3 extraPodConfig:
4 hostAliases:
5 - ip: "<IP_ADDRESS>"
6 hostnames:
7 - "<COMPONENT_HOSTNAME>"

Fields added to the pod definition of each user server.

  1. Extra pod configuration (linha 3). Fields added to the pod definition of each user server.
  2. IP (linha 5). The address to which the names below point.
  3. Names (linha 7). Names that resolve to this IP address inside servers.
Host aliases

When something goes wrong​

Troubleshooting

Paste the error message or choose a symptom. The answer includes the cause, what to do and the command.

  1. Connecting to /<pod-ip>:2222 timed out. Cause: The servers' NetworkPolicy blocks ingress from Spark workers, which need to connect back to the driver. What to do: Add the worker ingress rule to the servers' networkPolicy (scenario 2) and upgrade the release.
  2. java.net.UnknownHostException with the pod name. Cause: spark.driver.host resolves to the pod name rather than its IP address. What to do: Leave spark.driver.host empty in sparkConfig and inject SPARK_DRIVER_HOST through the Downward API, with fieldPath: status.podIP (scenario 2).
  3. Connection to the Spark cluster fails. Cause: A NetworkPolicy blocks traffic, or the Spark cluster is not reachable from the notebooks namespace. What to do: Check NetworkPolicies and whether the Spark cluster is reachable. The configuration generated by the chart shows the master used by servers.
  4. BindException on the Spark Connect port. Cause: Several notebooks run at the same time and Spark's default ports are already in use. What to do: Set SPARK_CONNECT_PORT to "0" in singleuser.extraEnv, as in the scenario 2 example: Spark Connect then uses any available port.
  5. CANNOT_MODIFY_CONFIG warnings. Cause: spark.driver.host or JARs were passed through SparkSession.builder.config(). What to do: Pass spark.driver.host and JARs through PYSPARK_SUBMIT_ARGS, before importing PySpark.
  6. Spark configuration changes do not appear in the notebook. Cause: The user server reads Spark configuration and environment variables only when it starts. What to do: After helm upgrade, each user stops and restarts their server: File, Hub Control Panel, Stop My Server, then Start My Server.
  7. The notebook job does not appear in History Server. Cause: The driver, running in the user server, does not write event logs to the directory read by History Server. What to do: Add spark.eventLog.enabled and spark.eventLog.dir to tdpSparkIntegration.configMap.sparkConfig (scenario 2).
  8. S3 access denied with Ozone security enabled. Cause: With Ozone security enabled, Spark drivers running outside Spark pods need the keys from the ozone-s3-credentials Secret. What to do: Provide the user server with AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY from the ozone-s3-credentials Secret (scenario 4).
  9. Other problem. Cause: Start with server pods and the Spark variables they receive. What to do: Server pods are named <RELEASE_NAME>-notebook-<user>. SPARK_ variables show what the server received.

Integration parameters​

The chart prefix is already filled in. Keys without a prefix belong at the root of the values file.

18 of 18 parameters

ParameterDescriptionChart default
tdpSparkIntegration.enabledIntegrationPoints servers' Spark configuration to a Spark clusterfalse
tdpSparkIntegration.configMap.nameIntegrationSpark configuration ConfigMap name. When empty, <RELEASE_NAME>-spark-integration""
tdpSparkIntegration.configMap.sparkConfig."spark.master"IntegrationMaster address. When empty, local[*] with integration disabled and, with it enabled, this chart release's master: set it when enabling a cluster""
tdpSparkIntegration.configMap.sparkConfig."spark.driver.host"IntegrationDriver address. When empty, PySpark uses the pod IP from SPARK_DRIVER_HOST""
tdpSparkIntegration.configMap.sparkConfig."spark.driver.port"IntegrationDriver port2222
tdpSparkIntegration.configMap.sparkConfig."spark.blockManager.port"IntegrationBlock manager port7777
tdpSparkIntegration.configMap.sparkConfig."spark.executor.instances"IntegrationExecutors per session3
tdpSparkIntegration.configMap.sparkConfig."spark.executor.memory"IntegrationMemory per executor2g
tdpSparkIntegration.configMap.sparkConfig."spark.executor.cores"IntegrationCores per executor2
tdp-jupyter.singleuser.extraEnv.SPARK_MASTER_URLEnvironmentMaster address read by notebookslocal[*]
tdp-jupyter.singleuser.extraEnv.SPARK_DRIVER_PORTEnvironmentDriver port2222
tdp-jupyter.singleuser.extraEnv.SPARK_BLOCKMANAGER_PORTEnvironmentBlock manager port7777
tdp-jupyter.singleuser.extraEnv.SPARK_DRIVER_MEMORYEnvironmentDriver memory4g
tdp-jupyter.singleuser.extraEnv.SPARK_EXECUTOR_MEMORYEnvironmentExecutor memory4g
tdp-jupyter.singleuser.extraEnv.SPARK_HOMEEnvironmentSpark distribution in the image/opt/bitnami/spark
tdp-jupyter.singleuser.networkPolicy.ingressNetworkServer ingress rules. With a Spark cluster, allows workers to reach the drivernot set
tdp-jupyter.singleuser.networkPolicy.egressNetworkServer egress rules. Setting the list in your file replaces the entire listDNS, cluster pods, external addresses and TDP component services
tdp-jupyter.singleuser.extraPodConfig.hostAliasesNetwork/etc/hosts entries in user serversnot set

Next steps​