File tree Expand file tree Collapse file tree
rust/operator-binary/src/backend Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -355,6 +355,21 @@ impl SecretBackend for TlsGenerate {
355355 }
356356 }
357357
358+ let domain_components = if selector. autotls_cert_domain_components_in_subject_dn {
359+ [
360+ Some ( pod_info. pod_name . as_str ( ) ) ,
361+ pod_info. service_name . as_deref ( ) ,
362+ Some ( & pod_info. namespace ) ,
363+ Some ( "svc" ) ,
364+ ]
365+ . into_iter ( )
366+ . flatten ( )
367+ . chain ( pod_info. kubernetes_cluster_domain . split ( '.' ) )
368+ . collect ( )
369+ } else {
370+ vec ! [ ]
371+ } ;
372+
358373 let pod_cert = X509Builder :: new ( )
359374 . and_then ( |mut x509| {
360375 let subject_name = X509NameBuilder :: new ( )
@@ -363,6 +378,12 @@ impl SecretBackend for TlsGenerate {
363378 Nid :: COMMONNAME ,
364379 "generated certificate for pod" ,
365380 ) ?;
381+ for domain_component in domain_components {
382+ name. append_entry_by_nid (
383+ Nid :: DOMAINCOMPONENT ,
384+ domain_component,
385+ ) ?;
386+ }
366387 Ok ( name)
367388 } ) ?
368389 . build ( ) ;
Original file line number Diff line number Diff line change @@ -129,6 +129,13 @@ pub struct SecretVolumeSelector {
129129 ) ]
130130 pub autotls_cert_jitter_factor : f64 ,
131131
132+ #[ serde(
133+ rename = "secrets.stackable.tech/backend.autotls.cert.domain-components-in-subject-dn" ,
134+ deserialize_with = "SecretVolumeSelector::deserialize_str_as_bool" ,
135+ default
136+ ) ]
137+ pub autotls_cert_domain_components_in_subject_dn : bool ,
138+
132139 /// The TLS cert lifetime (when using the [`cert_manager`] backend).
133140 ///
134141 /// The format is documented in <https://docs.stackable.tech/home/nightly/concepts/duration>.
@@ -301,6 +308,16 @@ impl SecretVolumeSelector {
301308 )
302309 } )
303310 }
311+
312+ fn deserialize_str_as_bool < ' de , D : Deserializer < ' de > > ( de : D ) -> Result < bool , D :: Error > {
313+ let str = String :: deserialize ( de) ?;
314+ str. parse ( ) . map_err ( |_| {
315+ <D :: Error as serde:: de:: Error >:: invalid_value (
316+ Unexpected :: Str ( & str) ,
317+ & "a string containing a boolean" ,
318+ )
319+ } )
320+ }
304321}
305322
306323#[ derive( Debug ) ]
Original file line number Diff line number Diff line change @@ -104,7 +104,9 @@ pub enum FromPodError {
104104#[ derive( Debug ) ]
105105pub struct PodInfo {
106106 pub pod_ips : Vec < IpAddr > ,
107+ pub pod_name : String ,
107108 pub service_name : Option < String > ,
109+ pub namespace : String ,
108110 pub node_name : String ,
109111 pub node_ips : Vec < IpAddr > ,
110112 pub listener_addresses : Option < ListenerAddresses > ,
@@ -119,6 +121,8 @@ impl PodInfo {
119121 scopes : & [ SecretScope ] ,
120122 ) -> Result < Self , FromPodError > {
121123 use from_pod_error:: * ;
124+ let pod_name = pod. metadata . name . clone ( ) . context ( NoPodNameSnafu ) ?;
125+ let namespace = pod. metadata . namespace . clone ( ) . context ( NoNamespaceSnafu ) ?;
122126 let node_name = pod
123127 . spec
124128 . as_ref ( )
@@ -150,7 +154,9 @@ impl PodInfo {
150154 . context ( from_pod_error:: IllegalAddressSnafu { address : ip } )
151155 } )
152156 . collect :: < Result < _ , _ > > ( ) ?,
157+ pod_name,
153158 service_name : pod. spec . as_ref ( ) . and_then ( |spec| spec. subdomain . clone ( ) ) ,
159+ namespace,
154160 node_name,
155161 node_ips : node
156162 . status
You can’t perform that action at this time.
0 commit comments