Creating a Managed Service for Trino catalog
A Trino catalog defines a connection to a data source. Each catalog is described using a TrinoCatalog resource and associated with a specific cluster via the spec.cluster field.
Supported catalog types:
- PostgreSQL: Connection properties are specified in
spec.postgres. - ClickHouse®: Connection properties are specified in
spec.clickhouse. - Apache Iceberg™: Connection to Iceberg REST Catalog in Stackland is set in
spec.stacklandRestCatalog.
In the manifest, specify a single section with connector settings. You do not need to add the spec.type property.
Note
When you create a catalog, Managed Service for Trino recreates the cluster. While the new configuration is being applied, the cluster switches to Updating, and active queries get interrupted. For more information, see Updating a cluster.
Using the CLI
-
Get the data source ready:
- For PostgreSQL and ClickHouse®, create a secret with credentials.
- For Apache Iceberg™, make sure the Iceberg REST Catalog and Object Storage components are enabled. Create the Iceberg REST Catalog catalog in the same namespace as the Trino cluster and wait for its status to change to
ready. Grant permissions to the user or service account that will run queries.
-
Create the
TrinoCatalogresource file, e.g., using thetouch trinocatalog.yamlcommand. -
Open the file and paste the configuration for the appropriate catalog type:
PostgreSQLIceberg--- apiVersion: v1 kind: Secret metadata: name: postgres-secret stringData: username: <username> password: <user_password> --- apiVersion: trino.stackland.yandex.cloud/v1alpha1 kind: TrinoCatalog metadata: name: postgresql-test-trino-full spec: cluster: trino-full name: postgresql-test postgres: url: postgres.example.svc.cluster.local:5432/database credentialsSecretRef: name: postgres-secret usernameKey: username passwordKey: passwordSettings:
spec.cluster: Name of the Trino cluster you want to associate the catalog with.spec.name: Catalog name in Trino (used in SQL queries, such asSELECT * FROM <catalog_name>.schema.table).spec.postgres.url: PostgreSQL server address inhost:port/databaseformat.spec.postgres.credentialsSecretRef: Reference to the Secret with credentials, and the names ofusernameKeyandpasswordKey.
-ClickHouse®
{% include notitle [YAML-file](../../_includes/yamls/operations/trino/create-catalog-clickhouse-c3e42da7f70e.md) %} Settings: * `spec.cluster`: Trino cluster name. * `spec.name`: Catalog name in Trino. * `spec.clickhouse.url`: ClickHouse® server address in `host:port/database` format. * `spec.clickhouse.credentialsSecretRef`: Reference to the Secret with credentials.Specify the name of the
StacklandRestCatalogresource. The connection settings for both the catalog and storage will be populated automatically.apiVersion: trino.stackland.yandex.cloud/v1alpha1 kind: TrinoCatalog metadata: name: iceberg-test-trino-full spec: cluster: trino-full name: iceberg-test stacklandRestCatalog: catalogRef: analyticsSettings:
spec.cluster: Trino cluster name.spec.name: Catalog name in Trino SQL queries.spec.stacklandRestCatalog.catalogRef:StacklandRestCatalogresource name in the same namespace.spec.stacklandRestCatalog.useExternalEndpoint: Using an external catalog address. The default value isfalse, i.e., the internal address is used. You may specifytrueif public access is enabled for the catalog and thestatus.externalEndpointfield is populated.spec.stacklandRestCatalog.additionalProperties: Additional Iceberg settings, i.e., data format and compression, file size, filter requirements for queries, statistics, storage options, and Iceberg view support. This is an optional setting.
The following example uses the catalog's external endpoint. For new tables, the default settings are the
PARQUETformat,ZSTDcompression, and target maximum file size of512MB. Queries to partitioned tables within thereportsandeventsSQL schemas require a filter by partition keys. The storage connection timeout is set to10s, and the read/write timeout is30s. Settingiceberg.rest-catalog.view-endpoints-enabled: trueenables support for Iceberg views. When creating views, specifySECURITY INVOKER; for more information, see Iceberg views.apiVersion: trino.stackland.yandex.cloud/v1alpha1 kind: TrinoCatalog metadata: name: iceberg-test-trino-full spec: cluster: trino-full name: iceberg-test stacklandRestCatalog: catalogRef: analytics useExternalEndpoint: true additionalProperties: iceberg.rest-catalog.view-endpoints-enabled: true iceberg.file-format: PARQUET iceberg.compression-codec: ZSTD iceberg.target-max-file-size: "512MB" iceberg.query-partition-filter-required: true iceberg.query-partition-filter-required-schemas: "reports,events" s3.socket-connect-timeout: "10s" s3.socket-timeout: "30s"Tip
Make sure the resource name (
metadata.name) follows the<spec.name>-<spec.cluster>format as shown above. Otherwise, the operator will reject catalog creation. -
Apply the manifest:
kubectl apply -f trinocatalog.yaml -n <namespace>.
Using the management console
To connect Apache Iceberg™, first, create an Iceberg REST Catalog catalog in the same namespace, wait until it is ready, and assign permission to a user or group.
-
If you have not opened a project yet, select one.
-
Select the namespace the cluster was created in.
-
In the left-hand menu, select Trino → Clusters.
-
Select the cluster.
-
Open the Catalogs tab and click Create catalog.
-
Fill out the fields as follows:
Basic settings
- Name: Catalog name in Trino. It is defined in
spec.name. The management console automatically uses the<catalog_name>-<cluster_name>format for the Kubernetes resource name (metadata.name). - Type: Connector type, i.e.,
postgresql,clickhouse, oriceberg.
After selecting the type, the Catalog settings section appears.
Catalog settings: PostgreSQL
- URL: Server address in
host:port/databaseformat. - Username: PostgreSQL user.
- Password: User password.
Catalog settings: ClickHouse
- URL: Server address in
host:port/databaseformat. - Username: ClickHouse® user.
- Password: User password.
Сatalog settings: Iceberg
- REST Catalog: Iceberg REST Catalog catalog within the current namespace.
- Access method: Internal or External. The External method is available if the selected catalog has a configured external address.
Additional settings (optional)
Specify supported connector settings as
key:valuepairs. You can add each key only once. For Apache Iceberg™, you can configure settings for data storage, queries, storage access, and Iceberg views. - Name: Catalog name in Trino. It is defined in
-
Click Create.
The new catalog is ready and shown in the Catalogs list. After the operator applies the new configuration and the cluster switches to Running, the catalog will be available in SQL queries.