@@ -28,7 +28,7 @@ use stackable_operator::{
2828 security:: PodSecurityContextBuilder ,
2929 volume:: {
3030 ListenerOperatorVolumeSourceBuilder , ListenerOperatorVolumeSourceBuilderError ,
31- ListenerReference , VolumeBuilder ,
31+ ListenerReference , SecretOperatorVolumeSourceBuilder , VolumeBuilder ,
3232 } ,
3333 } ,
3434 } ,
@@ -86,7 +86,7 @@ use crate::{
8686 command:: build_container_command_args,
8787 config:: {
8888 jvm:: { construct_hadoop_heapsize_env, construct_non_heap_jvm_args} ,
89- opa:: HiveOpaConfig ,
89+ opa:: { HiveOpaConfig , OPA_TLS_VOLUME_NAME } ,
9090 } ,
9191 crd:: {
9292 APP_NAME , CORE_SITE_XML , Container , DB_PASSWORD_ENV , DB_USERNAME_ENV , HIVE_PORT ,
@@ -323,6 +323,11 @@ pub enum Error {
323323 InvalidOpaConfig {
324324 source : stackable_operator:: commons:: opa:: Error ,
325325 } ,
326+
327+ #[ snafu( display( "failed to build TLS certificate SecretClass Volume" ) ) ]
328+ TlsCertSecretClassVolumeBuild {
329+ source : stackable_operator:: builder:: pod:: volume:: SecretOperatorVolumeSourceBuilderError ,
330+ } ,
326331}
327332type Result < T , E = Error > = std:: result:: Result < T , E > ;
328333
@@ -472,6 +477,7 @@ pub async fn reconcile_hive(
472477 s3_connection_spec. as_ref ( ) ,
473478 & config,
474479 & rbac_sa. name_any ( ) ,
480+ hive_opa_config. as_ref ( ) ,
475481 ) ?;
476482
477483 cluster_resources
@@ -742,6 +748,7 @@ fn build_metastore_rolegroup_statefulset(
742748 s3_connection : Option < & s3:: v1alpha1:: ConnectionSpec > ,
743749 merged_config : & MetaStoreConfig ,
744750 sa_name : & str ,
751+ hive_opa_config : Option < & HiveOpaConfig > ,
745752) -> Result < StatefulSet > {
746753 let role = hive. role ( hive_role) . context ( InternalOperatorFailureSnafu ) ?;
747754 let rolegroup = hive
@@ -815,6 +822,32 @@ fn build_metastore_rolegroup_statefulset(
815822 }
816823 }
817824
825+ // Add OPA TLS certs if configured
826+ if let Some ( ( tls_secret_class, tls_mount_path) ) =
827+ hive_opa_config. as_ref ( ) . and_then ( |opa_config| {
828+ opa_config
829+ . tls_secret_class
830+ . as_ref ( )
831+ . zip ( opa_config. tls_ca_cert_mount_path ( ) )
832+ } )
833+ {
834+ container_builder
835+ . add_volume_mount ( OPA_TLS_VOLUME_NAME , & tls_mount_path)
836+ . context ( AddVolumeMountSnafu ) ?;
837+
838+ let opa_tls_volume = VolumeBuilder :: new ( OPA_TLS_VOLUME_NAME )
839+ . ephemeral (
840+ SecretOperatorVolumeSourceBuilder :: new ( tls_secret_class)
841+ . build ( )
842+ . context ( TlsCertSecretClassVolumeBuildSnafu ) ?,
843+ )
844+ . build ( ) ;
845+
846+ pod_builder
847+ . add_volume ( opa_tls_volume)
848+ . context ( AddVolumeSnafu ) ?;
849+ }
850+
818851 let db_type = hive. db_type ( ) ;
819852 let start_command = if resolved_product_image. product_version . starts_with ( "3." ) {
820853 // The schematool version in 3.1.x does *not* support the `-initOrUpgradeSchema` flag yet, so we can not use that.
@@ -866,6 +899,7 @@ fn build_metastore_rolegroup_statefulset(
866899 create_vector_shutdown_file_command( STACKABLE_LOG_DIR ) ,
867900 } ,
868901 s3_connection,
902+ hive_opa_config,
869903 ) )
870904 . add_volume_mount ( STACKABLE_CONFIG_DIR_NAME , STACKABLE_CONFIG_DIR )
871905 . context ( AddVolumeMountSnafu ) ?
0 commit comments