Setting up the Apache Iceberg Sink connector

Install the Apache Iceberg Sink connector plugin on each Kafka Connect worker and configure Ranger policies so you can deploy a connector instance in Streams Messaging Manager.

Before you deploy an instance of the Apache Iceberg Sink connector, you must download and copy the connector plugin ZIP to every Kafka Connect worker. Cloudera does not automate this installation. As a standalone plugin, the connector may require additional JARs for your storage and catalog configuration. Collect the required JARs and place them in the extracted connector directory on each worker.

The connector supports Amazon S3, Azure Data Lake Storage (ADLS), and Ozone as storage backends. For catalogs, it supports Hive Metastore and JDBC catalogs.

Configure the connector entirely through the connector JSON in Streams Messaging Manager. Use iceberg.catalog.* properties for catalog and storage settings, and iceberg.hadoop.* properties for Hive Metastore client and Kerberos settings.

For connector properties, single message transformations (SMTs), and routing, see the Apache Iceberg Sink Connector documentation in Related information.

Import CA certificates into the Cloudera Manager Auto-TLS truststore. The required certificates depend on your storage backend:

  • Amazon S3: Import all four Amazon Root CA certificates (amazonrootca1 through amazonrootca4) into the Auto-TLS truststore. In Cloudera Manager, go to Administration > Security > Update Auto-TLS Truststore. Restart Hive and Kafka Connect on the affected hosts.
  • Azure ADLS: Import the DigiCert Global Root G2 or the Microsoft RSA Root Certificate Authority 2017 certificate into the Auto-TLS truststore. In Cloudera Manager, go to Administration > Security > Update Auto-TLS Truststore.
  • Ozone: No additional certificate import is required.

If your cluster mounts /tmp with noexec, set the JAVA_TOOL_OPTIONS Kafka Connect worker environment variable to -Djava.io.tmpdir=/var/lib/kafka before you restart the service.

On Kerberos clusters, the upstream Apache Iceberg connector's bundled Hive Metastore client (iceberg-kafka-connect-runtime-hive, Hive 2.3.10) connects to HMS over SASL/Kerberos on plain Thrift, not TLS on the HMS Thrift port. This connector does not support TLS on the HMS Thrift interface combined with Kerberos SASL, and the upstream Apache Iceberg Kafka Connect guide does not document this combination. To disable HMS Thrift SSL in Cloudera Manager:

  1. On the Hive service Configuration page, add hive.metastore.use.SSL=false to Hive Metastore Server Advanced Configuration Snippet (Safety Valve) for hive-site.xml.
  2. Restart Hive Metastore.
  1. Download the certified Apache Iceberg Sink connector ZIP from Cloudera Archive.
  2. Copy the connector ZIP to the plugin path on each Kafka Connect worker.
    For example:
    scp iceberg-kafka-connect-runtime-hive-[***VERSION***].zip root@[***HOST***]:/var/lib/kafka
  3. Extract the ZIP on each worker.
    For example:
    ssh root@[***HOST***] "unzip -d /var/lib/kafka/ /var/lib/kafka/iceberg-kafka-connect-runtime-hive-[***VERSION***].zip"
  4. Set file permissions so the kafka user can read the plugin files.
  5. Configure storage-specific settings for Hive Metastore and Kafka Connect.

    The required configuration depends on your storage backend.

    Amazon S3

    On the Hive service Configuration page, add the following bucket-scoped S3A settings to Hive Metastore Server Advanced Configuration Snippet (Safety Valve) for hive-site.xml. Replace the placeholders with your values.

    fs.s3a.impl=org.apache.hadoop.fs.s3a.S3AFileSystem
    fs.s3a.bucket.[***BUCKET***].access.key=[***ACCESS_KEY***]
    fs.s3a.bucket.[***BUCKET***].secret.key=[***SECRET_KEY***]
    fs.s3a.bucket.[***BUCKET***].aws.credentials.provider=org.apache.hadoop.fs.s3a.SimpleAWSCredentialsProvider
    fs.s3a.bucket.[***BUCKET***].endpoint=s3.[***REGION***].amazonaws.com
    fs.s3a.bucket.[***BUCKET***].endpoint.region=[***REGION***]
    Azure ADLS

    The connector requires two sets of ADLS credentials:

    • An App Registration secret: AZURE_CLIENT_ID, AZURE_TENANT_ID, and AZURE_CLIENT_SECRET.
    • Storage account credentials: azureStorageAccountName, azureStorageAccountKey, and azureStorageContainer.

    On the Hive service Configuration page, add the storage account key to Hive Metastore Server Advanced Configuration Snippet (Safety Valve) for hive-site.xml. Hive Metastore derives the remaining settings from the warehouse path.

    fs.azure.account.key.[***AZURE_STORAGE_ACCOUNT_NAME***].dfs.core.windows.net=[***AZURE_STORAGE_ACCOUNT_KEY***]

    Add the App Registration secret values as environment variables in the Kafka Connect environment.

    Ozone
    1. Inject the Ozone filesystem JAR into the connector plugin. The iceberg-kafka-connect-runtime-hive package does not include ozone-filesystem-hadoop3-*.jar. Without it, any ofs:// access fails with ClassNotFoundException. On every Kafka Connect host, find the Iceberg runtime artifact under /var/lib/kafka/ and copy the JAR into its lib/ directory.
    2. Provision an iceberg.hadoop-conf-dir directory on each Kafka Connect host. Create a directory that the kafka user can read (for example, /tmp/kc-iceberg-hadoop-conf/) containing:
      • core-site.xml, hdfs-site.xml, and ozone-site.xml, copied from the Kafka Connect process directory.
      • A hand-authored hive-site.xml containing the HMS URI, sasl.enabled=true, the Kerberos principal, use.SSL=false, and the Ozone filesystem bindings fs.ofs.impl=org.apache.hadoop.fs.ozone.RootedOzoneFileSystem and fs.AbstractFileSystem.ofs.impl=org.apache.hadoop.fs.ozone.RootedOzFs.
    3. Create the Ozone volume and bucket, and grant ACLs. Access to Ozone is native (ACL and Ranger). As an Ozone Manager admin, run the following commands on an Ozone Manager host:
      kinit -kt [***OM_KEYTAB***] [***OM_PRINCIPAL***]
      ozone sh volume create /[***VOLUME***]
      ozone sh bucket create /[***VOLUME***]/[***BUCKET***]

      Grant all ACLs on both the volume and the bucket to each user involved, including kafka (the Kafka Connect worker principal) and hive (HMS reads and writes at commit time):

      for U in hive kafka [***YOUR_PRINCIPAL***]; do
        ozone sh volume addacl -a user:$U:a /[***VOLUME***]
        ozone sh bucket addacl -a user:$U:a /[***VOLUME***]/[***BUCKET***]
      done
  6. Configure the connector control topic for exactly-once semantics (EOS).
    The connector enables exactly-once semantics (EOS) by default. It uses a compacted Kafka control topic. If your cluster has auto.create.topics.enable set to true, the control topic is created automatically when the connector starts. If not, create a compacted topic first (for example, control-iceberg), then set the topic name with the iceberg.control.topic property. For details, see Control topic in the Apache Iceberg Sink Connector documentation.
  7. Configure Ranger policies for Kafka, Schema Registry, and Hadoop SQL.
    Grant these permissions:
    • Kafka: Grant consume, describe, and create on the source topics and consumer group. Also grant consume and describe on the connect-[***CONNECTOR_NAME***] and control-topic consumer groups.
    • Schema Registry: Grant read on the Schema Registry service and on the schema group, branch, and version you use.
    • Hadoop SQL: Grant create and write on the target Hive database, table, and storage URL. The storage URL scheme depends on your storage backend:
      • Amazon S3: s3a://[***BUCKET***]/[***WAREHOUSE_PREFIX***]/*
      • Azure ADLS: abfss://[***AZURE_STORAGE_CONTAINER***]@[***AZURE_STORAGE_ACCOUNT_NAME***].dfs.core.windows.net/[***WAREHOUSE_PREFIX***]/*
      • Ozone: ofs://[***OZONE_SERVICE_ID***]/[***VOLUME***]/[***BUCKET***]/*

    ADLS and Ozone require additional Ranger service policies for the kafka principal:

    Azure ADLS
    In the CM_ADLS service, grant read and write access on the storage account, container, and warehouse prefix path that the connector uses.
    Ozone
    In the OZONE service, grant read, list, and read_acl on the volume. Grant read, write, create, delete, list, and all on the bucket and on keys within it.
  8. Pre-create the target database.
    The connector automatically creates the target table, but not the database. Create the database through HiveServer2 before you deploy the connector. Use the URI scheme for your storage backend: s3a:// for Amazon S3, abfss:// for ADLS, or ofs:// for Ozone. For example:
    CREATE DATABASE IF NOT EXISTS [***HIVE_DB***]
      LOCATION 's3a://[***BUCKET***]/[***WAREHOUSE_PREFIX***]/[***HIVE_DB***].db';
  9. In Cloudera Manager, restart all Kafka Connect service roles.
The Apache Iceberg Sink connector plugin is on all Kafka Connect hosts. You can now deploy a connector instance in your cluster.

Deploy a connector instance in the Streams Messaging Manager UI. For deployment steps, see Deploying and managing Kafka Connect connectors in Streams Messaging Manager in Related information.

To automatically add new Schema Registry fields as columns in the Iceberg table, include the following property in the connector configuration:

"iceberg.tables.evolve-schema-enabled": "true"

Example configurations

Configuration examples for the Apache Iceberg Sink connector that you can import into the Streams Messaging Manager UI.

The following configurations can be imported into the Streams Messaging Manager UI.

Kerberized cluster with Auto-TLS, Hive catalog, and Amazon S3 (single table)

Replace the bracketed placeholders with your values:

{
  "name": "[***CONNECTOR_NAME***]",
  "config": {
    "connector.class": "org.apache.iceberg.connect.IcebergSinkConnector",
    "tasks.max": "1",
    "topics": "[***KAFKA_TOPIC***]",

    "iceberg.catalog.type": "hive",
    "iceberg.catalog.uri": "thrift://[***HIVE_METASTORE_HOST***]:9083",
    "iceberg.catalog.warehouse": "s3a://[***BUCKET_NAME***]/[***PATH***]/",
    "iceberg.catalog.client.region": "[***AWS_REGION***]",
    "iceberg.catalog.io-impl": "org.apache.iceberg.aws.s3.S3FileIO",
    "iceberg.catalog.s3.access-key-id": "[***AWS_ACCESS_KEY***]",
    "iceberg.catalog.s3.secret-access-key": "[***AWS_SECRET_KEY***]",

    "iceberg.hadoop.hive.metastore.use.SSL": "false",
    "iceberg.hadoop.hive.metastore.sasl.enabled": "true",
    "iceberg.hadoop.hive.metastore.kerberos.principal": "hive/_HOST@[***REALM***]",
    "iceberg.hadoop.hive.metastore.schema.verification": "false",

    "iceberg.tables": "[***HIVE_DB***].[***HIVE_TABLE***]",
    "iceberg.tables.auto-create-enabled": "true",
    "iceberg.control.topic": "[***CONTROL_TOPIC_NAME***]",
    "iceberg.control.commit.interval-ms": "60000",
    "iceberg.control.commit.timeout-ms": "30000",

    "key.converter": "org.apache.kafka.connect.storage.StringConverter",
    "value.converter": "com.cloudera.dim.kafka.connect.converts.AvroConverter",
    "value.converter.passthrough.enabled": "false",
    "value.converter.schema.registry.url": "https://[***SR_HOST***]:7790/api/v1",
    "value.converter.schema.registry.client.ssl.protocol": "SSL",
    "value.converter.schema.registry.client.ssl.trustStorePath": "[***TRUSTSTORE_PATH***]",
    "value.converter.schema.registry.client.ssl.trustStorePassword": "[***TRUSTSTORE_PASSWORD***]",

    "consumer.override.sasl.mechanism": "GSSAPI",
    "consumer.override.sasl.jaas.config": "com.sun.security.auth.module.Krb5LoginModule required useKeyTab=true storeKey=true keyTab=\"[***KEYTAB_PATH***]\" principal=\"[***PRINCIPAL***]@[***REALM***]\" serviceName=\"kafka\";",
    "value.converter.sasl.jaas.config": "com.sun.security.auth.module.Krb5LoginModule required useKeyTab=true storeKey=true keyTab=\"[***KEYTAB_PATH***]\" principal=\"[***PRINCIPAL***]@[***REALM***]\" serviceName=\"schemaregistry\";"
  }
}

Kerberized cluster with Auto-TLS, Hive catalog, and Azure ADLS

Replace the bracketed placeholders with your values:

{
  "name": "[***CONNECTOR_NAME***]",
  "config": {
    "connector.class": "org.apache.iceberg.connect.IcebergSinkConnector",
    "tasks.max": "1",
    "topics": "[***KAFKA_TOPIC***]",

    "iceberg.catalog.type": "hive",
    "iceberg.catalog.uri": "thrift://[***HIVE_METASTORE_HOST***]:9083",
    "iceberg.catalog.warehouse": "abfss://[***AZURE_STORAGE_CONTAINER***]@[***AZURE_STORAGE_ACCOUNT_NAME***].dfs.core.windows.net/[***WAREHOUSE_PREFIX***]/",
    "iceberg.catalog.io-impl": "org.apache.iceberg.azure.adlsv2.ADLSFileIO",
    "iceberg.hadoop-conf-dir": "/var/lib/kafka/iceberg-hadoop-conf",

    "iceberg.hadoop.hive.metastore.use.SSL": "false",
    "iceberg.hadoop.hive.metastore.sasl.enabled": "true",
    "iceberg.hadoop.hive.metastore.kerberos.principal": "hive/_HOST@[***REALM***]",
    "iceberg.hadoop.hadoop.security.authentication": "kerberos",

    "iceberg.tables": "[***HIVE_DB***].[***HIVE_TABLE***]",
    "iceberg.tables.auto-create-enabled": "true",
    "iceberg.control.topic": "[***CONTROL_TOPIC_NAME***]",
    "iceberg.control.group.id": "ctrlGroup_[***CONNECTOR_NAME***]",

    "key.converter": "org.apache.kafka.connect.storage.StringConverter",
    "value.converter": "com.cloudera.dim.kafka.connect.converts.AvroConverter",
    "value.converter.passthrough.enabled": "false",
    "value.converter.schema.registry.url": "https://[***SR_HOST***]:7790/api/v1",
    "value.converter.schema.registry.client.ssl.protocol": "SSL",
    "value.converter.schema.registry.client.ssl.trustStorePath": "[***TRUSTSTORE_PATH***]",
    "value.converter.schema.registry.client.ssl.trustStorePassword": "[***TRUSTSTORE_PASSWORD***]",

    "consumer.override.sasl.mechanism": "GSSAPI",
    "consumer.override.sasl.jaas.config": "com.sun.security.auth.module.Krb5LoginModule required useKeyTab=true storeKey=true keyTab=\"[***KEYTAB_PATH***]\" principal=\"[***PRINCIPAL***]@[***REALM***]\" serviceName=\"kafka\";",
    "value.converter.sasl.jaas.config": "com.sun.security.auth.module.Krb5LoginModule required useKeyTab=true storeKey=true keyTab=\"[***KEYTAB_PATH***]\" principal=\"[***PRINCIPAL***]@[***REALM***]\" serviceName=\"schemaregistry\";"
  }
}

Kerberized cluster with Auto-TLS, Hive catalog, and Ozone

Replace the bracketed placeholders with your values:

{
  "name": "[***CONNECTOR_NAME***]",
  "config": {
    "connector.class": "org.apache.iceberg.connect.IcebergSinkConnector",
    "tasks.max": "1",
    "topics": "[***KAFKA_TOPIC***]",

    "iceberg.catalog.type": "hive",
    "iceberg.catalog.uri": "thrift://[***HIVE_METASTORE_HOST***]:9083",
    "iceberg.catalog.warehouse": "ofs://[***OZONE_SERVICE_ID***]/[***VOLUME***]/[***BUCKET***]/",
    "iceberg.catalog.io-impl": "org.apache.iceberg.hadoop.HadoopFileIO",
    "iceberg.hadoop-conf-dir": "/var/lib/kafka/iceberg-hadoop-conf",

    "iceberg.hadoop.hive.metastore.use.SSL": "false",
    "iceberg.hadoop.hive.metastore.sasl.enabled": "true",
    "iceberg.hadoop.hive.metastore.kerberos.principal": "hive/_HOST@[***REALM***]",
    "iceberg.hadoop.hadoop.security.authentication": "kerberos",

    "iceberg.tables": "[***HIVE_DB***].[***HIVE_TABLE***]",
    "iceberg.tables.auto-create-enabled": "true",
    "iceberg.control.topic": "[***CONTROL_TOPIC_NAME***]",
    "iceberg.control.group.id": "ctrlGroup_[***CONNECTOR_NAME***]",

    "key.converter": "org.apache.kafka.connect.storage.StringConverter",
    "value.converter": "com.cloudera.dim.kafka.connect.converts.AvroConverter",
    "value.converter.passthrough.enabled": "false",
    "value.converter.schema.registry.url": "https://[***SR_HOST***]:7790/api/v1",
    "value.converter.schema.registry.client.ssl.protocol": "SSL",
    "value.converter.schema.registry.client.ssl.trustStorePath": "[***TRUSTSTORE_PATH***]",
    "value.converter.schema.registry.client.ssl.trustStorePassword": "[***TRUSTSTORE_PASSWORD***]",

    "consumer.override.sasl.mechanism": "GSSAPI",
    "consumer.override.sasl.jaas.config": "com.sun.security.auth.module.Krb5LoginModule required useKeyTab=true storeKey=true keyTab=\"[***KEYTAB_PATH***]\" principal=\"[***PRINCIPAL***]@[***REALM***]\" serviceName=\"kafka\";",
    "value.converter.sasl.jaas.config": "com.sun.security.auth.module.Krb5LoginModule required useKeyTab=true storeKey=true keyTab=\"[***KEYTAB_PATH***]\" principal=\"[***PRINCIPAL***]@[***REALM***]\" serviceName=\"schemaregistry\";"
  }
}

Dynamic table routing (fan-out)

You can enable dynamic table routing to write records to multiple Iceberg tables based on a field value in the record. Enable dynamic routing when each record carries the fully qualified destination table name (database.table) in a field.

Do not set the iceberg.tables property when iceberg.tables.dynamic-enabled is set to true. With iceberg.tables.auto-create-enabled set to true, missing tables, and namespaces if Ranger allows, are created on the first write. Pre-create the Hive database and grant Ranger access on [***HIVE_DB***].*.

The following Avro schema shows a field, target_table, that holds the target table. Records must set this field to a fully qualified table name:

{
  "type": "record",
  "name": "UserRouted",
  "namespace": "example",
  "fields": [
    {"name": "id", "type": "long"},
    {"name": "name", "type": "string"},
    {"name": "amount", "type": "double"},
    {"name": "target_table", "type": "string"}
  ]
}

In addition to the properties described in Kerberized cluster with Auto-TLS, Hive catalog, and Amazon S3 (single table), set the following properties on the connector:

"iceberg.tables.dynamic-enabled": "true"
"iceberg.tables.route-field": "target_table"
"iceberg.tables.auto-create-enabled": "true"
"iceberg.control.topic": "[***CONTROL_TOPIC_NAME***]"