11use stackable_operator:: {
2- builder:: { meta:: ObjectMetaBuilder , pod:: container:: ContainerBuilder } ,
2+ builder:: {
3+ meta:: ObjectMetaBuilder ,
4+ pod:: { container:: ContainerBuilder , volume:: SecretFormat } ,
5+ } ,
36 crd:: listener:: { self } ,
47 k8s_openapi:: {
58 DeepMerge ,
@@ -15,6 +18,7 @@ use stackable_operator::{
1518 } ,
1619 kube:: api:: ObjectMeta ,
1720 kvp:: { Label , Labels } ,
21+ time:: Duration ,
1822} ;
1923
2024use super :: node_config:: { CONFIGURATION_FILE_OPENSEARCH_YML , NodeConfig } ;
@@ -23,7 +27,7 @@ use crate::{
2327 crd:: v1alpha1,
2428 framework:: {
2529 RoleGroupName ,
26- builder:: meta:: ownerreference_from_resource,
30+ builder:: { meta:: ownerreference_from_resource, volume :: build_tls_volume } ,
2731 kvp:: label:: { recommended_labels, role_group_selector, role_selector} ,
2832 listener:: listener_pvc,
2933 role_group_utils:: ResourceNames ,
@@ -40,6 +44,8 @@ const DATA_VOLUME_NAME: &str = "data";
4044
4145const LISTENER_VOLUME_NAME : & str = "listener" ;
4246const LISTENER_VOLUME_DIR : & str = "/stackable/listener" ;
47+ const TLS_VOLUME_NAME : & str = "tls" ;
48+ const TLS_VOLUME_DIR : & str = "/stackable/tls" ;
4349
4450const DEFAULT_OPENSEARCH_HOME : & str = "/stackable/opensearch" ;
4551
@@ -152,8 +158,13 @@ impl<'a> RoleGroupBuilder<'a> {
152158
153159 fn build_pod_template ( & self ) -> PodTemplateSpec {
154160 let mut node_role_labels = Labels :: new ( ) ;
161+ let mut service_scopes = vec ! [ self . resource_names. headless_service_name( ) ] ;
162+
155163 for node_role in self . role_group_config . config . node_roles . iter ( ) {
156164 node_role_labels. insert ( Self :: build_node_role_label ( node_role) ) ;
165+ if let v1alpha1:: NodeRole :: ClusterManager = node_role {
166+ service_scopes. push ( self . cluster . name . to_string ( ) )
167+ }
157168 }
158169
159170 let metadata = ObjectMetaBuilder :: new ( )
@@ -198,14 +209,24 @@ impl<'a> RoleGroupBuilder<'a> {
198209 . config
199210 . termination_grace_period_seconds ,
200211 ) ,
201- volumes : Some ( vec ! [ Volume {
202- name: CONFIG_VOLUME_NAME . to_owned( ) ,
203- config_map: Some ( ConfigMapVolumeSource {
204- name: self . resource_names. role_group_config_map( ) ,
205- ..Default :: default ( )
206- } ) ,
207- ..Volume :: default ( )
208- } ] ) ,
212+ volumes : Some ( vec ! [
213+ Volume {
214+ name: CONFIG_VOLUME_NAME . to_owned( ) ,
215+ config_map: Some ( ConfigMapVolumeSource {
216+ name: self . resource_names. role_group_config_map( ) ,
217+ ..Default :: default ( )
218+ } ) ,
219+ ..Volume :: default ( )
220+ } ,
221+ build_tls_volume(
222+ TLS_VOLUME_NAME ,
223+ & self . cluster. cluster_config. tls. secret_class,
224+ service_scopes,
225+ SecretFormat :: TlsPem ,
226+ & Duration :: from_days_unchecked( 15 ) ,
227+ Some ( LISTENER_VOLUME_NAME ) ,
228+ ) ,
229+ ] ) ,
209230 ..PodSpec :: default ( )
210231 } ) ,
211232 } ;
@@ -312,6 +333,11 @@ impl<'a> RoleGroupBuilder<'a> {
312333 name : LISTENER_VOLUME_NAME . to_owned ( ) ,
313334 ..VolumeMount :: default ( )
314335 } ,
336+ VolumeMount {
337+ mount_path : TLS_VOLUME_DIR . to_owned ( ) ,
338+ name : TLS_VOLUME_NAME . to_owned ( ) ,
339+ ..VolumeMount :: default ( )
340+ } ,
315341 ] )
316342 . expect ( "The mount paths are statically defined and there should be no duplicates." )
317343 . add_container_ports ( vec ! [
0 commit comments