Skip to content

Commit 09cb175

Browse files
committed
use listener scope for tls
1 parent 16c1472 commit 09cb175

3 files changed

Lines changed: 28 additions & 7 deletions

File tree

rust/operator-binary/src/crd/security.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,19 +207,28 @@ impl DruidTlsSecurity {
207207
druid: &mut ContainerBuilder,
208208
pod: &mut PodBuilder,
209209
requested_secret_lifetime: &Duration,
210+
listener_scope: Option<String>,
210211
) -> Result<(), Error> {
211212
// `ResolvedAuthenticationClasses::validate` already checked that the tls AuthenticationClass
212213
// uses the same SecretClass as the Druid server itself.
213214
if let Some(secret_class) = &self.server_and_internal_secret_class {
215+
let mut secret_volume_source_builder =
216+
SecretOperatorVolumeSourceBuilder::new(secret_class);
217+
218+
secret_volume_source_builder
219+
.with_pod_scope()
220+
.with_format(SecretFormat::TlsPkcs12)
221+
.with_tls_pkcs12_password(TLS_STORE_PASSWORD)
222+
.with_auto_tls_cert_lifetime(*requested_secret_lifetime);
223+
224+
if let Some(listener_scope) = &listener_scope {
225+
secret_volume_source_builder.with_listener_volume_scope(listener_scope);
226+
}
227+
214228
pod.add_volume(
215229
VolumeBuilder::new(TLS_MOUNT_VOLUME_NAME)
216230
.ephemeral(
217-
SecretOperatorVolumeSourceBuilder::new(secret_class)
218-
.with_pod_scope()
219-
.with_node_scope()
220-
.with_format(SecretFormat::TlsPkcs12)
221-
.with_tls_pkcs12_password(TLS_STORE_PASSWORD)
222-
.with_auto_tls_cert_lifetime(*requested_secret_lifetime)
231+
secret_volume_source_builder
223232
.build()
224233
.context(SecretVolumeBuildSnafu)?,
225234
)

rust/operator-binary/src/druid_controller.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ use crate::{
8181
internal_secret::{create_shared_internal_secret, env_var_from_secret},
8282
listener::{
8383
LISTENER_VOLUME_DIR, LISTENER_VOLUME_NAME, build_group_listener, build_group_listener_pvc,
84-
group_listener_name,
84+
group_listener_name, secret_volume_listener_scope,
8585
},
8686
operations::{graceful_shutdown::add_graceful_shutdown_config, pdb::add_pdbs},
8787
product_logging::extend_role_group_config_map,
@@ -968,6 +968,8 @@ fn build_rolegroup_statefulset(
968968
&mut cb_druid,
969969
&mut pb,
970970
&merged_rolegroup_config.requested_secret_lifetime,
971+
// add listener
972+
secret_volume_listener_scope(role),
971973
)
972974
.context(FailedToInitializeSecurityContextSnafu)?;
973975

rust/operator-binary/src/listener.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,13 @@ pub fn build_listener_connection_string(
126126
})?
127127
))
128128
}
129+
130+
/// The listener volume name depending on the role
131+
pub fn secret_volume_listener_scope(role: &DruidRole) -> Option<String> {
132+
match role {
133+
DruidRole::Broker | DruidRole::Coordinator | DruidRole::Router => {
134+
Some(LISTENER_VOLUME_NAME.to_string())
135+
}
136+
DruidRole::Historical | DruidRole::MiddleManager => None,
137+
}
138+
}

0 commit comments

Comments
 (0)