Skip to content

Commit 7c35c40

Browse files
feat: Inject vector aggregator address into config as env (#1000)
* inject vector aggregator address as env into config file * add changelog entry * fix rustdoc * run cargo fmt * fix doctest * Update crates/stackable-operator/CHANGELOG.md Co-authored-by: Siegfried Weber <[email protected]> * move env name into const * Update crates/stackable-operator/src/product_logging/framework.rs Co-authored-by: Siegfried Weber <[email protected]> * move env name into const --------- Co-authored-by: Siegfried Weber <[email protected]>
1 parent cd73728 commit 7c35c40

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

Cargo.lock

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

crates/stackable-operator/CHANGELOG.md

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

55
## [Unreleased]
66

7+
### Added
8+
9+
- BREAKING: Inject vector aggregator address into vector config file using an environment variable ([#1000]).
10+
11+
[#1000]: https://github.com/stackabletech/operator-rs/pull/1000
12+
713
## [0.89.1] - 2025-04-02
814

915
### Changed

crates/stackable-operator/src/product_logging/framework.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ const SHUTDOWN_FILE: &str = "shutdown";
3131

3232
/// File name of the Vector config file
3333
pub const VECTOR_CONFIG_FILE: &str = "vector.yaml";
34+
/// Key in the discovery ConfigMap that holds the vector aggregator address
35+
const VECTOR_AGGREGATOR_CM_KEY: &str = "ADDRESS";
36+
/// Name of the env var in the vector container that holds the vector aggregator address
37+
const VECTOR_AGGREGATOR_ENV_NAME: &str = "VECTOR_AGGREGATOR_ADDRESS";
3438

3539
#[derive(Debug, Snafu)]
3640
pub enum LoggingError {
@@ -678,7 +682,6 @@ pub fn create_logback_config(
678682
/// # }
679683
/// #
680684
/// # let logging = fragment::validate::<Logging<Container>>(default_logging()).unwrap();
681-
/// # let vector_aggregator_address = "vector-aggregator:6000";
682685
/// # let role_group = RoleGroupRef {
683686
/// # cluster: ObjectRef::<Pod>::new("test-cluster"),
684687
/// # role: "role".into(),
@@ -702,7 +705,6 @@ pub fn create_logback_config(
702705
/// product_logging::framework::VECTOR_CONFIG_FILE,
703706
/// product_logging::framework::create_vector_config(
704707
/// &role_group,
705-
/// vector_aggregator_address,
706708
/// vector_log_config,
707709
/// ),
708710
/// );
@@ -712,7 +714,6 @@ pub fn create_logback_config(
712714
/// ```
713715
pub fn create_vector_config<T>(
714716
role_group: &RoleGroupRef<T>,
715-
vector_aggregator_address: &str,
716717
config: Option<&AutomaticContainerLogConfig>,
717718
) -> String
718719
where
@@ -1330,7 +1331,7 @@ sinks:
13301331
inputs:
13311332
- extended_logs
13321333
type: vector
1333-
address: {vector_aggregator_address}
1334+
address: ${VECTOR_AGGREGATOR_ENV_NAME}
13341335
"#,
13351336
namespace = role_group.cluster.namespace.clone().unwrap_or_default(),
13361337
cluster_name = role_group.cluster.name,
@@ -1386,6 +1387,7 @@ sinks:
13861387
/// # image_pull_policy: "Always".into(),
13871388
/// # pull_secrets: None,
13881389
/// # };
1390+
/// # let vector_aggregator_config_map_name = "vector-aggregator-discovery";
13891391
///
13901392
/// let mut pod_builder = PodBuilder::new();
13911393
/// pod_builder.metadata(ObjectMetaBuilder::default().build());
@@ -1425,6 +1427,7 @@ sinks:
14251427
/// "log",
14261428
/// logging.containers.get(&Container::Vector),
14271429
/// resources,
1430+
/// vector_aggregator_config_map_name,
14281431
/// ).unwrap());
14291432
/// }
14301433
///
@@ -1436,6 +1439,7 @@ pub fn vector_container(
14361439
log_volume_name: &str,
14371440
log_config: Option<&ContainerLogConfig>,
14381441
resources: ResourceRequirements,
1442+
vector_aggregator_config_map_name: &str,
14391443
) -> Result<Container, LoggingError> {
14401444
let log_level = if let Some(ContainerLogConfig {
14411445
choice: Some(ContainerLogConfigChoice::Automatic(automatic_log_config)),
@@ -1473,6 +1477,11 @@ kill $vector_pid
14731477
"
14741478
)])
14751479
.add_env_var("VECTOR_LOG", log_level.to_vector_literal())
1480+
.add_env_var_from_config_map(
1481+
VECTOR_AGGREGATOR_ENV_NAME,
1482+
vector_aggregator_config_map_name,
1483+
VECTOR_AGGREGATOR_CM_KEY,
1484+
)
14761485
.add_volume_mount(config_volume_name, STACKABLE_CONFIG_DIR)
14771486
.context(AddVolumeMountsSnafu)?
14781487
.add_volume_mount(log_volume_name, STACKABLE_LOG_DIR)

0 commit comments

Comments
 (0)