@@ -76,10 +76,10 @@ use strum::{EnumDiscriminants, IntoStaticStr};
7676
7777use crate :: {
7878 authentication:: { TrinoAuthenticationConfig , TrinoAuthenticationTypes } ,
79- authorization:: opa:: TrinoOpaConfig ,
79+ authorization:: opa:: { OPA_TLS_VOLUME_NAME , TrinoOpaConfig } ,
8080 catalog:: { FromTrinoCatalogError , config:: CatalogConfig } ,
81- command, config ,
82- config:: { client_protocol, fault_tolerant_execution} ,
81+ command,
82+ config:: { self , client_protocol, fault_tolerant_execution} ,
8383 crd:: {
8484 ACCESS_CONTROL_PROPERTIES , APP_NAME , CONFIG_DIR_NAME , CONFIG_PROPERTIES , Container ,
8585 DISCOVERY_URI , ENV_INTERNAL_SECRET , ENV_SPOOLING_SECRET , EXCHANGE_MANAGER_PROPERTIES ,
@@ -630,6 +630,7 @@ pub async fn reconcile_trino(
630630 & rbac_sa. name_any ( ) ,
631631 & resolved_fte_config,
632632 & resolved_client_protocol_config,
633+ & trino_opa_config,
633634 ) ?;
634635
635636 cluster_resources
@@ -1037,6 +1038,7 @@ fn build_rolegroup_statefulset(
10371038 sa_name : & str ,
10381039 resolved_fte_config : & Option < fault_tolerant_execution:: ResolvedFaultTolerantExecutionConfig > ,
10391040 resolved_spooling_config : & Option < client_protocol:: ResolvedClientProtocolConfig > ,
1041+ trino_opa_config : & Option < TrinoOpaConfig > ,
10401042) -> Result < StatefulSet > {
10411043 let role = trino
10421044 . role ( trino_role)
@@ -1140,6 +1142,7 @@ fn build_rolegroup_statefulset(
11401142 & requested_secret_lifetime,
11411143 resolved_fte_config,
11421144 resolved_spooling_config,
1145+ trino_opa_config,
11431146 ) ?;
11441147
11451148 let mut prepare_args = vec ! [ ] ;
@@ -1165,6 +1168,17 @@ fn build_rolegroup_statefulset(
11651168 prepare_args
11661169 . extend ( trino_authentication_config. commands ( & TrinoRole :: Coordinator , & Container :: Prepare ) ) ;
11671170
1171+ // Add OPA TLS certificate to truststore if configured
1172+ if let Some ( tls_mount_path) = trino_opa_config
1173+ . as_ref ( )
1174+ . and_then ( |opa_config| opa_config. tls_mount_path ( ) )
1175+ {
1176+ prepare_args. extend ( command:: add_cert_to_truststore (
1177+ format ! ( "{}/ca.crt" , tls_mount_path) . as_str ( ) ,
1178+ STACKABLE_CLIENT_TLS_DIR ,
1179+ ) ) ;
1180+ }
1181+
11681182 let container_prepare = cb_prepare
11691183 . image_from_product_image ( resolved_product_image)
11701184 . command ( vec ! [
@@ -1710,6 +1724,7 @@ fn tls_volume_mounts(
17101724 requested_secret_lifetime : & Duration ,
17111725 resolved_fte_config : & Option < fault_tolerant_execution:: ResolvedFaultTolerantExecutionConfig > ,
17121726 resolved_spooling_config : & Option < client_protocol:: ResolvedClientProtocolConfig > ,
1727+ trino_opa_config : & Option < TrinoOpaConfig > ,
17131728) -> Result < ( ) > {
17141729 if let Some ( server_tls) = trino. get_server_tls ( ) {
17151730 cb_prepare
@@ -1789,6 +1804,32 @@ fn tls_volume_mounts(
17891804 . context ( AddVolumeSnafu ) ?;
17901805 }
17911806
1807+ // Add OPA TLS certs if configured
1808+ if let Some ( ( tls_secret_class, tls_mount_path) ) =
1809+ trino_opa_config. as_ref ( ) . and_then ( |opa_config| {
1810+ opa_config
1811+ . tls_secret_class
1812+ . as_ref ( )
1813+ . zip ( opa_config. tls_mount_path ( ) )
1814+ } )
1815+ {
1816+ cb_prepare
1817+ . add_volume_mount ( OPA_TLS_VOLUME_NAME , & tls_mount_path)
1818+ . context ( AddVolumeMountSnafu ) ?;
1819+
1820+ let opa_tls_volume = VolumeBuilder :: new ( OPA_TLS_VOLUME_NAME )
1821+ . ephemeral (
1822+ SecretOperatorVolumeSourceBuilder :: new ( tls_secret_class)
1823+ . build ( )
1824+ . context ( TlsCertSecretClassVolumeBuildSnafu ) ?,
1825+ )
1826+ . build ( ) ;
1827+
1828+ pod_builder
1829+ . add_volume ( opa_tls_volume)
1830+ . context ( AddVolumeSnafu ) ?;
1831+ }
1832+
17921833 // fault tolerant execution S3 credentials and other resources
17931834 if let Some ( resolved_fte) = resolved_fte_config {
17941835 cb_prepare
@@ -2028,6 +2069,7 @@ mod tests {
20282069 . to_string ( ) ,
20292070 ) ,
20302071 allow_permission_management_operations : true ,
2072+ tls_secret_class : None ,
20312073 } ) ;
20322074 let resolved_fte_config = match & trino. spec . cluster_config . fault_tolerant_execution {
20332075 Some ( fault_tolerant_execution) => Some (
0 commit comments