Spark reading and writing
in the platform's lakehouse.
Five scenarios: the two files that connect Spark to the rest of the platform, the connection to S3 storage, the registration of Iceberg and Delta Lake tables in the Hive Metastore, and the Jupyter and Airflow side. Each one covers: the values file block commented line by line and a step-by-step with verification.
The chart tdp-spark connects Spark to S3-compatible storage through S3A, in tdp-spark.hadoopConfig, and to Iceberg and Delta Lake tables registered in Hive Metastore, with jars already in the image. For installation, workers and History Server, see Spark 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
- 1 · How it connects
- 2 · S3 storage
- 3 · Iceberg and Delta Lake
- 4 · Jupyter
- 5 · Airflow
The two files generated by the chart and what is already included in the image.
Spark connects to other components through two configuration files that the chart generates and mounts on the master and workers: core-site.xml and spark-defaults.conf. core-site.xml, generated from hadoopConfig, contains Hadoop properties, including those for S3A, Spark's connector to S3-compatible storage. spark-defaults.conf, generated from customSparkConfig.properties, contains Spark properties.
By default, the chart adds the classpath lines to spark-defaults.conf, and the S3A, Iceberg and Delta Lake jars are already in the image: applications do not need --packages or download anything. The S3 endpoint and keys have no default, and Iceberg and Delta Lake are disabled. When enabled, the chart adds their catalogs to spark-defaults.conf.
The following scenarios enable each integration: S3 storage (scenario 2), Iceberg and Delta Lake (scenario 3), Jupyter (scenario 4) and Airflow (scenario 5). Before enabling one of them, you want to know where it is configured.
fs.defaultFS in the bucket warehouse through S3A, with path-style access and without SSL, but without endpoint or keys.
The contents of customSparkConfig.properties and the classpath containing S3A jars. Iceberg and Delta Lake are disabled.
S3A, Iceberg, Delta Lake and Hive Metastore client jars, and the Python libraries pyspark, delta-spark and pyiceberg.
The two files the chart generates
- Master and workers. The chart's pods. They read the core-site.xml and spark-defaults.conf files generated by the chart and run application executors.
- core-site.xml. Generated from hadoopConfig: Hadoop properties, such as the S3A endpoint and keys. Chart default:
fs.defaultFS in the warehouse bucket, without endpoint or keys. (tdp-spark.hadoopConfig) - spark-defaults.conf. Generated from customSparkConfig.properties, plus lines added by the chart: the classpath for jars in the image, Iceberg and Delta Lake catalogs and Hive Metastore when enabled. Chart default:
Iceberg and Delta Lake disabled. (tdp-spark.customSparkConfig.properties) - S3-compatible storage. Accessed through S3A using the endpoint and keys from hadoopConfig. With TDP charts, this is the Ozone S3 Gateway. The bucket must exist. Chart default:
without endpoint or keys. (tdp-spark.hadoopConfig) - Hive Metastore. Stores metadata for Iceberg and Delta Lake tables registered by name, accessed through the catalog's Thrift address. Chart default:
disabled (Iceberg and Delta Lake disabled). (tdp-spark.iceberg.catalog.uri · tdp-spark.deltaLake.metastoreUri)
1tdp-spark:2hadoopConfig:3 fs.s3a.endpoint: ...4customSparkConfig:5 properties: |6 ...7iceberg:8 enabled: false9deltaLake:10 enabled: false11integration:12 jupyter:13 enabled: false
All integrations are under the chart key, tdp-spark, not in the spark block.
- TDP block (linha 1). All integrations are under the chart key, tdp-spark, not in the spark block.
- core-site.xml (linha 2). Each hadoopConfig key becomes a core-site.xml property. This is where the S3 endpoint and keys are configured (scenario 2).
- spark-defaults.conf (linha 4). properties is a single string: setting your own replaces the entire default. Start with a copy of the default content.
- Iceberg (linha 7). When enabled, the chart adds the SQL extension and iceberg catalog in Hive Metastore to spark-defaults.conf (scenario 3).
- Delta Lake (linha 9). When enabled, the chart adds the SQL extension and Delta Lake catalog in spark_catalog (scenario 3).
- Jupyter (linha 11). When enabled, the chart generates Spark client configuration for notebooks (scenario 4).
View the two files generated by the chart
The ConfigMaps show the core-site.xml and spark-defaults.conf used by the master and workers.
core-site.xml is in the ConfigMap tdp-spark-hadoop-config, and spark-defaults.conf in the ConfigMap from customSparkConfig.configMapName:
kubectl -n <NAMESPACE> get configmap tdp-spark-hadoop-config spark-custom-defaults -o yaml
Success criteria
core-site.xml contains the keys from hadoopConfig, and spark-defaults.conf contains the spark.driver.extraClassPath and spark.executor.extraClassPath lines with jars from the image.Add any other Hadoop or Spark property the same way: in hadoopConfig for core-site.xml, or in your copy of customSparkConfig.properties for spark-defaults.conf.
S3A endpoint and keys, with the Ozone S3 Gateway or other compatible storage.
You want applications to read and write S3-compatible storage, such as the Ozone S3 Gateway. The chart already points fs.defaultFS to the warehouse bucket through S3A, but the endpoint and keys have no defaults: you provide them. The bucket must exist in storage.
fs.defaultFS in the bucket warehouse, path-style access and no SSL, without endpoint or keys. The credential provider reads keys from hadoopConfig or the variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY of the pod.
The Ozone S3 Gateway address, or another S3-compatible storage address, access keys and the warehouse bucket already created.
The executors on S3 storage
- Master and workers. The chart's pods. They read the core-site.xml and spark-defaults.conf files generated by the chart and run application executors.
- core-site.xml. Generated from hadoopConfig: Hadoop properties, such as the S3A endpoint and keys. Chart default:
fs.defaultFS in the warehouse bucket, without endpoint or keys. (tdp-spark.hadoopConfig) - spark-defaults.conf. Generated from customSparkConfig.properties, plus lines added by the chart: the classpath for jars in the image, Iceberg and Delta Lake catalogs and Hive Metastore when enabled. Chart default:
Iceberg and Delta Lake disabled. (tdp-spark.customSparkConfig.properties) - S3-compatible storage. Accessed through S3A using the endpoint and keys from hadoopConfig. With TDP charts, this is the Ozone S3 Gateway. The bucket must exist. Chart default:
without endpoint or keys. (tdp-spark.hadoopConfig)
1tdp-spark:2hadoopConfig:3 fs.s3a.endpoint: "http://<S3_ENDPOINT>:<S3_PORT>"4 fs.s3a.access.key: "<S3_ACCESS_KEY>"5 fs.s3a.secret.key: "<S3_SECRET_KEY>"
Keys you define here are merged with the chart defaults, such as fs.defaultFS and path-style access.
- Map (linha 2). Keys you define here are merged with the chart defaults, such as fs.defaultFS and path-style access.
- Endpoint (linha 3). With the Ozone chart in the same cluster, this is the S3 Gateway Service address, as shown in the scenario 3 block.
- Keys (linha 4). To keep keys out of the values file, move them to a Secret and remove these two lines (Security - Spark, Keys in a Secret scenario).
With Ozone defaults, without Kerberos, the S3 Gateway does not validate keys: any non-empty pair works. With Ozone security enabled, only keys issued by Ozone work, such as the one in the ozone-s3-credentials Secret. See Security - Spark.
Add the block to the values file
Replace the placeholders with your storage endpoint and keys.
If you already have a Spark values file, add the block to it.
Apply to the release
The chart regenerates core-site.xml.
helm upgrade --install <RELEASE_NAME> oci://registry.tecnisys.com.br/tdp/charts/tdp-spark \
--version 3.0.3 \
-n <NAMESPACE> --create-namespace \
-f <VALUES_FILE>
Success criteria
kubectl -n <NAMESPACE> get configmap tdp-spark-hadoop-config -o yaml
core-site.xml contains fs.s3a.endpoint with the address you provided.
If applications cannot reach S3
Check the endpoint, keys and whether the warehouse bucket exists. See When something goes wrong.
Tables registered in Hive Metastore, with data in S3.
You want to create and query tables by name, with metadata in Hive Metastore and data in S3. The chart offers two table formats that can be enabled together. With Iceberg enabled, the chart adds the SQL extension and iceberg catalog, the default catalog for unqualified table names, in Hive Metastore. With Delta Lake enabled, it adds the SQL extension and Delta Lake catalog in spark_catalog. With both enabled, Delta Lake table names use spark_catalog.<DATABASE_NAME>.<TABLE_NAME>.
Disabled (iceberg.enabled). When enabled, the catalog iceberg uses Hive Metastore from iceberg.catalog.uri and the warehouse from iceberg.catalog.warehouse, in the bucket warehouse.
Disabled (deltaLake.enabled). When enabled, managed tables are stored in the warehouse from deltaLake.storage.warehouse. Tables are registered in Hive Metastore from deltaLake.metastoreUri or, when empty, from the Iceberg catalog if enabled. Without either, tables are only accessed by path, in the format delta.`s3a://...`.
The defaults expect the charts tdp-hive-metastore and tdp-ozone in the namespace tdp. For another namespace, replace the addresses as in the block below.
Hive Metastore deployed and reachable, and S3 access configured (scenario 2).
Metadata in the metastore, data in S3
- Master and workers. The chart's pods. They read the core-site.xml and spark-defaults.conf files generated by the chart and run application executors.
- core-site.xml. Generated from hadoopConfig: Hadoop properties, such as the S3A endpoint and keys. Chart default:
fs.defaultFS in the warehouse bucket, without endpoint or keys. (tdp-spark.hadoopConfig) - spark-defaults.conf. Generated from customSparkConfig.properties, plus lines added by the chart: the classpath for jars in the image, Iceberg and Delta Lake catalogs and Hive Metastore when enabled. Chart default:
Iceberg and Delta Lake disabled. (tdp-spark.customSparkConfig.properties) - S3-compatible storage. Accessed through S3A using the endpoint and keys from hadoopConfig. With TDP charts, this is the Ozone S3 Gateway. The bucket must exist. Chart default:
without endpoint or keys. (tdp-spark.hadoopConfig) - Hive Metastore. Stores metadata for Iceberg and Delta Lake tables registered by name, accessed through the catalog's Thrift address. Chart default:
disabled (Iceberg and Delta Lake disabled). (tdp-spark.iceberg.catalog.uri · tdp-spark.deltaLake.metastoreUri)
1tdp-spark:2hadoopConfig:3 fs.s3a.endpoint: "http://tdp-ozone-s3g-rest.<NAMESPACE>.svc.cluster.local:9878"4 fs.s3a.access.key: "<S3_ACCESS_KEY>"5 fs.s3a.secret.key: "<S3_SECRET_KEY>"6iceberg:7 enabled: true8 catalog:9 uri: "thrift://tdp-hive-metastore-metastore.<NAMESPACE>.svc.cluster.local:9083"10 storage:11 endpoint: "http://tdp-ozone-s3g-rest.<NAMESPACE>.svc.cluster.local:9878"12deltaLake:13 enabled: true
Table files pass through S3A using the endpoint and keys from hadoopConfig (scenario 2).
- Data files (linha 2). Table files pass through S3A using the endpoint and keys from hadoopConfig (scenario 2).
- Enable Iceberg (linha 7). The chart adds the Iceberg SQL extension and iceberg catalog, the default catalog for unqualified table names.
- Hive Metastore (linha 9). The Thrift address of the Hive Metastore Service, in the namespace where it was installed.
- Warehouse endpoint (linha 11). With Iceberg and Delta Lake enabled, this endpoint applies to both.
- Enable Delta Lake (linha 13). The chart adds the SQL extension and Delta Lake catalog in spark_catalog. With Iceberg enabled, Delta Lake tables use the same Hive Metastore.
Add the block to the values file
Replace the namespace in the addresses with the namespace of the Hive Metastore and Ozone charts.
If you already have a Spark values file, add the block to it.
Apply to the release
The chart regenerates spark-defaults.conf with the catalogs.
helm upgrade --install <RELEASE_NAME> oci://registry.tecnisys.com.br/tdp/charts/tdp-spark \
--version 3.0.3 \
-n <NAMESPACE> --create-namespace \
-f <VALUES_FILE>
Create and query an Iceberg table
From the master pod, spark-sql creates a table, writes a row and reads it back.
The master Service is the one from Spark configuration, the First steps scenario: with release spark, spark-master-svc.
kubectl -n <NAMESPACE> exec -it \
$(kubectl -n <NAMESPACE> get pod -l app.kubernetes.io/component=master -o jsonpath='{.items[0].metadata.name}') \
-- spark-sql --master spark://<SPARK_MASTER_SERVICE>:7077 \
-e "CREATE NAMESPACE IF NOT EXISTS iceberg.demo; CREATE TABLE iceberg.demo.t (id BIGINT) USING iceberg; INSERT INTO iceberg.demo.t VALUES (1); SELECT * FROM iceberg.demo.t;"
Success criteria
SELECT returns the row written.If the query fails
Without S3, data files are not written. Without Hive Metastore, the catalog does not register the table. See When something goes wrong.
The Spark client configuration generated by the chart for notebooks.
Jupyter notebooks run Spark: the driver runs in the notebook pod and connects to this chart's master, and executors run on workers. For this, the chart generates Spark client configuration: with integration.jupyter.enabled, it creates a ConfigMap containing a spark-defaults.conf built from integration.jupyter.sparkConfig. This map includes placeholders for the master address and driver host, which you fill in.
Disabled (integration.jupyter.enabled). The map integration.jupyter.sparkConfig contains placeholders in spark.master and spark.driver.host, in addition to ports and the per-user application name.
The ConfigMap tdp-spark-jupyter-integration, with the spark-defaults.conf and an environment script for notebooks.
The notebook as the Spark driver
- Master and workers. The chart's pods. They read the core-site.xml and spark-defaults.conf files generated by the chart and run application executors.
- core-site.xml. Generated from hadoopConfig: Hadoop properties, such as the S3A endpoint and keys. Chart default:
fs.defaultFS in the warehouse bucket, without endpoint or keys. (tdp-spark.hadoopConfig) - spark-defaults.conf. Generated from customSparkConfig.properties, plus lines added by the chart: the classpath for jars in the image, Iceberg and Delta Lake catalogs and Hive Metastore when enabled. Chart default:
Iceberg and Delta Lake disabled. (tdp-spark.customSparkConfig.properties) - Client configuration for Jupyter. With the integration enabled, the chart generates a ConfigMap with a spark-defaults.conf built from integration.jupyter.sparkConfig, plus an environment script. Chart default:
disabled. (tdp-spark.integration.jupyter.enabled) - Jupyter. The driver runs in the notebook pod and connects to the master through the Service; executors run on workers.
1tdp-spark:2integration:3 jupyter:4 enabled: true5 sparkConfig:6 "spark.master": "spark://<SPARK_MASTER_SERVICE>.<NAMESPACE>.svc.cluster.local:7077"7 "spark.driver.host": "<COMPONENT_HOSTNAME>"
The chart now generates the ConfigMap with client configuration.
- Enable the integration (linha 4). The chart now generates the ConfigMap with client configuration.
- Map (linha 5). Keys you define are merged with the other defaults, such as driver ports and the per-user application name.
- Master (linha 6). The full master Service address, including the namespace.
- Driver host (linha 7). The address executors use to reach the driver running in the notebook pod.
Apply to the release
The chart generates the integration ConfigMap.
helm upgrade --install <RELEASE_NAME> oci://registry.tecnisys.com.br/tdp/charts/tdp-spark \
--version 3.0.3 \
-n <NAMESPACE> --create-namespace \
-f <VALUES_FILE>
Success criteria
kubectl -n <NAMESPACE> get configmap tdp-spark-jupyter-integration -o yaml
The ConfigMap's spark-defaults.conf contains the master address and driver host you provided.
Notebooks read the spark-defaults.conf that the Jupyter chart builds from its values in tdpSparkIntegration. That is where this chart's master address is configured. For the Jupyter side, see Integrations - Jupyter.
Tasks running Spark, with the driver in the task pod.
Your Airflow tasks run Spark. The driver runs in the task pod, outside this chart's pods, so configuration is handled on the Airflow side. Two points apply on the Spark side: if History Server is enabled, the driver must write event logs to the same directory read by History Server. And with Ozone security enabled, the driver itself needs S3 keys.
The Airflow tasks as the Spark driver
- Master and workers. The chart's pods. They read the core-site.xml and spark-defaults.conf files generated by the chart and run application executors.
- core-site.xml. Generated from hadoopConfig: Hadoop properties, such as the S3A endpoint and keys. Chart default:
fs.defaultFS in the warehouse bucket, without endpoint or keys. (tdp-spark.hadoopConfig) - spark-defaults.conf. Generated from customSparkConfig.properties, plus lines added by the chart: the classpath for jars in the image, Iceberg and Delta Lake catalogs and Hive Metastore when enabled. Chart default:
Iceberg and Delta Lake disabled. (tdp-spark.customSparkConfig.properties) - Airflow. The Airflow image includes Spark: the driver runs in the task pod, outside this chart's pods. Configuration is handled on the Airflow side.
For the procedure, including event logs and Ozone keys, see Integrations - Airflow. For Spark History Server, see Spark configuration.
When something goes wrong
Troubleshooting
Paste the error message or choose a symptom. The response includes the cause, action and command.
- S3 access fails: missing endpoint or keys. Cause: The S3 endpoint and keys have no defaults in the chart. What to do: Set fs.s3a.endpoint, fs.s3a.access.key and fs.s3a.secret.key in hadoopConfig (S3 scenario), or move the keys to a Secret (Security - Spark).
- The bucket does not exist. Cause: Default paths use the warehouse bucket, which must exist in the storage system. What to do: Create the warehouse bucket in S3 storage before using Spark.
- Access denied after enabling Ozone security. Cause: With Ozone security (Kerberos) enabled, the S3 Gateway only accepts keys issued by Ozone. What to do: Use the key from the ozone-s3-credentials Secret or from an additional Ozone S3 user, and restart the pods (Security - Spark, Ozone security scenario).
- Delta Lake tables only work by path. Cause: Without deltaLake.metastoreUri or Iceberg enabled, there is no Hive Metastore to register Delta Lake tables by name. What to do: Set deltaLake.metastoreUri, or enable Iceberg, whose catalog already points to Hive Metastore (Lakehouse scenario).
- Iceberg, Delta Lake or S3A classes not found. Cause: A custom spark.driver.extraClassPath in customSparkConfig.properties replaces the chart's classpath. What to do: Remove the custom extraClassPath. Jars in the image are included through the classpath built by the chart.
- Another problem. Cause: Start with pod status and namespace events. What to do: Events in chronological order show what prevents the pod from starting.
Integration parameters
Filter by name or group. The chart prefix is already filled in.
20 of 20 parameters
| Parâmetro | Description | Chart default |
|---|---|---|
tdp-spark.hadoopConfig.fs.defaultFSS3 | Default filesystem | s3a://warehouse |
tdp-spark.hadoopConfig.fs.s3a.endpointS3 | S3-compatible storage endpoint | no default |
tdp-spark.hadoopConfig.fs.s3a.access.keyS3 | S3 access key. Alternative: AWS_ACCESS_KEY_ID in a Secret | no default |
tdp-spark.hadoopConfig.fs.s3a.secret.keyS3 | S3 secret key. Alternative: AWS_SECRET_ACCESS_KEY in a Secret | no default |
tdp-spark.hadoopConfig.fs.s3a.path.style.accessS3 | Path-style access | "true" |
tdp-spark.hadoopConfig.fs.s3a.connection.ssl.enabledS3 | SSL for the S3 connection | "false" |
tdp-spark.hadoopConfig.fs.s3a.regionS3 | S3 region | us-east-1 |
tdp-spark.iceberg.enabledIceberg | Iceberg SQL extension and catalog | false |
tdp-spark.iceberg.catalog.nameIceberg | Catalog name, the default for unqualified names | iceberg |
tdp-spark.iceberg.catalog.uriIceberg | Hive Metastore Thrift address | thrift://tdp-hive-metastore-metastore.tdp.svc.cluster.local:9083 |
tdp-spark.iceberg.catalog.warehouseIceberg | Iceberg table warehouse | s3a://warehouse/hive |
tdp-spark.iceberg.catalog.defaultNamespaceIceberg | Default catalog namespace | default |
tdp-spark.iceberg.storage.endpointIceberg | Warehouse S3 endpoint. With Delta Lake enabled, applies to both | http://tdp-ozone-s3g-rest.tdp.svc.cluster.local:9878 |
tdp-spark.deltaLake.enabledDelta Lake | Delta Lake SQL extension and catalog in spark_catalog | false |
tdp-spark.deltaLake.metastoreUriDelta Lake | Hive Metastore for Delta Lake tables. When empty, uses Iceberg's if enabled | "" |
tdp-spark.deltaLake.storage.endpointDelta Lake | Warehouse S3 endpoint when Iceberg is disabled | http://tdp-ozone-s3g-rest.tdp.svc.cluster.local:9878 |
tdp-spark.deltaLake.storage.warehouseDelta Lake | Managed table location | s3a://warehouse/delta |
tdp-spark.bundledJarsClasspath | Jars from the image in the driver and executor classpath. Follows the image tag | S3A, Iceberg and Delta Lake from the image |
tdp-spark.integration.jupyter.enabledJupyter | Generates Spark client configuration for Jupyter | false |
tdp-spark.integration.jupyter.sparkConfigJupyter | Client spark-defaults.conf map. Your settings are merged with the defaults | placeholders in spark.master and spark.driver.host |