Skip to content

Commit acb686e

Browse files
committed
Separate out kcat secret management now that it is the only PEM user
1 parent cab56ff commit acb686e

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

rust/crd/src/security.rs

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ impl<'a> KafkaTlsSecurity<'a> {
9898
const INTER_SSL_CLIENT_AUTH: &'static str = "listener.name.internal.ssl.client.auth";
9999
// directories
100100
// for kcat container
101-
const STACKABLE_TLS_CERT_SERVER_DIR: &'static str = "/stackable/tls_cert_server_mount";
102-
const STACKABLE_TLS_CERT_SERVER_DIR_NAME: &'static str = "tls-cert-server-mount";
101+
const STACKABLE_TLS_CERT_KCAT_DIR: &'static str = "/stackable/tls_cert_kcat";
102+
const STACKABLE_TLS_CERT_KCAT_DIR_NAME: &'static str = "tls-cert-kcat";
103103
// kafka container
104104
const STACKABLE_TLS_KEYSTORE_SERVER_DIR: &'static str = "/stackable/tls_keystore_server";
105105
const STACKABLE_TLS_KEYSTORE_SERVER_DIR_NAME: &'static str = "tls-keystore-server";
@@ -218,12 +218,12 @@ impl<'a> KafkaTlsSecurity<'a> {
218218
args.push("-b".to_string());
219219
args.push(format!("localhost:{}", port));
220220
args.extend(Self::kcat_client_auth_ssl(
221-
Self::STACKABLE_TLS_CERT_SERVER_DIR,
221+
Self::STACKABLE_TLS_CERT_KCAT_DIR,
222222
));
223223
} else if self.tls_server_secret_class().is_some() {
224224
args.push("-b".to_string());
225225
args.push(format!("localhost:{}", port));
226-
args.extend(Self::kcat_client_ssl(Self::STACKABLE_TLS_CERT_SERVER_DIR));
226+
args.extend(Self::kcat_client_ssl(Self::STACKABLE_TLS_CERT_KCAT_DIR));
227227
} else {
228228
args.push("-b".to_string());
229229
args.push(format!("localhost:{}", port));
@@ -272,14 +272,13 @@ impl<'a> KafkaTlsSecurity<'a> {
272272
// add tls (server or client authentication volumes) if required
273273
if let Some(tls_server_secret_class) = self.get_tls_secret_class() {
274274
// We have to mount tls pem files for kcat (the mount can be used directly)
275-
pod_builder.add_volume(Self::create_tls_volume(
276-
&self.kafka.bootstrap_service_name(),
277-
Self::STACKABLE_TLS_CERT_SERVER_DIR_NAME,
275+
pod_builder.add_volume(Self::create_kcat_tls_volume(
276+
Self::STACKABLE_TLS_CERT_KCAT_DIR_NAME,
278277
tls_server_secret_class,
279278
)?);
280279
cb_kcat_prober.add_volume_mount(
281-
Self::STACKABLE_TLS_CERT_SERVER_DIR_NAME,
282-
Self::STACKABLE_TLS_CERT_SERVER_DIR,
280+
Self::STACKABLE_TLS_CERT_KCAT_DIR_NAME,
281+
Self::STACKABLE_TLS_CERT_KCAT_DIR,
283282
);
284283
// Keystores fore the kafka container
285284
pod_builder.add_volume(Self::create_tls_keystore_volume(
@@ -426,18 +425,13 @@ impl<'a> KafkaTlsSecurity<'a> {
426425
.or(self.server_secret_class.as_ref())
427426
}
428427

429-
/// Creates ephemeral volumes to mount the `SecretClass` into the Pods
430-
fn create_tls_volume(
431-
kafka_bootstrap_service_name: &str,
432-
volume_name: &str,
433-
secret_class_name: &str,
434-
) -> Result<Volume, Error> {
428+
/// Creates ephemeral volumes to mount the `SecretClass` into the Pods for kcat client
429+
fn create_kcat_tls_volume(volume_name: &str, secret_class_name: &str) -> Result<Volume, Error> {
435430
Ok(VolumeBuilder::new(volume_name)
436431
.ephemeral(
437432
SecretOperatorVolumeSourceBuilder::new(secret_class_name)
438433
.with_pod_scope()
439-
.with_node_scope()
440-
.with_service_scope(kafka_bootstrap_service_name)
434+
.with_format(SecretFormat::TlsPem)
441435
.build()
442436
.context(SecretVolumeBuildSnafu)?,
443437
)

0 commit comments

Comments
 (0)