@@ -87,7 +87,7 @@ use crate::{
8787 authentication:: resolve_authentication_classes,
8888 catalog,
8989 discovery:: { TrinoDiscovery , TrinoDiscoveryProtocol , TrinoPodRef } ,
90- rolegroup_metrics_service_name , v1alpha1,
90+ rolegroup_headless_service_name , v1alpha1,
9191 } ,
9292 listener:: {
9393 LISTENER_VOLUME_DIR , LISTENER_VOLUME_NAME , build_group_listener, build_group_listener_pvc,
@@ -871,7 +871,7 @@ fn build_rolegroup_catalog_config_map(
871871/// The rolegroup [`StatefulSet`] runs the rolegroup, as configured by the administrator.
872872///
873873/// The [`Pod`](`stackable_operator::k8s_openapi::api::core::v1::Pod`)s are accessible through the
874- /// corresponding [`Service`] (from [`build_rolegroup_service `]).
874+ /// corresponding [`Service`] (from [`build_rolegroup_headless_service `]).
875875#[ allow( clippy:: too_many_arguments) ]
876876fn build_rolegroup_statefulset (
877877 trino : & v1alpha1:: TrinoCluster ,
@@ -964,6 +964,9 @@ fn build_rolegroup_statefulset(
964964 . requested_secret_lifetime
965965 . context ( MissingSecretLifetimeSnafu ) ?;
966966
967+ let extra_service_scopes = group_listener_name ( trino, trino_role)
968+ . map ( |listener_service_name| vec ! [ listener_service_name] ) ;
969+
967970 // add volume mounts depending on the client tls, internal tls, catalogs and authentication
968971 tls_volume_mounts (
969972 trino,
@@ -972,6 +975,7 @@ fn build_rolegroup_statefulset(
972975 & mut cb_trino,
973976 catalogs,
974977 & requested_secret_lifetime,
978+ extra_service_scopes,
975979 ) ?;
976980
977981 let mut prepare_args = vec ! [ ] ;
@@ -1230,7 +1234,7 @@ fn build_rolegroup_statefulset(
12301234 ) ,
12311235 ..LabelSelector :: default ( )
12321236 } ,
1233- service_name : Some ( rolegroup_metrics_service_name (
1237+ service_name : Some ( rolegroup_headless_service_name (
12341238 & role_group_ref. object_name ( ) ,
12351239 ) ) ,
12361240 template : pod_template,
@@ -1511,14 +1515,25 @@ fn create_tls_volume(
15111515 volume_name : & str ,
15121516 tls_secret_class : & str ,
15131517 requested_secret_lifetime : & Duration ,
1518+ service_scopes : Option < Vec < String > > ,
15141519) -> Result < Volume > {
1520+ let mut secret_volume_source_builder = SecretOperatorVolumeSourceBuilder :: new ( tls_secret_class) ;
1521+
1522+ secret_volume_source_builder
1523+ . with_pod_scope ( )
1524+ . with_node_scope ( )
1525+ . with_format ( SecretFormat :: TlsPkcs12 )
1526+ . with_auto_tls_cert_lifetime ( * requested_secret_lifetime) ;
1527+
1528+ if let Some ( scopes) = & service_scopes {
1529+ for scope in scopes {
1530+ secret_volume_source_builder. with_service_scope ( scope) ;
1531+ }
1532+ }
1533+
15151534 Ok ( VolumeBuilder :: new ( volume_name)
15161535 . ephemeral (
1517- SecretOperatorVolumeSourceBuilder :: new ( tls_secret_class)
1518- . with_pod_scope ( )
1519- . with_node_scope ( )
1520- . with_format ( SecretFormat :: TlsPkcs12 )
1521- . with_auto_tls_cert_lifetime ( * requested_secret_lifetime)
1536+ secret_volume_source_builder
15221537 . build ( )
15231538 . context ( TlsCertSecretClassVolumeBuildSnafu ) ?,
15241539 )
@@ -1532,6 +1547,7 @@ fn tls_volume_mounts(
15321547 cb_trino : & mut ContainerBuilder ,
15331548 catalogs : & [ CatalogConfig ] ,
15341549 requested_secret_lifetime : & Duration ,
1550+ extra_service_scopes : Option < Vec < String > > ,
15351551) -> Result < ( ) > {
15361552 if let Some ( server_tls) = trino. get_server_tls ( ) {
15371553 cb_prepare
@@ -1545,6 +1561,8 @@ fn tls_volume_mounts(
15451561 "server-tls-mount" ,
15461562 server_tls,
15471563 requested_secret_lifetime,
1564+ // add listener
1565+ extra_service_scopes,
15481566 ) ?)
15491567 . context ( AddVolumeSnafu ) ?;
15501568 }
@@ -1581,6 +1599,7 @@ fn tls_volume_mounts(
15811599 "internal-tls-mount" ,
15821600 internal_tls,
15831601 requested_secret_lifetime,
1602+ None ,
15841603 ) ?)
15851604 . context ( AddVolumeSnafu ) ?;
15861605
0 commit comments