Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
6 changes: 6 additions & 0 deletions crates/stackable-operator/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

### Added

- Inject vector aggregator address into vector config file using an environment variable ([#1000]).

[#1000]: https://github.com/stackabletech/operator-rs/pull/1000

## [0.89.1] - 2025-04-02

### Changed
Expand Down
35 changes: 23 additions & 12 deletions crates/stackable-operator/src/product_logging/framework.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const SHUTDOWN_FILE: &str = "shutdown";

/// File name of the Vector config file
pub const VECTOR_CONFIG_FILE: &str = "vector.yaml";
/// Key in the discovery ConfigMap that holds the vector aggregator address
const VECTOR_AGGREGATOR_CM_KEY: &str = "ADDRESS";

#[derive(Debug, Snafu)]
pub enum LoggingError {
Expand Down Expand Up @@ -678,7 +680,6 @@ pub fn create_logback_config(
/// # }
/// #
/// # let logging = fragment::validate::<Logging<Container>>(default_logging()).unwrap();
/// # let vector_aggregator_address = "vector-aggregator:6000";
/// # let role_group = RoleGroupRef {
/// # cluster: ObjectRef::<Pod>::new("test-cluster"),
/// # role: "role".into(),
Expand All @@ -702,7 +703,6 @@ pub fn create_logback_config(
/// product_logging::framework::VECTOR_CONFIG_FILE,
/// product_logging::framework::create_vector_config(
/// &role_group,
/// vector_aggregator_address,
/// vector_log_config,
/// ),
/// );
Expand All @@ -712,7 +712,6 @@ pub fn create_logback_config(
/// ```
pub fn create_vector_config<T>(
role_group: &RoleGroupRef<T>,
vector_aggregator_address: &str,
config: Option<&AutomaticContainerLogConfig>,
) -> String
where
Expand Down Expand Up @@ -1330,7 +1329,7 @@ sinks:
inputs:
- extended_logs
type: vector
address: {vector_aggregator_address}
address: $VECTOR_AGGREGATOR_ADDRESS
"#,
namespace = role_group.cluster.namespace.clone().unwrap_or_default(),
cluster_name = role_group.cluster.name,
Expand Down Expand Up @@ -1419,14 +1418,20 @@ sinks:
/// );
///
/// if logging.enable_vector_agent {
/// pod_builder.add_container(product_logging::framework::vector_container(
/// &resolved_product_image,
/// "config",
/// "log",
/// logging.containers.get(&Container::Vector),
/// resources,
/// ).unwrap());
/// }
/// if let Some(vector_aggregator_config_map_name) = spec
/// .cluster_config
/// .vector_aggregator_config_map_name
/// .to_owned()
/// {
/// pod_builder.add_container(product_logging::framework::vector_container(
/// &resolved_product_image,
/// "config",
/// "log",
/// logging.containers.get(&Container::Vector),
/// resources,
/// vector_aggregator_config_map_name,
/// ).unwrap());
/// }
///
/// pod_builder.build().unwrap();
/// ```
Expand All @@ -1436,6 +1441,7 @@ pub fn vector_container(
log_volume_name: &str,
log_config: Option<&ContainerLogConfig>,
resources: ResourceRequirements,
vector_aggregator_config_map_name: &str,
) -> Result<Container, LoggingError> {
let log_level = if let Some(ContainerLogConfig {
choice: Some(ContainerLogConfigChoice::Automatic(automatic_log_config)),
Expand Down Expand Up @@ -1473,6 +1479,11 @@ kill $vector_pid
"
)])
.add_env_var("VECTOR_LOG", log_level.to_vector_literal())
.add_env_var_from_config_map(
"VECTOR_AGGREGATOR_ADDRESS",
vector_aggregator_config_map_name,
VECTOR_AGGREGATOR_CM_KEY,
)
.add_volume_mount(config_volume_name, STACKABLE_CONFIG_DIR)
.context(AddVolumeMountsSnafu)?
.add_volume_mount(log_volume_name, STACKABLE_LOG_DIR)
Expand Down
Loading