Configuring writing to Apache Iceberg tables with Cloudera Harmony Catalog

Cloudera Data Flow writes data from Apache NiFi flows to Apache Iceberg tables managed by Cloudera Harmony Catalog on Cloudera Anywhere Cloud.

Cloudera Data Flow can write records from Apache NiFi flows to managed Apache Iceberg tables using Cloudera Harmony Catalog, which is powered by Apache Polaris. Cloudera Harmony Catalog deployed in Cloudera Anywhere Cloud exposes an Iceberg REST Catalog interface secured with OAuth authentication over TLS/SSL and governed by Apache Ranger authorization policies. To connect a NiFi flow to Cloudera Harmony Catalog, you obtain OAuth client credentials from Anywhere Cloud Console, configure controller services for OAuth token retrieval and REST catalog connectivity by using the pre-created Default NiFi SSL Context Service, and configure the PutIceberg processor to write to your target namespace and table.

Principal binding and Apache Ranger authorization

The Anywhere Cloud Console user that you log in as when generating OAuth client credentials determines what your NiFi flow is authorized to access in Cloudera Harmony Catalog. Client credentials are permanently bound to that user's principal. When a NiFi processor connects to Cloudera Harmony Catalog, Apache Ranger evaluates authorization policies against this bound principal instead of a separate client identity.

Ensure that the user account used to generate credentials exists in Ranger and is assigned to the required policies in the harmony-catalog service. For production data flows, Cloudera recommends logging in to Anywhere Cloud Console by using a dedicated identity provider account configured with only the Ranger permissions that your flow requires.

Prerequisites

Ensure that your environment meets the following prerequisites before configuring Cloudera Harmony Catalog connectivity in Flow Designer:

  • Cloudera Data Flow is deployed in Cloudera Anywhere Cloud, and your user account has the cdf-flow-admin role assigned for that instance.
  • You have created a flow draft in Flow Designer (an active test session is optional unless you want to enable controller services and validate live writes in Flow Designer). For instructions, see Creating a new draft and Starting a test session.
  • Cloudera Harmony Catalog is deployed in Cloudera Anywhere Cloud. For more information, see Deploying Cloudera Harmony Catalog on Anywhere Cloud
  • A catalog, namespace, and target Iceberg table have been created in Cloudera Harmony Catalog.
  • Your Anywhere Cloud Console user account is assigned to the required Apache Ranger policies in the harmony-catalog service, including table read and write permissions and table property read, write, remove, and set permissions.

Configuration workflow

Connecting a NiFi flow in Flow Designer to Cloudera Harmony Catalog involves the following tasks:

  1. Generate an OAuth client_id and client_secret pair from Anywhere Cloud Console. For instructions, see Access keys and API tokens.
  2. Configure a StandardOauth2AccessTokenProvider controller service to retrieve OAuth access tokens.
  3. Configure a RESTCatalogService controller service that references your Cloudera Harmony Catalog URI, warehouse, OAuth token provider, and the Default NiFi SSL Context Service.
  4. Configure a PutIceberg processor to write records to your Iceberg table through RESTCatalogService.

Creating an OAuth2 access token provider service

Configure a StandardOauth2AccessTokenProvider controller service in Cloudera Data Flow Flow Designer to retrieve OAuth bearer tokens for Cloudera Harmony Catalog authentication.

The StandardOauth2AccessTokenProvider controller service authenticates against the Anywhere Cloud Console OAuth token endpoint by using your client_id and client_secret credentials and supplies bearer tokens to the RESTCatalogService controller service.

  • You generated and recorded an OAuth client_id and client_secret pair from Anywhere Cloud Console, and you know your Anywhere Cloud Console domain (for example, my-awc.example.com when your console URL is https://console.my-awc.example.com). For instructions, see Access keys and API tokens.
  • You opened your flow draft in Cloudera Data Flow Flow Designer.
  1. In Flow Designer, click Flow Options > Services > Add Service, select StandardOauth2AccessTokenProvider, and click Add.
  2. Configure the StandardOauth2AccessTokenProvider properties in the Configuration pane.

    Set the following property values, using [Options] > Convert To Parameter for environment-specific and sensitive values:

    • Authorization Server URL - Specify the Anywhere Cloud Console OAuth token endpoint URL by using your Anywhere Cloud Console domain: https://console.[***DOMAIN***]/api/v1/auth/access-keys/token. Cloudera recommends converting this property to a parameter.
    • Client Authentication Strategy – Select BASIC_AUTHENTICATION.
    • Grant Type - Select Client Credentials.
    • Client ID - Enter the client_id value that you obtained from Anywhere Cloud Console. Cloudera recommends converting this property to a parameter.
    • Client Secret - Convert this property to a sensitive parameter and enter the client_secret value that you obtained from Anywhere Cloud Console.
    • SSL Context Service - Select the Default NiFi SSL Context Service.
  3. Click Apply Changes to save the controller service configuration.
  4. Optional: If you have an active test session, click Enable to enable the StandardOauth2AccessTokenProvider controller service.
    Enabling controller services in Flow Designer requires an active test session. If you are building your draft without a test session, Cloudera Data Flow enables configured controller services automatically when you deploy the published flow definition.

Creating a RESTCatalogService controller service

Configure a RESTCatalogService controller service in Cloudera Data Flow Flow Designer to connect Apache NiFi processors to Cloudera Harmony Catalog.

Apache Iceberg processors in Flow Designer delegate catalog metadata requests, TLS encryption, OAuth authentication, and storage credential vending to a RESTCatalogService controller service. This service combines your Cloudera Harmony Catalog URI and warehouse name with your StandardOauth2AccessTokenProvider instance and the pre-created Default NiFi SSL Context Service.

  • You recorded the secure URI and warehouse name for your Cloudera Harmony Catalog instance. To retrieve the secure URI in Anywhere Cloud Console,
    1. Go to Admin Center > Apps.
    2. Locate your Cloudera Harmony Catalog instance and view instance details.
    3. Copy the external API endpoint and append it with /api/catalog:
      https://[***HARMONY
                                          INSTANCE***]-harmony-catalog-api.[***AWC
                                          CLUSTER***].[***DOMAIN***]/api/catalog
      For example: https://my-harmony-instance-harmony-catalog-api.my-awc-cluster.mycompany.com/api/catalog
  • You created and configured the StandardOauth2AccessTokenProvider controller service in your Flow Designer draft (and enabled it if you have an active test session).
  1. In Flow Designer, click Flow Options > Services > Add Service, select RESTCatalogService, and click Add.
  2. Configure the RESTCatalogService properties in the Configuration pane.

    Set the following property values, using [Options] > Convert To Parameter for environment-specific values:

    • Catalog URI – Specify the secure URI for the Cloudera Harmony Catalog instance that you want to connect to (for example, https://[***HARMONY INSTANCE***]-harmony-catalog-api.[***AWC CLUSTER***].[***DOMAIN***]/api/catalog). Cloudera recommends converting this property to a parameter.
    • Access Delegation Strategy – Select Vended Credentials.
    • Warehouse – Enter the name of your Cloudera Harmony Catalog warehouse (for example, harmonycatalog). Cloudera recommends converting this property to a parameter.
    • OAuth2 Access Token Provider – Select the StandardOauth2AccessTokenProvider instance that you created earlier.
    • SSL Context Service – Select the existing Default NiFi SSL Context Service.
    • Add a Dynamic Property to connect to AWC Managed Storage - Select Add Propery:

      1. Provide io-impl as Property Name, then click Add.
      2. Provide org.apache.iceberg.io.ProxyResolvingFileIO. as Value, then click OK.
      3. Click Apply Changes.
  3. Click Apply Changes to save the controller service configuration.
  4. Optional: If you have an active test session, ensure that StandardOauth2AccessTokenProvider is enabled, and click Enable to enable the RESTCatalogService controller service.

Configuring the PutIceberg processor

Configure the PutIceberg processor on the Cloudera Data Flow Flow Designer canvas to write records to Apache Iceberg tables through Cloudera Harmony Catalog.

After you configure RESTCatalogService, you can reference it in the PutIceberg processor on the Flow Designer canvas to write incoming record-oriented FlowFiles to your target Apache Iceberg table.

  • You created and configured the RESTCatalogService controller service in your Flow Designer draft (and enabled all required controller services if you have an active test session).
  1. Drag a PutIceberg processor from the Components sidebar onto the Flow Designer canvas.
  2. Select the processor on the canvas to open the Configuration pane and expand Properties.
  3. Set Catalog Service to the RESTCatalogService instance that you created.
  4. Set Catalog Namespace to the target Iceberg namespace (database) name (for example, analytics_db).
  5. Set Table Name to the name of the Iceberg table that you want to write to (for example, customer_profile).

    Cloudera recommends converting Catalog Namespace and Table Name to parameters so that you can manage them centrally and set them at deployment time.

  6. Configure any remaining processor properties (such as Record Reader), settings, and relationships for your data flow, and click Apply Changes.