Spark Connector configuration in Apache Atlas

Learn to configure the Spark Atlas Connector so that Spark jobs can run even when Kafka brokers are down. This ensures that your job submissions do not fail.

Before you begin the configuration, you must link the Spark service to an Atlas service and enable Spark lineage in Cloudera Manager. Both settings are required. If Spark lineage is enabled but the Spark service does not depend on an Atlas service, Cloudera Manager displays a Spark lineage configuration warning.

  1. Log in to Cloudera Manager.
  2. Go to Clusters > Spark or Clusters > Spark 3 (spark3_on_yarn), depending on the Spark service that runs your jobs.
  3. Click the Configuration tab.
  4. Search for Atlas Service (atlas_service), and select your Atlas service from the list.

    This is a service-wide setting that has no default value.


    Configuration tab of the spark3_on_yarn service in Cloudera Manager. The Atlas Service (atlas_service) parameter is selected with an Atlas service in the service-wide scope.
  5. Search for Enable Spark Lineage (spark.lineage.enabled), and select the checkbox.

    This setting applies to the Gateway scope. The checkbox is selected by default.


    Configuration tab of the spark3_on_yarn service in Cloudera Manager, filtered by spark lineage. The Enable Spark Lineage (spark.lineage.enabled) checkbox is selected for the Gateway Default Group.
  6. Click Save Changes.
  7. Click Actions > Deploy Client Configuration so that the Spark gateways receive the updated Atlas client configuration and the Spark Atlas Connector listeners.
Using the spark.lineage.kafka.fault-tolerant.timeout.ms parameter

If all Kafka brokers are down, the deploy mode is cluster mode without the keytab/principal. Spark Atlas lineage is also enabled which does not allow a delegation token from the Kafka broker. Therefore, the job submission fails. As a result, --deploy-mode is set but --principal PRINCIPAL and --keytab KEYTAB are not set. Use spark.lineage.kafka.fault-tolerant.timeout.ms parameter to resolve this case.

The default timeout value for the Kafka delegation token creation is 0. This means that the fault tolerant mode is disabled. If the value is greater than 0, the fault tolerant mode is enabled with the configured timeout value.

See the example PySpark code below:
from pyspark.sql import SparkSession
import time
import sys
id_string = str(time.time()).split(".")[0]
spark = SparkSession.builder.appName("Python CTAS example").getOrCreate()
spark.sql("CREATE TABLE parquet_spark1_" + id_string +" ( id bigint, data string, category string) using parquet")
spark.sql("CREATE TABLE parquet_spark2_" + id_string +" USING parquet AS SELECT * from parquet_spark1_" + id_string)
Example commands:
spark-submit --conf spark.lineage.kafka.fault-tolerant.timeout.ms=8000 --deploy-mode cluster test.py
spark3-submit --conf spark.lineage.kafka.fault-tolerant.timeout.ms=8000 --deploy-mode cluster test.py
Limitation:

This timeout will permit the job submission in cluster mode if all Kafka Brokers are down. There will be no Spark Atlas Connector lineage because we do not have Kafka delegation token which is required for the lineage creation.

TLS and encryption in transit (7.3.2.10000 SP1)

The Spark Atlas Connector does not terminate TLS for lineage traffic. Metadata is published to Apache Atlas and Kafka using the TLS and Kerberos configuration for those services. Enable TLS 1.3 for Apache Atlas when your Cloudera Manager policy allows it. For Apache Atlas TLS configuration, see Configuring TLS/SSL for Apache Atlas. For Spark and Livy encryption defaults when you enable the CMF_FF_ENCRYPT_ALL_PORTS (Encrypt all ports) feature flag, see Encryption in transit for Spark and Livy in Cloudera Runtime 7.3.2.10000 SP1.