Skip to content

Commit c3f785d

Browse files
committed
feat: requestedSecretLifetime role group property added
1 parent 526f589 commit c3f785d

File tree

7 files changed

+61
-17
lines changed

7 files changed

+61
-17
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
### Added
8+
9+
- The lifetime of auto generated TLS certificates is now configurable with the role and roleGroup config property `requestedSecretLifetime` ([#619])
10+
711
### Fixed
812

913
- BREAKING: Use distinct ServiceAccounts for the Stacklets, so that multiple Stacklets can be
1014
deployed in one namespace. Existing Stacklets will use the newly created ServiceAccounts after
1115
restart ([#616]).
1216

1317
[#616]: https://github.com/stackabletech/hdfs-operator/pull/616
18+
[#619]: https://github.com/stackabletech/hdfs-operator/pull/619
1419

1520
## [24.11.0] - 2024-11-18
1621

Cargo.lock

Lines changed: 4 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ tokio = { version = "1.40", features = ["full"] }
2828
tracing = "0.1"
2929
tracing-futures = { version = "0.2", features = ["futures-03"] }
3030

31-
#[patch."https://github.com/stackabletech/operator-rs.git"]
31+
[patch."https://github.com/stackabletech/operator-rs.git"]
3232
#stackable-operator = { path = "../operator-rs/crates/stackable-operator" }
33-
#stackable-operator = { git = "https://github.com/stackabletech//operator-rs.git", branch = "main" }
33+
stackable-operator = { git = "https://github.com/stackabletech//operator-rs.git", branch = "feat/request-secret-lifetime" }

deploy/helm/hdfs-operator/crds/crds.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,10 @@ spec:
261261
nullable: true
262262
type: boolean
263263
type: object
264+
requestedSecretLifetime:
265+
description: Request secret (currently only autoTls certificates) lifetime from the secret operator, e.g. `7d`, or `30d`. This can be shortened by the `maxCertificateLifetime` setting on the SecretClass issuing the TLS certificate.
266+
nullable: true
267+
type: string
264268
resources:
265269
default:
266270
cpu:
@@ -538,6 +542,10 @@ spec:
538542
nullable: true
539543
type: boolean
540544
type: object
545+
requestedSecretLifetime:
546+
description: Request secret (currently only autoTls certificates) lifetime from the secret operator, e.g. `7d`, or `30d`. This can be shortened by the `maxCertificateLifetime` setting on the SecretClass issuing the TLS certificate.
547+
nullable: true
548+
type: string
541549
resources:
542550
default:
543551
cpu:
@@ -840,6 +848,10 @@ spec:
840848
nullable: true
841849
type: boolean
842850
type: object
851+
requestedSecretLifetime:
852+
description: Request secret (currently only autoTls certificates) lifetime from the secret operator, e.g. `7d`, or `30d`. This can be shortened by the `maxCertificateLifetime` setting on the SecretClass issuing the TLS certificate.
853+
nullable: true
854+
type: string
843855
resources:
844856
default:
845857
cpu:
@@ -1104,6 +1116,10 @@ spec:
11041116
nullable: true
11051117
type: boolean
11061118
type: object
1119+
requestedSecretLifetime:
1120+
description: Request secret (currently only autoTls certificates) lifetime from the secret operator, e.g. `7d`, or `30d`. This can be shortened by the `maxCertificateLifetime` setting on the SecretClass issuing the TLS certificate.
1121+
nullable: true
1122+
type: string
11071123
resources:
11081124
default:
11091125
cpu:
@@ -1353,6 +1369,10 @@ spec:
13531369
nullable: true
13541370
type: boolean
13551371
type: object
1372+
requestedSecretLifetime:
1373+
description: Request secret (currently only autoTls certificates) lifetime from the secret operator, e.g. `7d`, or `30d`. This can be shortened by the `maxCertificateLifetime` setting on the SecretClass issuing the TLS certificate.
1374+
nullable: true
1375+
type: string
13561376
resources:
13571377
default:
13581378
cpu:
@@ -1621,6 +1641,10 @@ spec:
16211641
nullable: true
16221642
type: boolean
16231643
type: object
1644+
requestedSecretLifetime:
1645+
description: Request secret (currently only autoTls certificates) lifetime from the secret operator, e.g. `7d`, or `30d`. This can be shortened by the `maxCertificateLifetime` setting on the SecretClass issuing the TLS certificate.
1646+
nullable: true
1647+
type: string
16241648
resources:
16251649
default:
16261650
cpu:

rust/crd/src/constants.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,7 @@ pub const LISTENER_VOLUME_NAME: &str = "listener";
8787
pub const LISTENER_VOLUME_DIR: &str = "/stackable/listener";
8888

8989
pub const HDFS_UID: i64 = 1000;
90+
91+
pub const DEFAULT_NAME_NODE_SECRET_LIFETIME: Duration = Duration::from_days_unchecked(7);
92+
pub const DEFAULT_DATA_NODE_SECRET_LIFETIME: Duration = Duration::from_days_unchecked(7);
93+
pub const DEFAULT_JOURNAL_NODE_SECRET_LIFETIME: Duration = Duration::from_days_unchecked(7);

rust/crd/src/lib.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,10 @@ pub struct CommonNodeConfig {
238238
/// Time period Pods have to gracefully shut down, e.g. `30m`, `1h` or `2d`. Consult the operator documentation for details.
239239
#[fragment_attrs(serde(default))]
240240
pub graceful_shutdown_timeout: Option<Duration>,
241+
/// Request secret (currently only autoTls certificates) lifetime from the secret operator, e.g. `7d`, or `30d`.
242+
/// This can be shortened by the `maxCertificateLifetime` setting on the SecretClass issuing the TLS certificate.
243+
#[fragment_attrs(serde(default))]
244+
pub requested_secret_lifetime: Option<Duration>,
241245
}
242246

243247
/// Configuration for a rolegroup of an unknown type.
@@ -310,6 +314,13 @@ impl AnyNodeConfig {
310314
AnyNodeConfig::JournalNode(node) => node.logging.enable_vector_agent,
311315
}
312316
}
317+
pub fn requested_secret_lifetime(&self) -> Option<Duration> {
318+
match self {
319+
AnyNodeConfig::NameNode(node) => node.common.requested_secret_lifetime,
320+
AnyNodeConfig::DataNode(node) => node.common.requested_secret_lifetime,
321+
AnyNodeConfig::JournalNode(node) => node.common.requested_secret_lifetime,
322+
}
323+
}
313324
}
314325

315326
#[derive(
@@ -1098,6 +1109,7 @@ impl NameNodeConfigFragment {
10981109
common: CommonNodeConfigFragment {
10991110
affinity: get_affinity(cluster_name, role),
11001111
graceful_shutdown_timeout: Some(DEFAULT_NAME_NODE_GRACEFUL_SHUTDOWN_TIMEOUT),
1112+
requested_secret_lifetime: Some(DEFAULT_NAME_NODE_SECRET_LIFETIME),
11011113
},
11021114
}
11031115
}
@@ -1237,6 +1249,7 @@ impl DataNodeConfigFragment {
12371249
common: CommonNodeConfigFragment {
12381250
affinity: get_affinity(cluster_name, role),
12391251
graceful_shutdown_timeout: Some(DEFAULT_DATA_NODE_GRACEFUL_SHUTDOWN_TIMEOUT),
1252+
requested_secret_lifetime: Some(DEFAULT_DATA_NODE_SECRET_LIFETIME),
12401253
},
12411254
}
12421255
}
@@ -1347,6 +1360,7 @@ impl JournalNodeConfigFragment {
13471360
common: CommonNodeConfigFragment {
13481361
affinity: get_affinity(cluster_name, role),
13491362
graceful_shutdown_timeout: Some(DEFAULT_JOURNAL_NODE_GRACEFUL_SHUTDOWN_TIMEOUT),
1363+
requested_secret_lifetime: Some(DEFAULT_JOURNAL_NODE_SECRET_LIFETIME),
13501364
},
13511365
}
13521366
}

rust/operator-binary/src/container.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ type Result<T, E = Error> = std::result::Result<T, E>;
8989
#[derive(Snafu, Debug, EnumDiscriminants)]
9090
#[strum_discriminants(derive(IntoStaticStr))]
9191
pub enum Error {
92+
#[snafu(display("missing secret lifetime"))]
93+
MissingSecretLifetime,
94+
9295
#[snafu(display("object has no namespace"))]
9396
ObjectHasNoNamespace,
9497

@@ -272,6 +275,11 @@ impl ContainerConfig {
272275
.with_node_scope()
273276
.with_format(SecretFormat::TlsPkcs12)
274277
.with_tls_pkcs12_password(TLS_STORE_PASSWORD)
278+
.with_auto_tls_cert_lifetime(
279+
merged_config
280+
.requested_secret_lifetime()
281+
.context(MissingSecretLifetimeSnafu)?,
282+
)
275283
.build()
276284
.context(BuildSecretVolumeSnafu {
277285
volume_name: TLS_STORE_VOLUME_NAME,

0 commit comments

Comments
 (0)