Skip to content

Commit 5ec590c

Browse files
committed
fix: Re-enable custom ca.secret.namespace for 'tls' SecretClass
1 parent b66f3c3 commit 5ec590c

2 files changed

Lines changed: 23 additions & 6 deletions

File tree

deploy/helm/secret-operator/templates/daemonset.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ spec:
7272
fieldRef:
7373
fieldPath: spec.nodeName
7474

75+
# The namespace that the TLS Certificate Authority is installed into.
76+
# Internally defaults to the namespace where secret-operator is installed.
77+
{{- if .Values.secretClasses.tls.caSecretNamespace }}
78+
- name: TLS_SECRETCLASS_CA_SECRET_NAMESPACE
79+
value: {{ .Values.secretClasses.tls.caSecretNamespace }}
80+
{{- end }}
81+
7582
{{- if .Values.kubernetesClusterDomain }}
7683
- name: KUBERNETES_CLUSTER_DOMAIN
7784
value: {{ .Values.kubernetesClusterDomain | quote }}

rust/operator-binary/src/main.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ struct Opts {
5656

5757
#[derive(clap::Parser)]
5858
struct SecretOperatorRun {
59-
#[clap(long, env)]
59+
#[arg(long, env)]
6060
csi_endpoint: PathBuf,
6161

6262
/// Unprivileged mode disables any features that require running secret-operator in a privileged container.
@@ -65,10 +65,16 @@ struct SecretOperatorRun {
6565
/// - Secret volumes will be stored on disk, rather than in a ramdisk
6666
///
6767
/// Unprivileged mode is EXPERIMENTAL and heavily discouraged, since it increases the risk of leaking secrets.
68-
#[clap(long, env)]
68+
#[arg(long, env)]
6969
privileged: bool,
7070

71-
#[clap(flatten)]
71+
/// The namespace that the TLS Certificate Authority is installed into.
72+
///
73+
/// Defaults to the namespace where secret-operator is installed.
74+
#[arg(long, env)]
75+
tls_secretclass_ca_secret_namespace: Option<String>,
76+
77+
#[command(flatten)]
7278
common: RunArguments,
7379
}
7480

@@ -87,6 +93,7 @@ async fn main() -> anyhow::Result<()> {
8793
.print_yaml_schema(built_info::PKG_VERSION, SerializeOptions::default())?;
8894
}
8995
stackable_operator::cli::Command::Run(SecretOperatorRun {
96+
tls_secretclass_ca_secret_namespace,
9097
csi_endpoint,
9198
privileged,
9299
common:
@@ -176,9 +183,12 @@ async fn main() -> anyhow::Result<()> {
176183
.run()
177184
.map_err(|err| anyhow!(err).context("failed to run CRD maintainer"));
178185

186+
let ca_secret_namespace = tls_secretclass_ca_secret_namespace
187+
.unwrap_or(operator_environment.operator_namespace.clone());
188+
179189
let default_secretclass = create_default_secretclass(
180190
initial_reconcile_rx,
181-
operator_environment.operator_namespace.clone(),
191+
ca_secret_namespace,
182192
client.clone(),
183193
)
184194
.map_err(|err| anyhow!(err).context("failed to apply default custom resources"));
@@ -197,7 +207,7 @@ async fn main() -> anyhow::Result<()> {
197207

198208
async fn create_default_secretclass(
199209
initial_reconcile_rx: oneshot::Receiver<()>,
200-
operator_namespace: String,
210+
ca_secret_namespace: String,
201211
client: Client,
202212
) -> anyhow::Result<()> {
203213
initial_reconcile_rx.await?;
@@ -225,7 +235,7 @@ async fn create_default_secretclass(
225235
if let v1alpha2::SecretClassBackend::AutoTls(auto_tls_backend) =
226236
&mut tls_secret_class.spec.backend
227237
{
228-
auto_tls_backend.ca.secret.namespace = operator_namespace
238+
auto_tls_backend.ca.secret.namespace = ca_secret_namespace
229239
}
230240

231241
client.create_if_missing(&tls_secret_class).await?;

0 commit comments

Comments
 (0)