@@ -31,6 +31,10 @@ const SHUTDOWN_FILE: &str = "shutdown";
3131
3232/// File name of the Vector config file
3333pub 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 ) ]
3640pub 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/// ```
713715pub fn create_vector_config < T > (
714716 role_group : & RoleGroupRef < T > ,
715- vector_aggregator_address : & str ,
716717 config : Option < & AutomaticContainerLogConfig > ,
717718) -> String
718719where
@@ -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