Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support setting TLS certificate lifetimes #598

Merged
merged 11 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@

## [Unreleased]

### Added

- Lifetime of auto generated certificates is configurable with the `requestedSecretLifetime` role group property ([#598])
razvan marked this conversation as resolved.
Show resolved Hide resolved

### Fixed

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

[#594]: https://github.com/stackabletech/hbase-operator/pull/594
[#598]: https://github.com/stackabletech/hbase-operator/pull/598

## [24.11.0] - 2024-11-18

Expand Down
19 changes: 4 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ strum = { version = "0.26", features = ["derive"] }
tokio = { version = "1.40", features = ["full"] }
tracing = "0.1"

#[patch."https://github.com/stackabletech/operator-rs.git"]
#stackable-operator = { git = "https://github.com/stackabletech//operator-rs.git", branch = "main" }
[patch."https://github.com/stackabletech/operator-rs.git"]
stackable-operator = { git = "https://github.com/stackabletech//operator-rs.git", branch = "feat/request-secret-lifetime" }
24 changes: 24 additions & 0 deletions deploy/helm/hbase-operator/crds/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,10 @@ spec:
nullable: true
type: boolean
type: object
requestedSecretLifetime:
description: Request secret (currently only auto certificates) lifetime from the secret operator.
nullable: true
type: string
resources:
default:
cpu:
Expand Down Expand Up @@ -520,6 +524,10 @@ spec:
nullable: true
type: boolean
type: object
requestedSecretLifetime:
description: Request secret (currently only auto certificates) lifetime from the secret operator.
nullable: true
type: string
resources:
default:
cpu:
Expand Down Expand Up @@ -724,6 +732,10 @@ spec:
nullable: true
type: boolean
type: object
requestedSecretLifetime:
description: Request secret (currently only auto certificates) lifetime from the secret operator.
nullable: true
type: string
resources:
default:
cpu:
Expand Down Expand Up @@ -947,6 +959,10 @@ spec:
nullable: true
type: boolean
type: object
requestedSecretLifetime:
description: Request secret (currently only auto certificates) lifetime from the secret operator.
nullable: true
type: string
resources:
default:
cpu:
Expand Down Expand Up @@ -1151,6 +1167,10 @@ spec:
nullable: true
type: boolean
type: object
requestedSecretLifetime:
description: Request secret (currently only auto certificates) lifetime from the secret operator.
nullable: true
type: string
resources:
default:
cpu:
Expand Down Expand Up @@ -1374,6 +1394,10 @@ spec:
nullable: true
type: boolean
type: object
requestedSecretLifetime:
description: Request secret (currently only auto certificates) lifetime from the secret operator.
nullable: true
type: string
resources:
default:
cpu:
Expand Down
8 changes: 8 additions & 0 deletions rust/crd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ const DEFAULT_REGION_SERVER_GRACEFUL_SHUTDOWN_TIMEOUT: Duration =
Duration::from_minutes_unchecked(60);
const DEFAULT_REST_SERVER_GRACEFUL_SHUTDOWN_TIMEOUT: Duration = Duration::from_minutes_unchecked(5);

// Auto TLS certificate lifetime
pub const DEFAULT_SECRET_LIFETIME: Duration = Duration::from_days_unchecked(7);
sbernauer marked this conversation as resolved.
Show resolved Hide resolved

#[derive(Snafu, Debug)]
pub enum Error {
#[snafu(display("the role [{role}] is invalid and does not exist in HBase"))]
Expand Down Expand Up @@ -316,6 +319,7 @@ impl HbaseRole {
logging: product_logging::spec::default_logging(),
affinity: get_affinity(cluster_name, self, hdfs_discovery_cm_name),
graceful_shutdown_timeout: Some(graceful_shutdown_timeout),
requested_secret_lifetime: Some(DEFAULT_SECRET_LIFETIME),
}
}

Expand Down Expand Up @@ -410,6 +414,10 @@ pub struct HbaseConfig {
/// Time period Pods have to gracefully shut down, e.g. `30m`, `1h` or `2d`. Consult the operator documentation for details.
#[fragment_attrs(serde(default))]
pub graceful_shutdown_timeout: Option<Duration>,

/// Request secret (currently only auto certificates) lifetime from the secret operator.
razvan marked this conversation as resolved.
Show resolved Hide resolved
#[fragment_attrs(serde(default))]
pub requested_secret_lifetime: Option<Duration>,
}

impl Configuration for HbaseConfigFragment {
Expand Down
20 changes: 14 additions & 6 deletions rust/operator-binary/src/hbase_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ use strum::{EnumDiscriminants, IntoStaticStr, ParseError};

use stackable_hbase_crd::{
merged_env, Container, HbaseCluster, HbaseClusterStatus, HbaseConfig, HbaseConfigFragment,
HbaseRole, APP_NAME, CONFIG_DIR_NAME, HBASE_ENV_SH, HBASE_HEAPSIZE, HBASE_MANAGES_ZK,
HBASE_MASTER_OPTS, HBASE_REGIONSERVER_OPTS, HBASE_REST_OPTS, HBASE_REST_PORT_NAME_HTTP,
HBASE_REST_PORT_NAME_HTTPS, HBASE_SITE_XML, JVM_HEAP_FACTOR, JVM_SECURITY_PROPERTIES_FILE,
METRICS_PORT, SSL_CLIENT_XML, SSL_SERVER_XML,
HbaseRole, APP_NAME, CONFIG_DIR_NAME, DEFAULT_SECRET_LIFETIME, HBASE_ENV_SH, HBASE_HEAPSIZE,
HBASE_MANAGES_ZK, HBASE_MASTER_OPTS, HBASE_REGIONSERVER_OPTS, HBASE_REST_OPTS,
HBASE_REST_PORT_NAME_HTTP, HBASE_REST_PORT_NAME_HTTPS, HBASE_SITE_XML, JVM_HEAP_FACTOR,
JVM_SECURITY_PROPERTIES_FILE, METRICS_PORT, SSL_CLIENT_XML, SSL_SERVER_XML,
};

use crate::product_logging::STACKABLE_LOG_DIR;
Expand Down Expand Up @@ -986,8 +986,16 @@ fn build_rolegroup_statefulset(

add_graceful_shutdown_config(config, &mut pod_builder).context(GracefulShutdownSnafu)?;
if hbase.has_kerberos_enabled() {
add_kerberos_pod_config(hbase, hbase_role, &mut hbase_container, &mut pod_builder)
.context(AddKerberosConfigSnafu)?;
add_kerberos_pod_config(
hbase,
hbase_role,
&mut hbase_container,
&mut pod_builder,
config
.requested_secret_lifetime
.unwrap_or(DEFAULT_SECRET_LIFETIME),
sbernauer marked this conversation as resolved.
Show resolved Hide resolved
)
.context(AddKerberosConfigSnafu)?;
}
pod_builder.add_container(hbase_container.build());

Expand Down
3 changes: 3 additions & 0 deletions rust/operator-binary/src/kerberos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use stackable_operator::{
},
},
kube::{runtime::reflector::ObjectRef, ResourceExt},
time::Duration,
utils::cluster_info::KubernetesClusterInfo,
};

Expand Down Expand Up @@ -232,6 +233,7 @@ pub fn add_kerberos_pod_config(
role: &HbaseRole,
cb: &mut ContainerBuilder,
pb: &mut PodBuilder,
requested_secret_lifetime: Duration,
) -> Result<(), Error> {
if let Some(kerberos_secret_class) = hbase.kerberos_secret_class() {
// Mount keytab
Expand Down Expand Up @@ -270,6 +272,7 @@ pub fn add_kerberos_pod_config(
.with_node_scope()
.with_format(SecretFormat::TlsPkcs12)
.with_tls_pkcs12_password(TLS_STORE_PASSWORD)
.with_auto_tls_cert_lifetime(requested_secret_lifetime)
.build()
.context(AddTlsSecretVolumeSnafu)?,
)
Expand Down