77use  std:: collections:: BTreeMap ; 
88
99use  indoc:: formatdoc; 
10- use  snafu:: { ensure ,   ResultExt ,  Snafu } ; 
10+ use  snafu:: { ResultExt ,  Snafu ,  ensure } ; 
1111use  stackable_operator:: { 
1212 builder:: { 
1313 self , 
1414 pod:: { 
15+  PodBuilder , 
1516 container:: ContainerBuilder , 
1617 volume:: { SecretFormat ,  SecretOperatorVolumeSourceBuilder ,  VolumeBuilder } , 
17-  PodBuilder , 
1818 } , 
1919 } , 
2020 client:: Client , 
@@ -29,11 +29,12 @@ use stackable_operator::{
2929
3030use  super :: listener:: node_port_cmd; 
3131use  crate :: crd:: { 
32+  KafkaRole ,  LISTENER_BOOTSTRAP_VOLUME_NAME ,  LISTENER_BROKER_VOLUME_NAME ,  SERVER_PROPERTIES_FILE , 
33+  STACKABLE_CONFIG_DIR ,  STACKABLE_KERBEROS_KRB5_PATH ,  STACKABLE_LISTENER_BOOTSTRAP_DIR , 
34+  STACKABLE_LISTENER_BROKER_DIR ,  STACKABLE_LOG_DIR , 
3235 authentication:: { self ,  ResolvedAuthenticationClasses } , 
33-  listener:: { self ,  node_address_cmd,  KafkaListenerConfig } , 
34-  tls,  v1alpha1,  KafkaRole ,  LISTENER_BOOTSTRAP_VOLUME_NAME ,  LISTENER_BROKER_VOLUME_NAME , 
35-  SERVER_PROPERTIES_FILE ,  STACKABLE_CONFIG_DIR ,  STACKABLE_KERBEROS_KRB5_PATH , 
36-  STACKABLE_LISTENER_BOOTSTRAP_DIR ,  STACKABLE_LISTENER_BROKER_DIR ,  STACKABLE_LOG_DIR , 
36+  listener:: { self ,  KafkaListenerConfig ,  node_address_cmd} , 
37+  tls,  v1alpha1, 
3738} ; 
3839
3940#[ derive( Snafu ,  Debug ) ]  
@@ -66,32 +67,12 @@ pub struct KafkaTlsSecurity {
6667} 
6768
6869impl  KafkaTlsSecurity  { 
69-  // ports 
70-  pub  const  CLIENT_PORT_NAME :  & ' static  str  = "kafka" ; 
71-  pub  const  CLIENT_PORT :  u16  = 9092 ; 
72-  pub  const  SECURE_CLIENT_PORT_NAME :  & ' static  str  = "kafka-tls" ; 
73-  pub  const  SECURE_CLIENT_PORT :  u16  = 9093 ; 
70+  pub  const  BOOTSTRAP_PORT :  u16  = 9094 ; 
7471 // bootstrap: we will have a single named port with different values for 
7572 // secure (9095) and insecure (9094). The bootstrap listener is needed to 
7673 // be able to expose principals for both the broker and bootstrap in the 
7774 // JAAS configuration, so that clients can use both. 
7875 pub  const  BOOTSTRAP_PORT_NAME :  & ' static  str  = "bootstrap" ; 
79-  pub  const  BOOTSTRAP_PORT :  u16  = 9094 ; 
80-  pub  const  SECURE_BOOTSTRAP_PORT :  u16  = 9095 ; 
81-  // internal 
82-  pub  const  INTERNAL_PORT :  u16  = 19092 ; 
83-  pub  const  SECURE_INTERNAL_PORT :  u16  = 19093 ; 
84-  // - TLS global 
85-  const  SSL_STORE_PASSWORD :  & ' static  str  = "" ; 
86-  // - TLS client 
87-  const  CLIENT_SSL_KEYSTORE_LOCATION :  & ' static  str  = "listener.name.client.ssl.keystore.location" ; 
88-  const  CLIENT_SSL_KEYSTORE_PASSWORD :  & ' static  str  = "listener.name.client.ssl.keystore.password" ; 
89-  const  CLIENT_SSL_KEYSTORE_TYPE :  & ' static  str  = "listener.name.client.ssl.keystore.type" ; 
90-  const  CLIENT_SSL_TRUSTSTORE_LOCATION :  & ' static  str  =
91-  "listener.name.client.ssl.truststore.location" ; 
92-  const  CLIENT_SSL_TRUSTSTORE_PASSWORD :  & ' static  str  =
93-  "listener.name.client.ssl.truststore.password" ; 
94-  const  CLIENT_SSL_TRUSTSTORE_TYPE :  & ' static  str  = "listener.name.client.ssl.truststore.type" ; 
9576 // - Bootstrapper 
9677 const  BOOTSTRAP_SSL_KEYSTORE_LOCATION :  & ' static  str  =
9778 "listener.name.bootstrap.ssl.keystore.location" ; 
@@ -104,6 +85,7 @@ impl KafkaTlsSecurity {
10485 "listener.name.bootstrap.ssl.truststore.password" ; 
10586 const  BOOTSTRAP_SSL_TRUSTSTORE_TYPE :  & ' static  str  =
10687 "listener.name.bootstrap.ssl.truststore.type" ; 
88+  const  CLIENT_AUTH_SSL_CLIENT_AUTH :  & ' static  str  = "listener.name.client_auth.ssl.client.auth" ; 
10789 // - TLS client authentication 
10890 const  CLIENT_AUTH_SSL_KEYSTORE_LOCATION :  & ' static  str  =
10991 "listener.name.client_auth.ssl.keystore.location" ; 
@@ -117,9 +99,23 @@ impl KafkaTlsSecurity {
11799 "listener.name.client_auth.ssl.truststore.password" ; 
118100 const  CLIENT_AUTH_SSL_TRUSTSTORE_TYPE :  & ' static  str  =
119101 "listener.name.client_auth.ssl.truststore.type" ; 
120-  const  CLIENT_AUTH_SSL_CLIENT_AUTH :  & ' static  str  = "listener.name.client_auth.ssl.client.auth" ; 
102+  pub  const  CLIENT_PORT :  u16  = 9092 ; 
103+  // ports 
104+  pub  const  CLIENT_PORT_NAME :  & ' static  str  = "kafka" ; 
105+  // - TLS client 
106+  const  CLIENT_SSL_KEYSTORE_LOCATION :  & ' static  str  = "listener.name.client.ssl.keystore.location" ; 
107+  const  CLIENT_SSL_KEYSTORE_PASSWORD :  & ' static  str  = "listener.name.client.ssl.keystore.password" ; 
108+  const  CLIENT_SSL_KEYSTORE_TYPE :  & ' static  str  = "listener.name.client.ssl.keystore.type" ; 
109+  const  CLIENT_SSL_TRUSTSTORE_LOCATION :  & ' static  str  =
110+  "listener.name.client.ssl.truststore.location" ; 
111+  const  CLIENT_SSL_TRUSTSTORE_PASSWORD :  & ' static  str  =
112+  "listener.name.client.ssl.truststore.password" ; 
113+  const  CLIENT_SSL_TRUSTSTORE_TYPE :  & ' static  str  = "listener.name.client.ssl.truststore.type" ; 
114+  // internal 
115+  pub  const  INTERNAL_PORT :  u16  = 19092 ; 
121116 // - TLS internal 
122117 const  INTER_BROKER_LISTENER_NAME :  & ' static  str  = "inter.broker.listener.name" ; 
118+  const  INTER_SSL_CLIENT_AUTH :  & ' static  str  = "listener.name.internal.ssl.client.auth" ; 
123119 const  INTER_SSL_KEYSTORE_LOCATION :  & ' static  str  =
124120 "listener.name.internal.ssl.keystore.location" ; 
125121 const  INTER_SSL_KEYSTORE_PASSWORD :  & ' static  str  =
@@ -130,14 +126,19 @@ impl KafkaTlsSecurity {
130126 const  INTER_SSL_TRUSTSTORE_PASSWORD :  & ' static  str  =
131127 "listener.name.internal.ssl.truststore.password" ; 
132128 const  INTER_SSL_TRUSTSTORE_TYPE :  & ' static  str  = "listener.name.internal.ssl.truststore.type" ; 
133-  const  INTER_SSL_CLIENT_AUTH :  & ' static  str  = "listener.name.internal.ssl.client.auth" ; 
129+  pub  const  SECURE_BOOTSTRAP_PORT :  u16  = 9095 ; 
130+  pub  const  SECURE_CLIENT_PORT :  u16  = 9093 ; 
131+  pub  const  SECURE_CLIENT_PORT_NAME :  & ' static  str  = "kafka-tls" ; 
132+  pub  const  SECURE_INTERNAL_PORT :  u16  = 19093 ; 
133+  // - TLS global 
134+  const  SSL_STORE_PASSWORD :  & ' static  str  = "" ; 
135+  const  STACKABLE_TLS_KAFKA_INTERNAL_DIR :  & ' static  str  = "/stackable/tls-kafka-internal" ; 
136+  const  STACKABLE_TLS_KAFKA_INTERNAL_VOLUME_NAME :  & ' static  str  = "tls-kafka-internal" ; 
137+  const  STACKABLE_TLS_KAFKA_SERVER_DIR :  & ' static  str  = "/stackable/tls-kafka-server" ; 
138+  const  STACKABLE_TLS_KAFKA_SERVER_VOLUME_NAME :  & ' static  str  = "tls-kafka-server" ; 
134139 // directories 
135140 const  STACKABLE_TLS_KCAT_DIR :  & ' static  str  = "/stackable/tls-kcat" ; 
136141 const  STACKABLE_TLS_KCAT_VOLUME_NAME :  & ' static  str  = "tls-kcat" ; 
137-  const  STACKABLE_TLS_KAFKA_SERVER_DIR :  & ' static  str  = "/stackable/tls-kafka-server" ; 
138-  const  STACKABLE_TLS_KAFKA_SERVER_VOLUME_NAME :  & ' static  str  = "tls-kafka-server" ; 
139-  const  STACKABLE_TLS_KAFKA_INTERNAL_DIR :  & ' static  str  = "/stackable/tls-kafka-internal" ; 
140-  const  STACKABLE_TLS_KAFKA_INTERNAL_VOLUME_NAME :  & ' static  str  = "tls-kafka-internal" ; 
141142
142143 #[ cfg( test) ]  
143144 pub  fn  new ( 
@@ -685,7 +686,9 @@ impl KafkaTlsSecurity {
685686 "-X" . to_string( ) , 
686687 format!( "sasl.kerberos.service.name={service_name}" ) , 
687688 "-X" . to_string( ) , 
688-  format!( "sasl.kerberos.principal={service_name}/$POD_BROKER_LISTENER_ADDRESS@$KERBEROS_REALM" ) , 
689+  format!( 
690+  "sasl.kerberos.principal={service_name}/$POD_BROKER_LISTENER_ADDRESS@$KERBEROS_REALM" 
691+  ) , 
689692 ] 
690693 } 
691694} 
0 commit comments