Configuring virtual-hosted-style S3 access for external clients

Configure Ozone S3 Gateway, Hive Metastore, and Hive on Tez so that external clients such as Snowflake can read shared Iceberg tables with virtual-hosted-style S3 requests, while cluster services (such as Hive Metastore hosting REST Catalog and HiveServer2) keep using path-style requests.

  • You must complete Configuring Hive Metastore as a REST Catalog for Ozone storage.
  • You must have a publicly accessible S3-compatible endpoint, such as a load balancer or reverse proxy in front of Ozone S3 Gateway, that the external client can reach. The endpoint must forward the original Host header to Ozone S3 Gateway unchanged, including any port number. S3 clients sign the Host header of each request, so if the endpoint changes the header, Ozone S3 Gateway rejects the request with an HTTP 403 error. The same requirement applies to any internal load balancer in front of Ozone S3 Gateway.
  • You must have DNS records for the endpoint domain ([***PUBLIC_S3_DOMAIN***]) and for the wildcard domain (*.[***PUBLIC_S3_DOMAIN***]) that resolve to the endpoint.
  • You must have a TLS certificate from a publicly trusted certificate authority for the endpoint that covers both [***PUBLIC_S3_DOMAIN***] and *.[***PUBLIC_S3_DOMAIN***], so that external clients trust the endpoint. If TLS terminates at the endpoint, Ozone S3 Gateway can keep using its internal certificate.
  • For Snowflake, the endpoint must also meet the Snowflake requirements for S3-compatible storage, and Snowflake Support must enable the endpoint for your Snowflake account. For more information, see Requirements for S3-compatible storage in the Snowflake documentation.

Some external clients, such as Snowflake, send virtual-hosted-style S3 requests, in which the bucket name is part of the host name, for example https://[***BUCKET_NAME***].[***PUBLIC_S3_DOMAIN***]/[***KEY***]. By default, Ozone S3 Gateway and the Cloudera Iceberg REST Catalog use path-style requests, for example https://[***S3_HOST***]/[***BUCKET_NAME***]/[***KEY***].

In this configuration, two access paths use different endpoints and addressing styles:

  • Hive Metastore, which hosts the REST Catalog, and HiveServer2 read and write Iceberg metadata through their own S3A client. The fs.s3a.endpoint property points this client to an Ozone S3 Gateway, or to an internal load balancer in front of the Ozone S3 Gateways, on the internal network, which it reaches with path-style requests.
  • External clients use the public endpoint that the REST Catalog returns to them in the hive.metastore.catalog.ozone.s3.gateway property, which they reach with virtual-hosted-style requests. They reach the Cloudera Iceberg REST Catalog itself through the Knox URL, which is the URL that you use, for example, in the Snowflake catalog integration.

Ozone S3 Gateway serves both styles at the same time when the ozone.s3g.domain.name property is set. For more information about the two styles, see Virtual hosting of buckets in the Amazon S3 documentation.

  1. Create an Ozone bucket with the OBJECT_STORE layout in the s3v volume for the tables that you share:
    ozone sh bucket create --layout OBJECT_STORE /s3v/[***BUCKET_NAME***]
  2. In Cloudera Manager, go to Clusters > OZONE-1 > Configuration and search for Ozone Service Advanced Configuration Snippet (Safety Valve) for ozone-conf/ozone-site.xml.
  3. Add the following properties:
    <property><name>ozone.s3g.domain.name</name><value>[***PUBLIC_S3_DOMAIN***],[***S3G_HOST_1***],[***S3G_HOST_2***]</value></property>
    <property><name>ozone.om.enable.filesystem.paths</name><value>false</value></property>

    In ozone.s3g.domain.name, list the host names without port numbers, separated by commas: the public endpoint domain, and the fully qualified domain name of every Ozone S3 Gateway host and internal load balancer that clients use.

    For more information about ozone.om.enable.filesystem.paths, see Configuring Ozone to work as a pure object store.

  4. Click Save Changes and restart the Ozone service.
  5. Go to Clusters > HIVE-1 > Configuration, search for Hive Service Advanced Configuration Snippet (Safety Valve) for hive-site.xml, and set the following properties:
    <property><name>hive.metastore.catalog.ozone.s3.gateway</name><value>https://[***PUBLIC_S3_DOMAIN***]</value></property>
    <property><name>hive.metastore.catalog.ozone.s3.path.style.access</name><value>false</value></property>
    <property><name>fs.s3a.path.style.access</name><value>false</value></property>

    The hive.metastore.catalog.ozone.s3.gateway property sets the public endpoint that the REST Catalog returns to external clients. When hive.metastore.catalog.ozone.s3.path.style.access is false, the REST Catalog tells external clients to use virtual-hosted-style requests. The default value is true.

    These values replace the hive.metastore.catalog.ozone.s3.gateway and fs.s3a.path.style.access values that you set when you configured Hive Metastore as a REST Catalog for Ozone storage.

  6. Search for Hive Service Advanced Configuration Snippet (Safety Valve) for core-site.xml and add the following property for each bucket that stores shared tables:
    <property><name>fs.s3a.bucket.[***BUCKET_NAME***].path.style.access</name><value>true</value></property>

    These per-bucket properties keep Hive's own S3A client on path-style requests to the internal Ozone S3 Gateway.

  7. Go to Clusters > HIVE_ON_TEZ-1 > Configuration and add the same settings to the Hive on Tez service:
    • In Hive Service Advanced Configuration Snippet (Safety Valve) for hive-site.xml, set fs.s3a.path.style.access to false.
    • In Hive Service Advanced Configuration Snippet (Safety Valve) for core-site.xml, add fs.s3a.bucket.[***BUCKET_NAME***].path.style.access with the value true for each bucket that stores shared tables.
  8. Click Save Changes, and then run Actions > Deploy Client Configuration and restart the Hive and Hive on Tez services.
  9. Generate a long-lived S3 access key and secret in Ozone for the external client.

    Snowflake uses this static key for the bucket. It does not use the short-lived credentials that the REST Catalog vends. For instructions, see Obtaining S3 credentials in Ozone. Provide the external client administrator with the public endpoint, the access key and secret, and the bucket and base path of the shared tables.

The REST Catalog loadTable call returns the table metadata, and the response tells external clients to use virtual-hosted-style requests to the public endpoint. To test the call, see Supported REST Catalog APIs for accessing the data.

If loadTable fails with an UnknownHostException for a host name such as [***BUCKET_NAME***].[***OZONE_S3_GATEWAY_HOST***], Hive is sending virtual-hosted-style requests to the internal Ozone S3 Gateway. Add the per-bucket path.style.access property for that bucket.

To configure Snowflake to read the shared tables, see Configure an external volume for S3-compatible storage and Configure a catalog integration for Apache Iceberg REST catalogs in the Snowflake documentation.