Skip to main content

Governed Hive Metastore (Enterprise)

Hive Metastore 3 does not authenticate its clients. Whoever reaches its Thrift port can create a table over any storage location, and a governed engine then reads that location under a table name that no Ranger policy covers. Ranger policies on tables therefore protect governed data only if users cannot change the metastore those engines read.

Ilum runs a second Hive Metastore for governed data, ilum-hive-metastore-governed, next to the bundled one. It has its own PostgreSQL database, its own warehouse and its own storage key, and a NetworkPolicy admits connections only from Trino, ilum-core and the namespaces allowed to use it. Domain teams keep their tables in the bundled metastore.

Requirements​

  • An Ilum installation with Apache Ranger and the governed engines (see Apache Ranger).
  • A network plugin that enforces Kubernetes NetworkPolicy (Calico, Cilium and others). Without it, the metastore is reachable from every pod.
  • A storage key for the metastore, limited to the governed buckets. The platform key reaches every bucket and must not be used here.

Installing​

Create the Secret with the metastore's storage key in the release namespace:

kubectl -n <release namespace> create secret generic ilum-hive-metastore-governed-storage \
--from-literal=access-key=<access key> --from-literal=secret-key=<secret key>

Then turn the metastore on:

ilum-hive-metastore-governed:
enabled: true
storage:
metastore:
warehouse: "s3a://<governed bucket>/"
networkPolicy:
workspaces: [hr]

The postgresExtensions Job creates the database metastore_governed on the bundled PostgreSQL while postgresExtensions.enabled is on (the render fails if it is off), and the metastore creates its schema on the first start. On another PostgreSQL, create the database yourself. The metastore is reachable in the cluster at thrift://ilum-hive-metastore-governed.<release namespace>.svc.cluster.local:9083.

Network access​

The NetworkPolicy admits port 9083 from:

  • pods of the release namespace that carry the labels in networkPolicy.pods: by default Trino (app.kubernetes.io/name: ilum-trino) and ilum-core (app: ilum-core);
  • the Spark namespace of each workspace in networkPolicy.workspaces (its notebook namespace is not admitted);
  • the namespaces in networkPolicy.namespaces;
  • the peers in networkPolicy.extraFrom, written as in a NetworkPolicy's ingress[].from.

Spark pods never match a label peer: a job sets the labels of its driver and executors, so a label would admit any job in the release namespace. Governed Spark SQL engines and workspace jobs reach the metastore only from a namespace listed in namespaces or workspaces. Run them on a cluster whose Spark namespace is listed there, and set that cluster's catalog to the governed metastore.

ilum-core reaches the metastore for the Table Explorer. In governed mode the DuckDB session lockdown refuses ATTACH, so SQL editor users cannot attach the metastore through ilum-core.

Trino catalogs​

Trino reads the metastore through the catalogs hr and hr_files, each with a key limited to the governed buckets (see Catalogs on their own identities).

Registering the metastore in Ilum​

Add the metastore under Data Catalogs as a Hive catalog with the address above. In the Access section, mark it as Restricted and select the Bound groups that may see it: a restricted catalog is hidden from everyone else in the Table Explorer and the catalog endpoints, and DuckDB attaches it only to sessions the DuckDB Ranger guard checks. Only members of the bound groups and holders of METASTORE_MANAGE can link it to a cluster or unlink it (see Restricted catalogs).

Querying a restricted catalog​

A query in the SQL editor runs on one cluster and reads that cluster's catalog. When the catalog is restricted, ilum-core decides by engine:

EngineRuns when
DuckDBWith the DuckDB Ranger guard on (sql.duckdb.guard.enabled, set by values-governed.yaml): the cluster is governed. Without the guard: never while sql.duckdb.refuseRestrictedCatalogs is on, which governed mode always sets, because the cluster's storage holds the catalog's files
Spark SQLThe cluster is governed and the Ilum SQL guard is on (sql.guard.enabled, set by values-governed.yaml)
TrinoThe cluster is governed

A cluster is governed for a restricted catalog when nobody outside the catalog's bound groups may run Spark jobs on it, because a Spark job reads the catalog's storage without Ranger. That is the case when:

  • its Groups that may run jobs list (submitGroups) is empty while clusters with an empty list admit only administrators (security.clusterAccess.unrestrictedWhenEmpty: false, set by governed mode), or
  • every group on that list is one of the catalog's bound groups.

Who may run SQL on the cluster (sqlGroups) does not matter here: Spark SQL, Trino and the DuckDB guard apply the Ranger policies of the signed-in user. A typical setup is a cluster for governed SQL with an empty job list and the SQL users in its SQL list, and the workspace of the team that owns the data, whose job list holds only that team.

The same rule applies to engine creation and to Spark SQL engines that Kyuubi starts for JDBC clients. A refused query answers 403 with the reason, for example The catalog governed of cluster finance is restricted, and the cluster is not governed: users outside the catalog's groups may run Spark jobs on it. ..., and is recorded in the event log as CLUSTER_ACCESS_DENIED with the action SQL.

note

The rule follows the catalog of the cluster. Trino also reaches its own catalogs (hr, hr_files), whatever the cluster: Ranger decides access to them in Trino.

Configuration​

The table shows the values of ilum-hive-metastore-governed in the helm_aio chart, which differ from the defaults in the README of the ilum-hive-metastore chart (for example networkPolicy.enabled, which is true here and false in the chart).

NameDescriptionDefault
ilum-hive-metastore-governed.enabledDeploy the governed metastorefalse
ilum-hive-metastore-governed.postgresql.databaseIts PostgreSQL databasemetastore_governed
ilum-hive-metastore-governed.postgresql.auth.existingSecretSecret with the database password; empty: the chart stores postgresql.auth.password in ilum-hive-metastore-governed-postgresql""
ilum-hive-metastore-governed.storage.metastore.warehouseWarehouse of new databases and managed tabless3a://ilum-governed/
ilum-hive-metastore-governed.storage.s3.existingSecretSecret with the storage key (access-key, secret-key)ilum-hive-metastore-governed-storage
ilum-hive-metastore-governed.networkPolicy.enabledAdmit port 9083 only from the peers belowtrue
ilum-hive-metastore-governed.networkPolicy.podsPods of the release namespace, by labelsTrino and ilum-core
ilum-hive-metastore-governed.networkPolicy.workspacesWorkspaces whose Spark namespace may connect[]
ilum-hive-metastore-governed.networkPolicy.workspaceReleaseValue of the label ilum.cloud/release of workspace namespaces, <namespace>.<release> of the Ilum release; set it when the chart is installed as a release of its own"" (this release)
ilum-hive-metastore-governed.networkPolicy.namespacesOther namespaces that may connect[]
ilum-hive-metastore-governed.networkPolicy.extraFromFurther NetworkPolicy peers[]

The chart is the same as the bundled metastore's, so every parameter of the ilum-hive-metastore chart README applies under ilum-hive-metastore-governed.

The query routing above has one setting in ilum-core:

NameDescriptionDefault
ilum-core.sql.duckdb.refuseRestrictedCatalogsRefuse DuckDB queries on a cluster whose catalog is restricted. Always on in governed modefalse

Limits​

  • Every client the NetworkPolicy admits can read and change every table definition in the metastore. Keep the list of admitted namespaces short.
  • The isolation works at the network level only. A Hive 4 metastore with an authorizer that asks Ranger is a later step.